Module:Logos: Difference between revisions

From TwogPedia
(Created page with "local getArgs = require('Module:Arguments').getArgs local Logos = {} function Logos.main(frame) local args = getArgs(frame) local enteredLogos = {} local currentDate = os.date('%Y-%m-%d') for key, value in ipairs (args) do local values = mw.text.jsonDecode(value) if (values.start == nil or values.start < currentDate) and (values['end'] == nil or values['end'] > currentDate) then enteredLogos['all'] = values.logoAll enteredLogos['light'] = values.logoLigh...")
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
 
VariablesLua = mw.ext.VariablesLua
local Logos = {}
local Logos = {}


Line 8: Line 8:


local currentDate = os.date('%Y-%m-%d')
local currentDate = os.date('%Y-%m-%d')
for key, value in ipairs (args) do
 
local values = mw.text.jsonDecode(value)
if (args.start == nil or args.start < currentDate) and (args['end'] == nil or args['end'] > currentDate) then
if (values.start == nil or values.start < currentDate) and (values['end'] == nil or values['end'] > currentDate) then
if args.logoAll then VariablesLua.vardefine( 'logoAll', args.logoAll ) end
enteredLogos['all'] = values.logoAll
if args.logoLight then VariablesLua.vardefine( 'logoLight', args.logoLight ) end
enteredLogos['light'] = values.logoLight
if args.logoDark then VariablesLua.vardefine( 'logoDark', args.logoDark ) end
enteredLogos['dark'] = values.logoDark
end
end
end
return mw.text.jsonEncode(enteredLogos)
 
return 'yes'
end
end


return Logos
return Logos

Latest revision as of 19:22, 5 May 2023

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

local getArgs = require('Module:Arguments').getArgs
VariablesLua = mw.ext.VariablesLua
local Logos = {}

function Logos.main(frame)
	local args = getArgs(frame)
	local enteredLogos = {}

	local currentDate = os.date('%Y-%m-%d')

	if (args.start == nil or args.start < currentDate) and (args['end'] == nil or args['end'] > currentDate) then
		if args.logoAll then VariablesLua.vardefine( 'logoAll', args.logoAll ) end
		if args.logoLight then VariablesLua.vardefine( 'logoLight', args.logoLight ) end
		if args.logoDark then VariablesLua.vardefine( 'logoDark', args.logoDark ) end
	end

	return 'yes'
end

return Logos