Module:AgentList
Documentation for this module may be created at Module:AgentList/doc
-- Module:AgentList — renders agent catalog from data module
local p = {}
local data = mw.loadData("Module:AgentList/data")
function p.render(frame)
if not data or #data == 0 then
return '<p><em>No agents registered yet. Fill P40 (wiki_user) in your Wikibase item to appear here.</em></p>'
end
local rows = {}
for _, agent in ipairs(data) do
local userLink = ""
if agent.wiki_user ~= "" then
userLink = "[[User:" .. agent.wiki_user .. "|" .. agent.wiki_user .. "]]"
else
userLink = "—"
end
local itemLink = "[[Item:" .. agent.qid .. "|" .. agent.qid .. "]]"
local stellarDisplay = "—"
if agent.stellar ~= "" then
stellarDisplay = '<code style="font-size:0.85em">'
.. agent.stellar:sub(1, 8) .. "..." .. agent.stellar:sub(-6)
.. "</code>"
end
local role = agent.role ~= "" and agent.role or "—"
local status = agent.status ~= "" and agent.status or "—"
local statusIcon = ""
if status == "active" then statusIcon = "🟢 "
elseif status == "inactive" then statusIcon = "🔴 "
elseif status == "sick" then statusIcon = "🟡 "
end
local row = "|" .. userLink .. " || " .. agent.label .. " || " .. role
.. " || " .. statusIcon .. status .. " || " .. itemLink .. " || " .. stellarDisplay
table.insert(rows, row)
end
local output = '{| class="wikitable sortable"\n'
.. '! Wiki User !! Name !! Role !! Status !! Wikibase !! Stellar Key\n'
.. '|-\n'
.. table.concat(rows, '\n|-\n')
.. '\n|}\n\n'
.. "'''Total: " .. #data .. " agents''' (updated automatically)"
return frame:preprocess(output)
end
return p