Content deleted Content added
limit examples to three; handle start and finish for partial lists |
use require('strict') instead of require('Module:No globals') |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 1:
require('
local conf = require( "Module:Taxonbar/conf" ) -- configuration module
Line 6:
function p.confdoc( frame )
local wikitable =
wikitable:addClass('wikitable sortable')
:tag('caption')
:wikitext('Taxon identifiers by parameter name')
:done()
:tag('tr')
:tag('th')
:wikitext('Parameter')
:tag('th')
:attr('data-sort-type', 'number')
:css('white-space', 'nowrap')
:wikitext('Wikidata ID')
:tag('th')
:wikitext('Authority')
:tag('th')
:wikitext('Description')
local format = string.format
for _, db in pairs( conf.databases ) do
local param = mw.ustring.lower(db[1])▼
local prop = db[3]
if type(prop) == 'number' and prop > 0 then
▲ local param = mw.ustring.lower(db[1])
row
:tag('td')
:wikitext(param)
:tag('td')
:attr('data-sort-value', prop)
:wikitext(format('[[d:Property:P%d|P%d]]', prop, prop))
-- {{#statements:P1629|from=P{{{1|}}}}}
:tag('td')
:wikitext(frame:callParserFunction{
name = '#statements:P1629',
args = { from = 'P' .. prop }
})
:tag('td')
:wikitext(mw.wikibase.getDescription('P' .. prop))
wikitable:node(row)
end
end
return wikitable
end
--[[ p.wikidataInfo( frame )
Line 36 ⟶ 66:
local wikitable = '{| class="wikitable sortable"\n' ..
'|-\n' ..
'! Parameter !!
for _, db in pairs( conf.databases ) do
Line 91 ⟶ 121:
.. '\n|' .. examples
.. '\n|' .. datatype
.. '\n|' .. url ..
end
end
Line 117 ⟶ 147:
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/><small>id=<code>' .. id .. '</code></small>'
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 ⟶ 189:
links = links .. '\n*' .. link .. ''
end
]==]
else
examples = examples .. "No example"
|