„Modul:Uses Wikidata“ – Versionsunterschied
Erscheinungsbild
[gesichtete Version] | [gesichtete Version] |
Inhalt gelöscht Inhalt hinzugefügt
K having count 'raus |
Fork β |
||
Zeile 31: | Zeile 31: | ||
if p_num ~= '' then |
if p_num ~= '' then |
||
local label = mw.wikibase.getLabel(p_num) or "NO LABEL" |
local label = mw.wikibase.getLabel(p_num) or "NO LABEL" |
||
result = result .. "<li><b><i>[[d: |
result = result .. "<li><b><i>[[d:" .. p_num .. "|" .. label |
||
.. |
.. "<small>" .. p_num .. "</small>([[d:Property ta" |
||
.. |
.. "lk:" .. p_num .. "|Diskussion)]]</i></b> (Sieh" |
||
.. " |
.. "e <span class='plainlinks'>[https://query.wiki" |
||
.. " |
.. "data.org/embed.html#SELECT%20DISTINCT%20%3FObj" |
||
.. " |
.. "ekt%20%3FObjektLabel%20(group_concat(%3FWertLa" |
||
.. " |
.. "bel%3B%20separator%3D%22%20%2C%20%22)%20as%20%" |
||
.. " |
.. "3F" .. p_num .. "_Auswahl)%20WHERE%20%7B%0A%20" |
||
.. " |
.. "%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3Aser" |
||
.. " |
.. "viceParam%20wikibase%3Alanguage%20%22de%22.%20" |
||
.. " |
.. "%7D%0A%20%20%7B%0A%20%20%20%20select%20%3FObje" |
||
.. "20% |
.. "kt%20%3FWertLabel%20where%20%7B%0A%20%20%20%20" |
||
.. " |
.. "%20%20%3FObjekt%20wdt%3A" .. p_num |
||
.. p_num |
|||
.. "%20%3FWert.%0A%20%20%20%20%20%20SERVICE%20wiki" |
.. "%20%3FWert.%0A%20%20%20%20%20%20SERVICE%20wiki" |
||
.. "base%3Alabel%20%7B%20bd%3AserviceParam%20wikib" |
.. "base%3Alabel%20%7B%20bd%3AserviceParam%20wikib" |
Version vom 4. Oktober 2022, 23:56 Uhr
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 = {}
p.LOGO = '[[Datei:Wikidata-logo-en.svg|100px]]'
--[[
Uses Wikidata|usesProperty|<P...>|<P...>|
displays Wikidata logo and listed properies
parameters:
unnamed*: property number, e. g. "P123", one proprty per parameter
returns: box with logo and some information followed by a list of properties
]]
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 = '<table><tr><td style="padding:0">' .. p.LOGO
.. '</td><td>Diese Vorlage greift auf das Datenobjekt zum Arti'
.. 'kel in WikiData zu. Sie berücksichtigt dabei nachfolgend a'
.. 'ufgeführte Eigenschaftswerte.</td></tr></table><ul>'
for _, v in ipairs(args) do
local p_num = mw.text.trim(v)
if p_num ~= '' then
local label = mw.wikibase.getLabel(p_num) or "NO LABEL"
result = result .. "<li><b><i>[[d:" .. p_num .. "|" .. label
.. "<small>" .. p_num .. "</small>([[d:Property ta"
.. "lk:" .. p_num .. "|Diskussion)]]</i></b> (Sieh"
.. "e <span class='plainlinks'>[https://query.wiki"
.. "data.org/embed.html#SELECT%20DISTINCT%20%3FObj"
.. "ekt%20%3FObjektLabel%20(group_concat(%3FWertLa"
.. "bel%3B%20separator%3D%22%20%2C%20%22)%20as%20%"
.. "3F" .. p_num .. "_Auswahl)%20WHERE%20%7B%0A%20"
.. "%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3Aser"
.. "viceParam%20wikibase%3Alanguage%20%22de%22.%20"
.. "%7D%0A%20%20%7B%0A%20%20%20%20select%20%3FObje"
.. "kt%20%3FWertLabel%20where%20%7B%0A%20%20%20%20"
.. "%20%20%3FObjekt%20wdt%3A" .. p_num
.. "%20%3FWert.%0A%20%20%20%20%20%20SERVICE%20wiki"
.. "base%3Alabel%20%7B%20bd%3AserviceParam%20wikib"
.. "ase%3Alanguage%20%22de%22.%20%7D%0A%20%20%20%2"
.. "0%7D%20limit%208000%0A%20%20%7D%0A%7D%0Agroup%"
.. "20by%20%3FObjekt%20%3FObjektLabel%20%0A Beispi"
.. "ele]</span>)</li>"
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