پودمان:Mailing list member
ظاهر
local yesno = require('Module:Yesno')
local pageCutoffs = {
['Wikipedia:WikiProject Articles for creation/Participants/Message'] = { '-1 year', '-1 year', '-2 years' },
['Template:Mailing list member/testcases'] = { '-1 year', '-18 months', '-2 years' }
}
local defaultCutoffs = { '-1 year', '-1 year', '-2 years' }
local p = {}
local function maybeLink(text, target)
return target and ('[[' .. target .. '|' .. text .. ']]') or text
end
function p.main(frame)
local pargs = frame:getParent().args
local lang = mw.getContentLanguage()
local page
if pargs.user then
page = 'User talk:' .. pargs.user
else
page = pargs.page
end
if yesno(pargs.blocked) then
if pargs.user then
return frame:expandTemplate{title = 'Userblocked', args = { pargs.user }} .. ' <span class="blocked-member" style="font-size: 0.95em; font-weight: bold; color: #E33;">(مسدودشده از: ' .. lang:formatDate('F Y', pargs.blocked) .. ')</span>'
else
return '<span class="error">هیچ کاربری تعریف نشده است</span>'
end
end
if not page then
return '<span class="error">هیچ کاربر یا صفحهای تعریف نشده است</span>'
end
if yesno(pargs.inactive, true) then
local cutoffs = pageCutoffs[mw.title.getCurrentTitle().prefixedText] or defaultCutoffs
local inactiveTS = tonumber(lang:formatDate('U', pargs.inactive))
local minInactive = tonumber(lang:formatDate('U', cutoffs[1]))
local notargetInactive = tonumber(lang:formatDate('U', cutoffs[2]))
local maxInactive = tonumber(lang:formatDate('U', cutoffs[3]))
local retval
if inactiveTS < notargetInactive then
if pargs.user then
retval = frame:expandTemplate{title = 'User', args = { pargs.user }}
else
retval = '[[' .. page .. ']]'
end
else
retval = frame:callParserFunction('#target', page)
end
retval = retval .. ' <span class="inactive-member" style="font-size: 0.95em; font-weight: bold; color: #'
if inactiveTS < maxInactive then
retval = retval .. 'F00';
elseif inactiveTS < minInactive then
retval = retval .. '555';
else
retval = retval .. '080';
end
retval = retval .. ';">(غیر فعال شده از: ' .. maybeLink(lang:formatDate('F Y', pargs.inactive), notargetInactive < inactiveTS and pargs.user and ('Special:Contributions/' .. pargs.user)) .. ')</span>'
return retval
else
return frame:callParserFunction('#target', page)
end
end
return p