Modulo:BibleQuote: differenze tra le versioni

Da Semi del Verbo, l'enciclopedia dell'influenza del Vangelo sulla cultura
Contenuto cancellato Contenuto aggiunto
Creata pagina con " local getArgs = require('Module:Arguments').getArgs local VERSIONS_AVAILABLE = { "NABRE", "NVBSE", "LUZZI", "CEI2008" } -- let's keep the needle in a haystack ordering..."
 
Nessun oggetto della modifica
 
(7 versioni intermedie di uno stesso utente non sono mostrate)
Riga 1: Riga 1:


local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local p = {} --p stands for package


local VERSIONS_AVAILABLE = {
local VERSIONS_AVAILABLE = {
Riga 6: Riga 7:
"NVBSE",
"NVBSE",
"LUZZI",
"LUZZI",
"CEI2008"
"CEI2008",
"DRB",
"VGCL"
}
}


Riga 19: Riga 22:
end
end


local function makeInvokeFunc(funcName)
local p = {} --p stands for package
return function (frame)

local args = getArgs(frame)
function p.isValidVersion( version )
-- let's make sure defaults are set
in_table(version, VERSIONS_AVAILABLE)
if args.version == nil or args.version == "" then
if args.versione ~= nil and args.versione ~= "" then
args.version = args.versione
else
args.version = "CEI2008"
end
end
if args.ref == nil or args.ref == "" then
if args.rif ~= nil and args.rif ~= "" then
args.ref = args.rif
else
args.ref = "Giovanni 3:16"
end
end
if args.inline == nil or args.inline == "" or args.inline == 1 or args.inline == "1" or args.inline == "true" then
args.inline = true
elseif args.inline == 0 or args.inline == "0" or args.inline == "false" then
args.inline = false
end
return p[funcName](args)
end
end
end


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


p.main = makeInvokeFunc("_main")
function p._main( args )
function p._main( args )
if (in_table(args.version, VERSIONS_AVAILABLE)) then
if (in_table(args.version, VERSIONS_AVAILABLE)) then
if args.inline then
return "<span class=\"bibleQuoteRef\" data-ref=\"" .. args.ref .. "\" data-version=\"" .. args.version .. "\">" .. args.ref .. "</span>"
return "<span class=\"bibleQuoteRef\" data-ref=\"" .. args.ref .. "\" data-version=\"" .. args.version .. "\" data-inline=\"true\">" .. args.ref .. "</span>"
else
return "<div class=\"bibleQuoteRef\" data-ref=\"" .. args.ref .. "\" data-version=\"" .. args.version .. "\" data-inline=\"false\"><div class=\"lds-spinner\"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div></div>"
end
else
else
return "<span class=\"bibleQuoteRefBroken\" data-ref=\"" .. args.ref .. "\" data-version=\"" .. args.version .. "\" title=\"The Bible version '" .. args.version .. "' is not supported by the BibleGet endpoint.\">" .. args.ref .. "</span><sup class=\"bibleQuoteRefBrokenReason\" title=\"The Bible version '" .. args.version .. "' is not supported by the BibleGet endpoint.\">[!]</sup>"
return "<span class=\"bibleQuoteRefBroken\" data-ref=\"" .. args.ref .. "\" data-version=\"" .. args.version .. "\" data-inline=\"" .. (args.inline == true and "true" or "false") .. "\" title=\"La versione biblica '" .. args.version .. "' non è supportata dall'API di BibleGet.\">" .. args.ref .. "</span><sup class=\"bibleQuoteRefBrokenReason\" title=\"La versione biblica '" .. args.version .. "' non è supportata dall'API di BibleGet.\">[!]</sup>"
end
end
end
end

--[[
function p.cacheDirExists( args )
if(fs.is_dir("/var/log/snort") = nil) then
else
end
end
]]
return p
return p

Versione attuale delle 10:18, 26 set 2020

La documentazione per questo modulo può essere creata in Modulo:BibleQuote/man

local getArgs = require('Module:Arguments').getArgs
local p = {} --p stands for package

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

-- 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 function makeInvokeFunc(funcName)
	return function (frame)
		local args = getArgs(frame)
	    -- let's make sure defaults are set
	    if args.version == nil or args.version == "" then
	    	if args.versione ~= nil and args.versione ~= "" then
	    		args.version = args.versione
	    	else
	    		args.version = "CEI2008"
	    	end
	    end
	
	    if args.ref == nil or args.ref == "" then
	    	if args.rif ~= nil and args.rif ~= "" then
	    		args.ref = args.rif
	    	else
	    		args.ref = "Giovanni 3:16"
	    	end
	    end
	
	    if args.inline == nil or args.inline == "" or args.inline == 1 or args.inline == "1" or args.inline == "true" then
	    	args.inline = true
	    elseif args.inline == 0 or args.inline == "0" or args.inline == "false" then
	    	args.inline = false
	    end
		return p[funcName](args)
	end
end

p.isValidVersion = makeInvokeFunc("_isValidVersion")
function p._isValidVersion(args)
	if (in_table(args.version, VERSIONS_AVAILABLE)) then
		return 1
	else
		return 0
	end
end

p.main = makeInvokeFunc("_main")
function p._main( args )
	if (in_table(args.version, VERSIONS_AVAILABLE)) then
		if args.inline then
			return "<span class=\"bibleQuoteRef\" data-ref=\"" .. args.ref .. "\" data-version=\"" .. args.version .. "\" data-inline=\"true\">" .. args.ref .. "</span>"
		else
			return "<div class=\"bibleQuoteRef\" data-ref=\"" .. args.ref .. "\" data-version=\"" .. args.version .. "\" data-inline=\"false\"><div class=\"lds-spinner\"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div></div>"
		end
	else
		return "<span class=\"bibleQuoteRefBroken\" data-ref=\"" .. args.ref .. "\" data-version=\"" .. args.version .. "\" data-inline=\"" .. (args.inline == true and "true" or "false") .. "\" title=\"La versione biblica '" .. args.version .. "' non è supportata dall'API di BibleGet.\">" .. args.ref .. "</span><sup class=\"bibleQuoteRefBrokenReason\" title=\"La versione biblica '" .. args.version .. "' non è supportata dall'API di BibleGet.\">[!]</sup>"
	end
end

return p