Difference between revisions of "Module:Mailing list member"
Jump to navigation
Jump to search
blackwiki>Jackmcbarn (inline htmlerror) |
blackwiki>Jackmcbarn (allow customizing inactive cutoffs) |
||
| Line 5: | Line 5: | ||
function p.main(frame) | function p.main(frame) | ||
local pargs = frame:getParent().args | local pargs = frame:getParent().args | ||
| + | local args = frame.args | ||
local lang = mw.getContentLanguage() | local lang = mw.getContentLanguage() | ||
local page | local page | ||
| Line 24: | Line 25: | ||
if yesno(pargs.inactive, true) then | if yesno(pargs.inactive, true) then | ||
local inactiveTS = tonumber(lang:formatDate('U', pargs.inactive)) | local inactiveTS = tonumber(lang:formatDate('U', pargs.inactive)) | ||
| − | local | + | local minInactive = os.time() - 31556952 |
| − | local | + | local notargetInactive = minInactive |
| + | local maxInactive = minInactive - 31556952 | ||
| + | if args.minInactive then | ||
| + | minInactive = tonumber(lang:formatDate('U', args.minInactive)) | ||
| + | end | ||
| + | if args.notargetInactive then | ||
| + | notargetInactive = tonumber(lang:formatDate('U', args.notargetInactive)) | ||
| + | end | ||
| + | if args.maxInactive then | ||
| + | maxInactive = tonumber(lang:formatDate('U', args.maxInactive)) | ||
| + | end | ||
local retval | local retval | ||
| − | if inactiveTS < | + | if inactiveTS < notargetInactive then |
if pargs.user then | if pargs.user then | ||
retval = frame:expandTemplate{title = 'User', args = { pargs.user }} | retval = frame:expandTemplate{title = 'User', args = { pargs.user }} | ||
| Line 37: | Line 48: | ||
end | end | ||
retval = retval .. ' <span class="inactive-member" style="font-size: 0.95em; font-weight: bold; color: #' | retval = retval .. ' <span class="inactive-member" style="font-size: 0.95em; font-weight: bold; color: #' | ||
| − | if inactiveTS < | + | if inactiveTS < maxInactive then |
retval = retval .. 'F00'; | retval = retval .. 'F00'; | ||
| − | elseif inactiveTS < | + | elseif inactiveTS < minInactive then |
retval = retval .. '555'; | retval = retval .. '555'; | ||
else | else | ||
Revision as of 23:06, 23 February 2014
Template:Template for discussion/dated Implements {{Mailing list member}}
local yesno = require('Module:Yesno')
local p = {}
function p.main(frame)
local pargs = frame:getParent().args
local args = frame.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;">(Blocked since: ' .. lang:formatDate('F Y', pargs.blocked) .. ')</span>'
else
return '<span class="error">No user defined</span>'
end
end
if not page then
return '<span class="error">No user or page defined</span>'
end
if yesno(pargs.inactive, true) then
local inactiveTS = tonumber(lang:formatDate('U', pargs.inactive))
local minInactive = os.time() - 31556952
local notargetInactive = minInactive
local maxInactive = minInactive - 31556952
if args.minInactive then
minInactive = tonumber(lang:formatDate('U', args.minInactive))
end
if args.notargetInactive then
notargetInactive = tonumber(lang:formatDate('U', args.notargetInactive))
end
if args.maxInactive then
maxInactive = tonumber(lang:formatDate('U', args.maxInactive))
end
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 .. ';">(Inactive since: ' .. lang:formatDate('F Y', pargs.inactive) .. ')</span>'
return retval
else
return frame:callParserFunction('#target', page)
end
end
return p