„Modul:Uses Wikidata“ – Versionsunterschied
Erscheinungsbild
[gesichtete Version] | [gesichtete Version] |
Inhalt gelöscht Inhalt hinzugefügt
Fork β |
K Fork β, Kosmetik |
||
(14 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 9: | Zeile 9: | ||
local p = {} |
local p = {} |
||
p.LOGO = '[[Datei:Wikidata-logo-en.svg|100px]]' |
|||
--[[ |
--[[ |
||
Zeile 23: | Zeile 23: | ||
args = frame.args |
args = frame.args |
||
end |
end |
||
local result = '<table |
local result = '<table><tr><td style="padding:0">' .. p.LOGO |
||
.. ' |
.. '</td><td>Diese Vorlage greift auf das Datenobjekt zum Arti' |
||
⚫ | |||
.. [[ greift auf das Datenobjekt zum Artikel in WikiData zu. |
|||
⚫ | |||
⚫ | |||
⚫ | |||
for _, v in ipairs(args) do |
for _, v in ipairs(args) do |
||
local p_num = mw.text.trim(v) |
local p_num = mw.text.trim(v) |
||
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 |
result = result .. "<li><i>[[d:" .. p_num .. "|" .. label |
||
.. |
.. " <small>(" .. p_num |
||
.. |
.. ")</small>]]</i> ([[d:Property talk:" .. p_num |
||
.. " |
.. "|Diskussion]], <span class='plainlinks'>[https" |
||
.. " |
.. "://query.wikidata.org/embed.html#SELECT%20DIST" |
||
.. " |
.. "INCT%20%3FObjekt%20%3FObjektLabel%20(group_con" |
||
.. " |
.. "cat(%3FWertLabel%3B%20separator%3D%22%20%2C%20" |
||
.. " |
.. "%22)%20as%20%3F" .. p_num |
||
.. ")%20WHERE%20%7B%0A%20%20SERVICE% |
.. "_Auswahl)%20WHERE%20%7B%0A%20%20SERVICE%20wiki" |
||
.. " |
.. "base%3Alabel%20%7B%20bd%3AserviceParam%20wikib" |
||
.. " |
.. "ase%3Alanguage%20%22de%22.%20%7D%0A%20%20%7B%0" |
||
.. "20%20select%20%3FObjekt%20%3FWertLabel |
.. "A%20%20%20%20select%20%3FObjekt%20%3FWertLabel" |
||
.. "%20%7B%0A%20%20%20%20%20%20%3FObjekt% |
.. "%20where%20%7B%0A%20%20%20%20%20%20%3FObjekt%2" |
||
.. p_num |
.. "0wdt%3A" .. 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" |
||
.. "ase%3Alanguage%20%22de%22.%20%7D%0A%20%20%20%2" |
.. "ase%3Alanguage%20%22de%22.%20%7D%0A%20%20%20%2" |
||
.. "0%7D%20limit%208000%0A%20%20%7D%0A%7D%0Agroup%" |
.. "0%7D%20limit%208000%0A%20%20%7D%0A%7D%0Agroup%" |
||
.. "20by%20%3FObjekt%20%3FObjektLabel |
.. "20by%20%3FObjekt%20%3FObjektLabel%20%0A Beispi" |
||
.. " |
.. "ele]</span>)</li>" |
||
.. "</span>)</li>" |
|||
end |
end |
||
end |
end |
Aktuelle Version vom 5. Oktober 2022, 00:10 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><i>[[d:" .. p_num .. "|" .. label
.. " <small>(" .. p_num
.. ")</small>]]</i> ([[d:Property talk:" .. p_num
.. "|Diskussion]], <span class='plainlinks'>[https"
.. "://query.wikidata.org/embed.html#SELECT%20DIST"
.. "INCT%20%3FObjekt%20%3FObjektLabel%20(group_con"
.. "cat(%3FWertLabel%3B%20separator%3D%22%20%2C%20"
.. "%22)%20as%20%3F" .. p_num
.. "_Auswahl)%20WHERE%20%7B%0A%20%20SERVICE%20wiki"
.. "base%3Alabel%20%7B%20bd%3AserviceParam%20wikib"
.. "ase%3Alanguage%20%22de%22.%20%7D%0A%20%20%7B%0"
.. "A%20%20%20%20select%20%3FObjekt%20%3FWertLabel"
.. "%20where%20%7B%0A%20%20%20%20%20%20%3FObjekt%2"
.. "0wdt%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