Մոդուլ:ԱշբոտԱրխիվ
Documentation for this module may be created at Մոդուլ:ԱշբոտԱրխիվ/doc
local p = {}
local lang = mw.language.getContentLanguage()
local currentYear = tonumber( lang:formatDate( 'Y' ) )
local function checkPageExists( title )
if not title then
error('No title passed to checkArchiveExists', 2)
end
local noError, titleObject = pcall(mw.title.new, title)
if not noError then
-- If we are over the expensive function limit then assume
-- that the page doesn't exist.
return false
else
if titleObject then
return titleObject.exists
else
return false -- Return false if given a bad title.
end
end
end
local function yearCheck( archive )
result = ''
year = 2005
while year <= currentYear do
title = string.gsub( archive, "%%%(year%)d", year)
if checkPageExists( title ) then
result = result .. '* [[' .. title .. '|' .. year .. ']]\n'
end
year = year + 1
end
return result .. ''
end
function p.main( frame )
local args = frame:getParent().args
if string.match( args['archive'], "%%%(year%)d" ) ~= nil then
local prefix = frame:expandTemplate{ title = 'Սյուն', args = {colwidth = '10em'}} .. '\n'
local sufix = '\n' .. frame:expandTemplate{ title = 'Սյուն ավարտ'}
return prefix .. yearCheck(args['archive']) .. sufix
else
-- TODO
return ''
end
end
return p