Modulo:Commons
Etoso
Dokumentado por ĉi tiu modulo povas esti kreata ĉe Modulo:Commons/dokumentado
local p = {}
function p.print(frame)
local parent = frame:getParent()
local params = parent and parent.args or {}
local title = mw.title.getCurrentTitle()
local pagename = title.text
local namespace = title.namespace
local link, show, cats = '', '', ''
local Wikidata = require 'Modulo:Wikidata2'
local sitelink = Wikidata.getSitelinkFromLua{ site = 'commonswiki' }
local property = Wikidata.getRawValueFromLua{ property = 'P935' }
if params[1] and params[1] ~= '' then
link = params[1]
if (namespace == 0 or namespace == 14) and not property then
cats = cats .. '[[Kategorio:Komuneja kategorio ne estas en Vikidatumoj|' .. pagename .. ']]'
end
-- local Check = require 'Modulo:WikidataCheck'
-- cats = cats .. Check.wikidatacheck({ args =
-- { value = link, category = 'Commons', property = 'P935', namespaces = '0,14' }
-- }) or ''
else
link = property -- preferigu econ
if not link then
link = sitelink -- eco ne estas, provu ligilon el Vikidatumoj
if not link or mw.ustring.find(link, "Category:") then
link = pagename -- aŭ titolon de paĝo
end
end
end
-- se alirebla, komparu la econ kaj ligilon
if (
sitelink and not mw.ustring.find(sitelink, 'Category:')
and property and sitelink ~= property
) then
cats = cats .. '[[Kategorio:Komuneja kategorio kun loka ligilo malsama kiel en Vikidatumoj|' .. pagename .. ']]'
end
if params[2] and params[2] ~= '' then
show = params[2] -- bildigu lokan valoron
elseif namespace ~= 0 then
show = pagename
else
show = Wikidata.getLabel() -- aŭ etikedon
if not show or show == '' then
show = pagename -- aŭ titolon de paĝo
cats = cats .. '[[Kategorio:Artikoloj sen etikedon en Vikidatumoj|' .. pagename .. ']]'
end
end
local output = ""
output = output .. "<span class=\"sisterproject sisterproject-commons\">"
output = output .. "<span class=\"sisterproject_image\">[[Dosiero:Commons-logo.svg|16x16px|alt=Logo Wikimedia Commons|link=Vikimedia Komunejo]]</span> "
output = output .. "<span class=\"sisterproject_text\">Fotogalerio pri "
output = output .. "<span class=\"sisterproject_text_target\">[[c:" .. link .. "|" .. show .. "]]</span>"
output = output .. " en la [[Vikimedia Komunejo]]</span>"
output = output .. "</span>" .. cats
output = frame:preprocess(output)
return output
end
return p