Modul:Commonscat: Porovnání verzí
Smazaný obsah Přidaný obsah
m v RelatedSites je zdá se nějaký problém, takže takto |
m ještě jednou "Category:" |
||
(Není zobrazena jedna mezilehlá verze od stejného uživatele.) | |||
Řádek 7: | Řádek 7: | ||
local link, show |
local link, show |
||
if params[1] and params[1] ~= '' then |
if params[1] and params[1] ~= '' then |
||
link = params[1] |
link = 'Category:' .. params[1] |
||
else |
else |
||
link = Wikidata. |
link = Wikidata.getSitelink({ args = { site = 'commonswiki' } }) or '' |
||
if link == '' then |
if link == '' or not string.find(link,"Category:") then |
||
link = Wikidata.formatStatementsFromLua({ property = 'P373', limit = 1 }) or '' |
|||
⚫ | |||
if link == '' then |
|||
⚫ | |||
else |
|||
link = 'Category:' .. link |
|||
end |
|||
end |
end |
||
end |
end |
||
Řádek 28: | Řádek 33: | ||
output = output .. "<span class=\"sisterproject_image\">[[Soubor:Commons-logo.svg|16x16px|alt=Logo Wikimedia Commons|link=Wikimedia Commons]]</span> " |
output = output .. "<span class=\"sisterproject_image\">[[Soubor:Commons-logo.svg|16x16px|alt=Logo Wikimedia Commons|link=Wikimedia Commons]]</span> " |
||
output = output .. "<span class=\"sisterproject_text\">Obrázky, zvuky či videa k tématu " |
output = output .. "<span class=\"sisterproject_text\">Obrázky, zvuky či videa k tématu " |
||
output = output .. "<span class=\"sisterproject_text_target\">[[c |
output = output .. "<span class=\"sisterproject_text_target\">[[c:" .. link .. "|" .. show .. "]] </span> " |
||
output = output .. "ve [[Wikimedia Commons]]</span>" |
output = output .. "ve [[Wikimedia Commons]]</span>" |
||
output = output .. "</span>" |
output = output .. "</span>" |
Verze z 17. 2. 2015, 17:18
function makeFormat(frame)
local parent = frame:getParent()
local params = parent and parent.args or {}
local pagename = mw.title.getCurrentTitle().text
local lang = mw.getContentLanguage()
local Wikidata = require 'Modul:Wikidata'
local link, show
if params[1] and params[1] ~= '' then
link = 'Category:' .. params[1]
else
link = Wikidata.getSitelink({ args = { site = 'commonswiki' } }) or ''
if link == '' or not string.find(link,"Category:") then
link = Wikidata.formatStatementsFromLua({ property = 'P373', limit = 1 }) or ''
if link == '' then
link = 'Category:' .. pagename
else
link = 'Category:' .. link
end
end
end
if params[2] and params[2] ~= '' then
show = params[2]
elseif params['lokální'] and params['lokální'] ~= '' then
show = pagename
else
show = Wikidata.getLabel({ args = { lang = lang } }) or ''
if show == '' then show = pagename end
end
local output = ""
output = output .. "<span class=\"sisterproject sisterproject-commons\">"
output = output .. "<span class=\"sisterproject_image\">[[Soubor:Commons-logo.svg|16x16px|alt=Logo Wikimedia Commons|link=Wikimedia Commons]]</span> "
output = output .. "<span class=\"sisterproject_text\">Obrázky, zvuky či videa k tématu "
output = output .. "<span class=\"sisterproject_text_target\">[[c:" .. link .. "|" .. show .. "]] </span> "
output = output .. "ve [[Wikimedia Commons]]</span>"
output = output .. "</span>"
-- output = frame:preprocess( output )
return output
end
local p = {}
function p.print(frame)
return makeFormat(frame)
end
return p