require('strict')local p = local frame = mw.getCurrentFramelocal config_file = frame.args.config and frame.args.config~= and ('/' .. frame.args.config) or local config = mw.loadData('Module:Authority control/config' .. config_file)local sandbox-- = '/' .. config.i18n.sandboxlocal title = mw.title.getCurrentTitlelocal namespace = title.namespacelocal testcases = title.subpageText
local function needsAttention(sortkey) return '' .. sortkey .. title.text .. ''end
local function addCat(cat, sortkey) if cat and cat ~= and (namespace
14 or testcases) then local category, redlinkcat = , if testcases
false then redlinkcat = needsAttention('N') end category = '' .. sortkey .. title.text end category = category .. '' .. redlinkcat return category else return endend
local getstatement = function(id, propid, qualid) local statement = mw.wikibase.getBestStatements('P' .. id, 'P' .. propid) local value if statement and statement[1] and statement[1].mainsnak.datavalue.value.id then value = statement[1].mainsnak.datavalue.value.id local qual if qualid and statement[1].qualifiers['P' .. qualid][1].datavalue.value then qual = statement[1].qualifiers['P' .. qualid][1].datavalue.value end return value, qual endendlocal getname = function(property) local name for _, propnameqid in ipairs(config.property_items) do name = getstatement(property, propnameqid) if name then break end end if name then return frame:expandTemplate else return endend
-- Creates a human-readable standalone wikitable version of conf, and tracking categories with page counts, for use in the documentationfunction p.docConfTable local doc = local row = function(conf) local example_qid = getstatement(conf.property, 1855) local example = example_qid and frame:expandTemplate or local col1 = mw.html.create('th'):attr('data-sort-value', conf.property) if conf.remark then col1:attr('rowspan','2') end col1:wikitext(frame:expandTemplate) local row = mw.html.create('tr') :node(col1) :tag('td'):wikitext(getname(conf.property)):done :tag('td'):css('text-align', 'center'):wikitext(config.sections[conf.section].name):done :tag('td'):wikitext(example):allDone local remark if conf.remark then remark = mw.html.create('tr'):addClass('expand-child') :tag('td'):attr('colspan', '3') :tag('span'):css('font-weight', 'bold'):wikitext('Remarks:'):done :wikitext(frame:preprocess) :allDone end return row, remark end local header_row = mw.html.create('tr') :tag('th'):attr('data-sort-type', 'number'):wikitext(config.i18n.WDproperty):done :tag('th'):wikitext(lang:ucfirst(config.i18n.identifier)):done :tag('th'):wikitext(config.i18n.Section):done :tag('th'):wikitext(config.i18n.Appears_as):done local doc = mw.html.create('table'):addClass('wikitable sortable'):node(header_row) for _, conf in pairs(config.config) do local row, remark = row(conf) doc:node(row):node(remark) end return tostring(doc)end
function p.whitelisttable local header = mw.html.create('tr') :tag('th'):wikitext(config.i18n.Code):done :tag('th'):wikitext(config.i18n.Topic):done :tag('th'):wikitext(lang:ucfirst(config.i18n.identifiers)):done local Table = mw.html.create('table') :addClass('wikitable'):addClass('sortable') :node(header) for code, wlist in pairs(config.whitelists) do local plist = for _, property in pairs(wlist.properties) do table.insert(plist, frame:expandTemplate) end local row = mw.html.create('tr') :tag('th'):wikitext(code):done :tag('td'):wikitext('' .. mw.wikibase.getSitelink('Q' .. wlist.topic) .. ''):done :tag('td'):wikitext(table.concat(plist,', ')):done Table:node(row) end return tostring(Table)end
function p.sectiontable local header = mw.html.create('tr') :tag('th'):wikitext(config.i18n.Section):done :tag('th'):wikitext(config.i18n.Description):done :tag('th'):wikitext(lang:ucfirst(config.i18n.identifiers)):done local Table = mw.html.create('table') :addClass('wikitable'):addClass('sortable') :node(header) local plist = for n, _ in ipairs(config.sections) do plist[n] = end for _, id in pairs(config.config) do table.insert(plist[id.section], frame:expandTemplate) end for number, section in ipairs(config.sections) do local row = mw.html.create('tr') :tag('th'):wikitext(number):done :tag('td'):wikitext(section.name):done :tag('td'):wikitext(table.concat(plist[number],', ')):done Table:node(row) end return tostring(Table)end
function p.idproposal local property = frame.args.property or local out = '
if section~= then out = out .. config.sections[section].name .. ' (' .. section .. ')' else out = out .. 'Not specified' end out = out .. '
' .. link .. '
' else out = out .. 'Not specified' end out = out .. 'return p