Vorlagenprogrammierung | Diskussionen | Lua | Unterseiten | |||
Modul | Deutsch | English
|
Modul: | Dokumentation |
Diese Seite enthält Code in der Programmiersprache Lua. Einbindungszahl Cirrus
--[=[ Uses Wikidata 2022-06-08
as of en.wikipedia.org
for use in template documentation
* usesProperty show wikiData properties accessed in a template
* tuProperty track and use properties accessed in a template
]=]
local p = {}
local logo = '[[Datei:Wikidata-logo-en.svg|250px]]'
local FSuses = 'https://query.wikidata.org/embed.html#SELECT%20DISTINCT%20%3Fi'
.. 'tem%20%3FitemLabel%20WHERE%20%7B%0A%20%20SERVICE%20wikibase%3A'
.. 'label%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22de%'
.. '22.%20%7D%0A%20%20%7B%0A%20%20%20%20SELECT%20DISTINCT%20%3Fite'
.. 'm%20WHERE%20%7B%0A%20%20%20%20%20%20%3Fitem%20p%3AP527%20%3Fst'
.. 'atement0.%0A%20%20%20%20%20%20%3Fstatement0%20%28ps%3A%s%2F%28'
.. 'wdt%3A%s%2a%29%29%20%3Finstance.%0A%20%20%20%20%7D%0A%20%20%20'
.. '%20LIMIT%20100%0A%20%20%7D%0A%7D'
function p.usesProperty(frame)
local args = frame.getParent(frame).args or nil
if mw.text.trim(args[1] or '') == '' then
args = frame.args
end
local result = '<ul>'
local ii = 1
while true do
local p_num = mw.text.trim(args[ii] or '')
if p_num ~= '' then
local label = mw.wikibase.getLabel(p_num) or "NO LABEL"
result = result .. "<li>[[File:Disc Plain blue dark.svg|middle|4px"
.. "|link=|alt=]] <b><i>[[d:Property talk:"
.. p_num .. "|" .. label .. " ("
.. string.upper(p_num)
.. ")]]</i></b> (see <span class='plainlinks'>[htt"
.. "ps://query.wikidata.org/embed.html#SELECT%20%3"
.. "FWikidata_item_%20%3FWikidata_item_Label%20%3F"
.. "value%20%3FvalueLabel%20%3FEnglish_Wikipedia_a"
.. "rticle%20%23Show%20data%20in%20this%20order%0A"
.. "%7B%0A%09%3FWikidata_item_%20wdt%3A" .. p_num
.. "%20%3Fvalue%20.%20%23Collecting%20all%20items%"
.. "20which%20have%20" .. p_num
.. "%20data%2C%20from%20whole%20Wikidata%20item%20"
.. "pages%0A%09OPTIONAL%20%7B%3FEnglish_Wikipedia_"
.. "article%20schema%3Aabout%20%3FWikidata_item_%3"
.. "B%20schema%3AisPartOf%20%3Chttps%3A%2F%2Fen.wi"
.. "kipedia.org%2F%3E%20.%7D%20%23If%20collected%2"
.. "0item%20has%20link%20to%20English%20Wikipedia%"
.. "2C%20show%20that%0A%09SERVICE%20wikibase%3Alab"
.. "el%20%7B%20bd%3AserviceParam%20wikibase%3Alang"
.. "uage%20%22en%22%20%20%7D%20%23Show%20label%20i"
.. "n%20this%20language.%20%22en%22%20is%20English"
.. ".%20%20%20%0A%7D%0ALIMIT%201000 uses]</span>)<"
.. "/li>"
ii = ii + 1
else break
end
end
result = result.."</ul>"
return result
end
function p.tuProperty(frame)
local parent = frame.getParent(frame)
local result = '<ul>'
local ii = 1
while true do
local p_num = mw.text.trim(parent.args[ii] or '')
if p_num ~= '' then
local label = mw.wikibase.getLabel(p_num) or "NO LABEL"
result = result .. "<li><span style='font-size:90%;line-height:1;'"
.. ">●</span> <b>[[d:Property:"
.. p_num .. "|" .. label .. "]]</b> <span style='f"
.. "ont-size:90%;'>([[d:Property talk:"
.. string.upper(p_num) .. "|" .. p_num .. "]])</sp"
.. "an></li>"
ii = ii + 1
else break
end
end
result = result.."</ul>"
return result
end
return p