Module:BotTasks
Jump to navigation
Jump to search
Documentation for this module may be created at Module:BotTasks/doc
Code
local p = {}
function linkifyProperties(text)
local frame = mw.getCurrentFrame()
text = text:gsub('P[0-9]+', function(match)
return frame:expandTemplate{title='P', args={match}}
end)
return text
end
function p.main (frame, debugArgs)
local args = debugArgs or frame.args
local tasks = mw.text.jsonDecode( args[1] )
local tbl = mw.html.create('table'):attr('class', 'wikitable')
local tr = tbl:tag('tr')
tr:tag('th'):wikitext('Space'):attr('rowspan', 2)
tr:tag('th'):wikitext('Description'):attr('rowspan', 2)
tr:tag('th'):wikitext('Properties involved in the edit'):attr('colspan', 3)
local tr = tbl:tag('tr')
tr:tag('th'):wikitext('Main statement')
tr:tag('th'):wikitext('Qualifier')
tr:tag('th'):wikitext('Reference')
for _, task in pairs(tasks) do
local tr = tbl:tag('tr')
tr:tag('td'):wikitext(mw.text.nowiki(task.space))
tr:tag('td'):wikitext(linkifyProperties(mw.text.nowiki(task.description)))
if task.fingerprint then
tr:tag('td'):wikitext('This task edits labels, descriptions and/or aliases.'):attr('colspan', 3)
elseif task.sitelinks then
tr:tag('td'):wikitext('This task adds or removes sitelinks.'):attr('colspan', 3)
elseif task.sitelink_badges then
tr:tag('td'):wikitext('This task edits sitelink badges.'):attr('colspan', 3)
elseif task.properties then
tr:tag('td'):wikitext(linkifyProperties(table.concat(task.properties.mainStatement or {}, ', ')))
tr:tag('td'):wikitext(linkifyProperties(table.concat(task.properties.qualifier or {}, ', ')))
tr:tag('td'):wikitext(linkifyProperties(table.concat(task.properties.reference or {}, ', ')))
end
end
return tostring(tbl)
end
return p