Modul:TFA title
Videz
![]() | Ta modul je odvisen od zaščite strani. Je zelo viden modul, ki ga uporabljajo številne strani, ali pa je pogosto substituiran. Ker bi vandalizem ali napake vplivale na številne strani in bi lahko celo trivialno urejanje povzročilo veliko obremenitev strežnikov, je zaščiten pred urejanjem. |
Lua wrapper around the data in Predloga:TFA title/data.json, primarily to be used in Predloga:Editnotices/Namespace/Main.
Usage
[uredi kodo]{{#invoke:TFA title|is_todays_tfa|{{PAGENAME}}}}
, returns yes
if it is the TFA, and nothing if it is not.
Zgornja dokumentacija je vključena iz Modul:TFA title/dok. (uredi | zgodovina) Urejevalci lahko preizkušate ta modul v peskovniku (ustvari | mirror) in testnihprimerih (ustvari). Prosimo, da dodate kategorije v /dok podstran. Podstrani te predloge. |
local p = {}
local data = mw.loadJsonData("Predloga:TFA title/data.json")
-- Internal, today's date as YYYY-MM-DD
local function today()
return os.date("%Y-%m")
end
-- Get the TFA title for the specified "YYYY-MM-DD" date. May be
-- a single title, an array of multiple titles, or nil, if no title is known
function p.title(date)
return data.titles[date] or nil
end
-- Today's TFA, see title() for possible return values
function p.today_title()
return p.title(today())
end
-- Is the specified title the TFA today?
-- Returns "yes" or "", for use with {{#if:}}
function p.is_todays_tfa(frame)
return p.is_tfa_on(frame.args[1], today())
end
-- Is the specified title the TFA on the specified date?
-- Returns "yes" or "", for use with {{#if:}}
function p.is_tfa_on(title, date)
local days_title = p.title(date)
if days_title == nil then
-- no clue
return ""
end
if type(days_title) == "string" then
if title == days_title then
return "yes"
else
return ""
end
end
-- table case, multiple titles
for _, check in pairs( days_title ) do
if check == title then
return "yes"
end
end
return ""
end
return p