Module:Person table
Jump to navigation
Jump to search
Module documentation
This documentation is transcluded from Module:Person table/doc. [edit] [history] [purge]
Module:Person table's function main is invoked by Template:Person table.
Module:Person table requires Module:Clean image.
Module:Person table requires Module:Mw.html extension.
Module:Person table requires Module:Tables.
| Function list |
|---|
| L 27 — linkProjects L 41 — includes L 56 — p.main |
local tables = require('Module:Tables')
local cleanimg = require('Module:Clean image').clean
require('Module:Mw.html extension')
local lang = mw.getContentLanguage()
local p = {}
local project_map = {
ummo = { link = 'Unannounced MMO', cat = 'Unannounced MMO employees' },
chronicle = { link = '<i>[[Chronicle: RuneScape Legends]]</i>', cat = 'Chronicle employees' },
rs = { link = '<i>[[RuneScape]]</i>', cat = 'RuneScape employees' },
osrs = { link = '<i>[[Old School RuneScape]]</i>', cat = 'Old School RuneScape employees' },
mobile = { link = '<i>[[RuneScape Mobile]]</i>', cat = 'RuneScape Mobile employees' },
tu = { link = '<i>[[Jagex#Transformers Universe|Transformers Universe]]</i>', cat = 'Transformers Universe employees' },
sd = { link = '<i>[[Jagex#MechScape and Stellar Dawn|Stellar Dawn]]</i>', cat = 'Stellar Dawn employees' },
bnl = { link = '<i>[[Jagex#Block N Load|Block N Load]]</i>', cat = 'Block N Load employees' },
wol = { link = '<i>[[Jagex#War of Legends|War of Legends]]</i>', cat = 'War of Legends employees' },
fo = { link = '<i>[[Jagex#FunOrb|FunOrb]]</i>', cat = 'FunOrb employees' },
vh = { link = '<i>Void Hunters</i>', cat = 'Void Hunters employees' },
er = { link = '<i>8Realms</i>', cat = '8Realms employees' },
ia = { link = '<i>[[RuneScape Idle Adventures|RuneScape: Idle Adventures]]</i>', cat = 'RuneScape Idle Adventures employees' },
ht = { link = '<i>[[Jagex#Herotopia|Herotopia]]</i>', cat = 'Herotopia employees' },
dw = { link = '<i>[[RuneScape - Dragonwilds|RuneScape: Dragonwilds]]</i>', cat = 'RuneScape: Dragonwilds employees' };
-- primarily for Mod North
corporate = { link = 'Corporate' }
}
function linkProjects(projs)
projs = mw.text.split(projs, ',')
local out = {}
for i,v in ipairs(projs) do
v = mw.text.trim(v)
if project_map[v] then
table.insert(out, project_map[v].link)
else
table.insert(out, lang:ucfirst(v))
end
end
return table.concat(out, '<br>')
end
function includes(a,b)
if a == nil or b == nil then
return false
end
if type(a) == 'string' then
a = mw.text.split(a, ',')
end
for i,v in ipairs(a) do
if mw.text.trim(v) == b then
return true
end
end
return false
end
function p.main(frame)
local args = frame:getParent().args
local jagex = (args.jagex or ''):lower()
local current = (args.current or ''):lower()
local currentonly = current == 'yes'
local former = (args.former or ''):lower()
local formeronly = former == 'yes'
local team = (args.team or '')
local project = (args.project or '')
local hasproject = project ~= ''
local collapsed = (args.collapsed or 'no'):lower() == 'yes'
local b = bucket('infobox_person')
.select('page_name', 'json')
.where('Category:People')
if jagex == 'yes' then
b.where('Category:Jagex employees')
if currentonly then
b.where('Category:Current Jagex employees')
end
if isformer then
b.where('Category:Former Jagex employees')
end
if team ~= '' then
b.where('Category:'..team)
end
end
local data = b.run()
local ret = mw.html.create('table')
:addClass('wikitable sticky-header sortable autosort=2,a mw-collapsible')
:addClassIf(collapsed, 'mw-collapsed')
local header = {
"Picture",
"Name",
"Role",
"Employment",
"Project"
}
tables._row(ret:tag('tr'), header, true)
for _, line in ipairs(data) do
local page = line.page_name
line = mw.text.jsonDecode(line.json)
mw.logObject(line)
local doline = true
if hasproject then
doline = includes(line.project, project)
end
if currentonly then
doline = doline and (line.left == nil or select(2, line.left:gsub(",", "")) < select(2, (line.employed or ''):gsub(",", "")))
elseif formeronly then
doline = doline and (line.left ~= nil and select(2, line.left:gsub(",", "")) >= select(2, (line.employed or ''):gsub(",", "")))
end
if doline then
local image = cleanimg{file = line.image, width = 60}
local row = {
image,
'[['..page..']]',
line.role or '',
line.employment_dates or '',
linkProjects(line.project or '')
}
tables._row(ret:tag('tr'), row, false)
end
end
return ret
end
return p