Module:Calendar date/sandbox: Difference between revisions

Content deleted Content added
citetitle
use require('strict') instead of require('Module:No globals')
 
(3 intermediate revisions by 2 users not shown)
Line 1:
--[[
 
Display Gregorian date of a holiday that moves year to year. Date data can be obtained from multiple sources as configured in Module:Calendar date/Eventsevents
 
"localfile" = local data file (eg. https://en.wikipedia.org/wiki/Template:Calendar_date/localfiles/Hanukkah)
Line 9:
]]
 
require('Module:No globalsstrict')
 
local p = {}
local cfg -- Data structure from ~/Eventsevents
local eventdata -- Data structure from ~/localfiles/<holiday name>
local track = {} -- Tracking category container
Line 341:
 
-- Load configuration file
local eventsfile = mw.loadData ('Module:Calendar date/Eventsevents')
if eventsfile.hebrew_calendar[mw.ustring.upper(holiday)] then
cfg = eventsfile.hebrew_calendar[mw.ustring.upper(holiday)]
Line 348:
elseif eventsfile.carnivals[mw.ustring.upper(holiday)] then
cfg = eventsfile.carnivals[mw.ustring.upper(holiday)]
elseif eventsfile.chinese_events[mw.ustring.upper(holiday)] then
cfg = eventsfile.chinese_events[mw.ustring.upper(holiday)]
elseif eventsfile.misc_events[mw.ustring.upper(holiday)] then
cfg = eventsfile.misc_events[mw.ustring.upper(holiday)]
Line 387 ⟶ 389:
cite = trimArg2(args.cite)
if cite then
if (cite ~= "no") then
cite = ""
if cfg.citeurl and cfg.accessdate and cfg.source and cfg.name then
local citetitle = cfg.citetitle
if local citetitle == nil thencfg.citetitle
if citetitle == 'Dates for ' ..nil cfg.namethen
citetitle = 'Dates for ' .. cfg.name
end
cite = frame:preprocess('<ref name="' .. holiday .. ' dates">{{cite web |url=' .. cfg.citeurl .. ' |title=' .. citetitle .. ' |publisher=' .. cfg.source .. '|accessdate=' .. cfg.accessdate .. '}}</ref>')
elseif cfg.source then
cite = frame:preprocess('<ref name="' .. holiday .. ' dates">' .. cfg.source:gsub("YYYY", date) .. '</ref>')
else
cite = ""
end
cite = frame:preprocess('<ref name="' .. holiday .. ' dates">{{cite web |url=' .. cfg.citeurl .. ' |title=' .. citetitle .. ' |publisher=' .. cfg.source .. '|accessdate=' .. cfg.accessdate .. '}}</ref>')
elseif cfg.source then
cite = frame:preprocess('<ref name="' .. holiday .. ' dates">' .. cfg.source:gsub("YYYY", date) .. '</ref>')
else
cite = ""