require('strict')
local p =
local startYear = 2005local endYearlocal prefix = "Wikipedia:Wikipedia Signpost/Archives/"
p.list = function(frame) -- Get current year frame = frame or mw.getCurrentFrame local lang = mw.language.new("en") local currentYear = lang:formatDate("Y") -- Get end year (this year if the page exists, otherwise last year) local currentYearTitle = mw.title.new(prefix .. currentYear) if currentYearTitle.exists then endYear = tonumber(currentYear) else endYear = tonumber(currentYear) - 1 end -- Create a table of links local links = local year = startYear while year <= endYear do table.insert(links, ""..year.."") year = year + 1 end -- Format as wikitext local wikitext = table.concat(links, "") -- return after pre-processing return frame:preprocess(wikitext)end
return p