Content deleted Content added
limit examples to three; handle start and finish for partial lists |
less expensive method (get example info from qualifiers rather than call getEntities on each example |
||
Line 36:
local wikitable = '{| class="wikitable sortable"\n' ..
'|-\n' ..
'! Parameter !! data-sort-type=number style="white-space: nowrap;"|Wikidata ID !! Database !! Examples !! datatype !! formatterURL (or alternative) and examples'
for _, db in pairs( conf.databases ) do
Line 91:
.. '\n|' .. examples
.. '\n|' .. datatype
.. '\n|' .. url ..
end
end
Line 117:
if examplesValue and examplesValue.id then
local exampleID = examplesValue.id
--examples = examples .. '\n*[[:d:' .. exampleID .. '|' .. exampleID ..']]
local label = mw.wikibase.getLabel( exampleID )
examples = examples .. '\n*[[' .. label .. ']] ([[:d:' .. exampleID .. '|' .. exampleID ..']])'
-- get information form qualifiers
if statement.qualifiers then
local qualifiers = statement['qualifiers']
local value = qualifiers['P'..prop][1] --['datavalue']['value']
--mw.addWarning (mw.wikibase.formatValues( qualifiers ))
--mw.addWarning (mw.wikibase.renderSnaks( qualifiers ))
-- mw.addWarning (mw.wikibase.formatValue( value ))
--mw.addWarning ( mw.wikibase.renderSnak( value ))
local id = mw.wikibase.renderSnak( value )
examples = examples .. '<br/>id=<code>' .. id .. '</code>'
local link = formatterURL:gsub('$1', id)
if (datatype == "url") then link = id end
links = links .. '\n*' .. link .. ''
end
--[==[ -- this method is expensive as it calls getEntity
local item = mw.wikibase.getEntity(exampleID)
counter = counter - 1
Line 138 ⟶ 159:
links = links .. '\n*' .. link .. ''
end
]==]
else
examples = examples .. "No example"
|