Content deleted Content added
No edit summary |
No edit summary |
||
Line 189:
]]
function renderHoli(
local hits = 0
Line 197:
-- user-supplied date calculator
if
if jsoncfg.main.event[it].datasource then
enddate = dateOffset(startdate, json.days - 1)
else ▼
else
return inlineError("holiday", 'Invalid calculator result' )
-- Get first and last date of holiday ▼
end
-- read dates from jsonlocal.items -- it assumes dates in the json are in chrono order, needs a more flexible method
for i = 1, numRecords do
if mw.ustring.find(
if hits == 0 then
startdate =
hits = 1
end
if hits >= tonumber(
enddate = json.items[i].date
break
end
Line 223 ⟶ 225:
-- Verify data is OK
if startdate == nil or enddate == nil then
if
enddate = dateOffset(startdate, 8)
else
Line 231 ⟶ 233:
-- Generate start-date offset (ie. holiday starts the evening before the given date)
if
startdate = dateOffset(startdate,
if startdate ~= enddate then
enddate = dateOffset(enddate,
else
if
end
end
Line 243 ⟶ 245:
-- Generate end-date outside-Irael offset (ie. outside Israel the holiday ends +1 day later)
if
endoutoffset = dateOffset(enddate,
end
Line 274 ⟶ 276:
-- return output
if startdate == enddate or
return
else
return
end
Line 295 ⟶ 297:
if cfg.main.event[i].datatype:lower() == "calculator" then
return "calculator", i
elseif cfg.main.event[i].datatype:lower() == "
return "
else
return nil, nil
Line 355 ⟶ 357:
return inlineError("holiday", 'File missing: Template:' .. tname .. '/Configuration.js', tname) .. createTracking()
end
local jsoncfg,
jsoncfg = mw.text.jsonDecode( cfgfp:getContent() )
if not jsoncfg then
Line 365 ⟶ 367:
return inlineError("holiday", 'Template:' .. tname .. '/Configuration.js misconfigured: missing datasource', tname) .. createTracking()
end
if isAvail == "
local version = mw.title.makeTitle( jsoncfg.main.event[it].datasource )
if not version.exists then
Line 371 ⟶ 373:
end
if version.isRedirect then
else
end
elseif isAvail == "calculator" then -- dates are calculated with a user-provided calculator
Line 404 ⟶ 406:
if cite then
cite = ""
if isAvail == "
if jsoncfg.main.event[it].citeurl and jsoncfg.main.event[it].accessdate and jsoncfg.main.event[it].source and jsoncfg.main.event[it].holiday then
cite = frame:preprocess('<ref name="' .. holiday .. ' dates">{{cite web |url=' .. jsoncfg.main.event[it].citeurl .. ' |title=Dates for ' .. jsoncfg.main.event[it].holiday .. ' |publisher=' .. jsoncfg.main.event[it].source .. ' |via=[[Template:' .. tname .. '|' .. tname .. ']] and [[Template:' .. tname .. '/holidays/' .. holiday .. '.js|' .. holiday .. '.js]] |accessdate=' .. jsoncfg.main.event[it].accessdate .. '}}</ref>')
Line 428 ⟶ 430:
-- Render
local rend = renderHoli( isAvail,it,jsoncfg,
if not rend then
rend = '<span style="font-size:100%" class="error citation-comment">Error in [[:Template:' .. tname .. ']]: Unknown problem. Please report on template talk page.</span>'
|