Modul:RelatedSites: Porovnání verzí
Smazaný obsah Přidaný obsah
m fix |
m wikipedia → wiki? změny commons |
||
Řádek 23: | Řádek 23: | ||
link = "" |
link = "" |
||
if entity.sitelinks. |
if entity.sitelinks.cswiki then |
||
cswiki = entity.sitelinks.cswiki.title |
|||
end |
end |
||
if entity.sitelinks.commonswiki then |
if entity.sitelinks.commonswiki then |
||
Řádek 37: | Řádek 37: | ||
-- Wikipedia |
-- Wikipedia |
||
if site == "wikipedia" then |
if site == "wikipedia" then |
||
if |
if cswiki then |
||
link = link .. |
link = link .. cswiki |
||
else return nil |
else return nil |
||
end |
end |
||
Řádek 45: | Řádek 45: | ||
elseif site == "commons" then |
elseif site == "commons" then |
||
if commonswiki then |
if commonswiki then |
||
if |
if string.find(commonswiki,"Category:") then |
||
⚫ | |||
⚫ | |||
link = link .. p935 |
|||
⚫ | |||
else return '' |
|||
end |
|||
⚫ | |||
end |
|||
elseif p935 then |
elseif p935 then |
||
link = link .. p935 |
|||
else return '' |
|||
end |
end |
||
elseif site == "commonscat" then |
elseif site == "commonscat" then |
||
Řádek 61: | Řádek 64: | ||
end |
end |
||
elseif p373 then |
elseif p373 then |
||
link = link .. p373 |
|||
end |
end |
||
Aktuální verze z 24. 6. 2014, 12:25
Dokumentaci tohoto modulu lze vytvořit na stránce Nápověda:Modul:RelatedSites
function link(pid)
if entity == nil then
return nil
elseif entity.claims == nil then
return nil
elseif entity.claims[pid] == nil then
return nil
else
return entity.claims[pid][0].mainsnak.datavalue.value
end
end
local p = {}
function p.link(frame)
entity = mw.wikibase.getEntityObject()
if entity == nil then
return ''
end
p373 = link("p373")
p935 = link("p935")
link = ""
if entity.sitelinks.cswiki then
cswiki = entity.sitelinks.cswiki.title
end
if entity.sitelinks.commonswiki then
commonswiki = entity.sitelinks.commonswiki.title
end
if entity.sitelinks.cswikisource then
cswikisource = entity.sitelinks.cswikisource.title
end
local site = frame.args[1]
-- Wikipedia
if site == "wikipedia" then
if cswiki then
link = link .. cswiki
else return nil
end
-- Wikimedia Commons
elseif site == "commons" then
if commonswiki then
if string.find(commonswiki,"Category:") then
if p935 then
link = link .. p935
else return ''
end
else link = link .. commonswiki
end
elseif p935 then
link = link .. p935
else return ''
end
elseif site == "commonscat" then
if commonswiki then
if string.find(commonswiki,"Category:") then
link = link .. string.sub(commonswiki,10)
elseif p373 then
link = link .. p373
end
elseif p373 then
link = link .. p373
end
-- Wikisource
elseif site == "wikisource" then
if cswikisource then
link = link .. cswikisource
else return nil
end
end
return link
end
return p