Module:WikianLine
Documentation for this module may be created at Module:WikianLine/doc
local yn = require('Module:Yesno')
local hc = require('Module:Paramtest').has_content
local var = mw.ext.VariablesLua
local lang = mw.getContentLanguage()
local p = {}
require('Module:Mw.html extension')
local na = {
['na'] = true,
['n/a'] = true
}
local check = {
[true] = 'Yes check',
[false] = 'X mark'
}
function _fdate(d)
return lang:formatDate('U', d), lang:formatDate('Y-m-d H:i', d)
end
function fdate(d)
local fd_good, fd_val1, fd_val2 = pcall(_fdate, d)
if fd_good then
return fd_val1, fd_val2
end
return 0, d
end
function p.main(frame)
return p._main(frame:getParent().args)
end
function p._main(args)
local user = args[1] or 'example'
local rsnames = args[2] or ''
local discussion = args.discussion
--date the discussin closed & user qualified for wikian title
local qualified = args.qualified or ''
local qualified_sort = 0
local granted = yn(args.granted or '', false)
local ret = mw.html.create('tr')
rsnames = rsnames:gsub('[;,] *', ', ') --ensure clean format
if hc(qualified) then
qualified_sort, qualified = fdate(qualified)
end
-- 1st + 2nd param = user and rsnames
ret
:tag('td')
:wikitext(string.format('[[User:%s|%s]]', user, user))
:done()
:tag('td')
:wikitext(rsnames)
:done()
-- discussion
:tag('td')
:IF(na[string.lower(discussion or '')])
:addClass('table-na')
:wikitext('N/A')
:ELSE()
:wikitext(string.format('[[RuneScape:The Wikian/%s|Discussion]]', hc(discussion) and discussion or user))
:END()
:done()
-- qualified
:tag('td')
:attr('data-sort-value', qualified_sort)
:IF(qualified == '')
:addClass('table-na')
:wikitext('N/A')
:ELSE()
:wikitext(qualified)
:END()
:done()
-- granted
:tag('td')
:wikitext(string.format('[[File:%s.svg|20px|link=]]', check[granted]))
:done()
var.vardefine('total_wiki_accounts', tonumber(var.var('total_wiki_accounts', 0))+1 )
if granted then
if hc(rsnames) then
rsaccs = #mw.text.split(rsnames, ',')
var.vardefine('total_rs_accounts', tonumber(var.var('total_rs_accounts', 0))+rsaccs )
end
else
var.vardefine('total_unclaimed', tonumber(var.var('total_unclaimed', 0))+1 )
end
return ret
end
return p