Module:Authority control/documentation and Module:Authority control/documentation/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
Attempt to prevent crash |
use label if no link |
||
Line 4: | Line 4: | ||
local config_file = frame.args.config and frame.args.config~='' and ('/' .. frame.args.config) or '' |
local 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 config = mw.loadData('Module:Authority control/config' .. config_file) |
||
local sandbox |
local sandbox = '/' .. config.i18n.sandbox |
||
local title = mw.title.getCurrentTitle() |
local title = mw.title.getCurrentTitle() |
||
local namespace = title.namespace |
local namespace = title.namespace |
||
Line 35: | Line 35: | ||
local statement = mw.wikibase.getBestStatements('P' .. id, 'P' .. propid) |
local statement = mw.wikibase.getBestStatements('P' .. id, 'P' .. propid) |
||
local value |
local value |
||
if statement and statement[1] |
if statement and statement[1] and statement[1].mainsnak.datavalue.value.id then |
||
value = statement[1].mainsnak.datavalue.value.id |
value = statement[1].mainsnak.datavalue.value.id |
||
local qual |
local qual |
||
Line 72: | Line 72: | ||
)} |
)} |
||
} or '' |
} or '' |
||
local col1 = mw.html.create('th'):attr('data-sort-value', conf.property) |
local col1 = mw.html.create('th') |
||
:attr('data-sort-value', conf.property) |
|||
:attr('rowspan',conf.remark and '2' or '1') |
|||
:wikitext(frame:expandTemplate{ |
|||
col1:attr('rowspan','2') |
|||
title = 'Wikidata property link', |
|||
⚫ | |||
args = {conf.property} |
|||
}) |
|||
local col2 = mw.html.create('td') |
|||
⚫ | |||
local col3 = mw.html.create('td') |
|||
:css('text-align', 'center') |
|||
⚫ | |||
local col4 = mw.html.create('td') |
|||
⚫ | |||
local row = mw.html.create('tr') |
local row = mw.html.create('tr') |
||
:node(col1) |
:node(col1) |
||
:node(col2) |
|||
⚫ | |||
:node(col4) |
|||
⚫ | |||
:node(col4) |
|||
⚫ | |||
local remark |
local remark |
||
if conf.remark then |
if conf.remark then |
||
local cell = mw.html.create('td') |
|||
:attr('colspan', '3') |
|||
:tag('span'):css('font-weight', 'bold'):wikitext('ℹ️ '):done() |
|||
:wikitext(frame:preprocess{text = conf.remark}) |
|||
remark = mw.html.create('tr') |
|||
:allDone() |
|||
:addClass('expand-child') |
|||
:node(cell) |
|||
end |
end |
||
return row, remark |
return row, remark |
||
Line 118: | Line 129: | ||
table.insert(plist, frame:expandTemplate{title='Wikidata property link', args={'P' .. property}}) |
table.insert(plist, frame:expandTemplate{title='Wikidata property link', args={'P' .. property}}) |
||
end |
end |
||
local link = wlist.topic and mw.wikibase.getSitelink('Q' .. wlist.topic) |
|||
and '[[' .. mw.wikibase.getSitelink('Q' .. wlist.topic) .. ']]' |
|||
or mw.wikibase.getLabel('Q' .. wlist.topic) |
|||
local row = mw.html.create('tr') |
local row = mw.html.create('tr') |
||
:tag('th'):wikitext(code):done() |
:tag('th'):wikitext(code):done() |
||
:tag('td'):wikitext( |
:tag('td'):wikitext(link):done() |
||
:tag('td'):wikitext(table.concat(plist,', ')):done() |
:tag('td'):wikitext(table.concat(plist,', ')):done() |
||
Table:node(row) |
Table:node(row) |
||
Line 194: | Line 208: | ||
out = out .. '</li></ul>' |
out = out .. '</li></ul>' |
||
return out |
return out |
||
⚫ | |||
p.listproperties = function() |
|||
local tab = {} |
|||
for _, conf in pairs(config.config) do |
|||
table.insert(tab, conf.property) |
|||
end |
|||
return table.concat(tab, ', ') |
|||
end |
end |
||