Module:BibleQuote: Difference between revisions

From Seeds of the Word, the encyclopedia of the influence of the Gospel on culture
Content deleted Content added
No edit summary
No edit summary
Line 1: Line 1:
-- local fs = require("fs")


local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
Line 17: Line 16:
end
end
end
end

return false
return false
end
end


local p = {} --p stands for package
local p = {} --p stands for package

function p.isValidVersion( version )
in_table(version, VERSIONS_AVAILABLE)
end


function p.main( frame )
function p.main( frame )
Line 40: Line 42:
return "<span style=\"color:#36b;font-weight:bold;\" data-ref=\"" .. args.ref .. "\" data-version=\"" .. args.version .. "\">" .. args.ref .. "</span><sup style=\"color:red;font-weight:bold;cursor:pointer;\" title=\"The Bible version '" .. args.version .. "' is not supported by the BibleGet endpoint.\">[!]</sup>"
return "<span style=\"color:#36b;font-weight:bold;\" data-ref=\"" .. args.ref .. "\" data-version=\"" .. args.version .. "\">" .. args.ref .. "</span><sup style=\"color:red;font-weight:bold;cursor:pointer;\" title=\"The Bible version '" .. args.version .. "' is not supported by the BibleGet endpoint.\">[!]</sup>"
end
end
end
end
--[[
--[[

Revision as of 23:45, September 4, 2020

Documentation for this module may be created at Module:BibleQuote/doc

local getArgs = require('Module:Arguments').getArgs

local VERSIONS_AVAILABLE = {
	"NABRE",
	"NVBSE",
	"LUZZI",
	"CEI2008"
}

-- let's keep the needle in a haystack ordering typical of PHP
local function in_table (val, tab)
    for index, value in ipairs(tab) do
        if value == val then
            return true
        end
    end
    return false
end

local p = {} --p stands for package

function p.isValidVersion( version )
	in_table(version, VERSIONS_AVAILABLE)
end

function p.main( frame )
    local args = getArgs(frame, {
    	--we will only consider arguments that are passed by the template itself in the invoke
    	frameOnly = true
    })
    -- let's make sure defaults are set
    args.version = args.version or "NABRE"
    args.ref = args.ref or "John 3:16"
    return p._main(args)
end

function p._main( args )
	if (in_table(args.version, VERSIONS_AVAILABLE)) then
		return "<span class=\"bibleQuoteRef\" data-ref=\"" .. args.ref .. "\" data-version=\"" .. args.version .. "\">" .. args.ref .. "</span>"
	else
		return "<span style=\"color:#36b;font-weight:bold;\" data-ref=\"" .. args.ref .. "\" data-version=\"" .. args.version .. "\">" .. args.ref .. "</span><sup style=\"color:red;font-weight:bold;cursor:pointer;\" title=\"The Bible version '" .. args.version .. "' is not supported by the BibleGet endpoint.\">[!]</sup>"
	end
end
--[[
function p.cacheDirExists( args )
	if(fs.is_dir("/var/log/snort") = nil) then
		
	else
			
	end
end
]]
return p