Modulo:Wl
Aspetto
La documentazione per questo modulo può essere creata in Modulo:Wl/man
local p = {}
local c = require('Modulo:Common')
function p.ld(frame)
local parent = frame:getParent()
local qid = parent.args[1]
local text = parent.args[2]
-- local item = mw.wikibase.getEntity(qid)
local label = mw.wikibase.label(qid) or ''
local desc = mw.wikibase.description(qid)
local ns = c.getNamespace()
-- c.setItem(item)
linkWs = mw.wikibase.sitelink(qid)
-- wpLang, linkWp = c.wikipedia()
linkWp= mw.wikibase.sitelink(qid, "itwiki") -- leggo direttamente il link a itwikiopedia
link = text or ''
cat = ''
if linkWs then
link = '[['..linkWs..'|'..text..']]'
if c.startsWith(linkWs, 'Autore:') then
name = linkWs:gsub('Autore:', '')
if ns == '' then
cat = c.category('Testi in cui è citato '..name, name, false)
elseif ns == 'Pagina' then
cat = c.category('Pagine in cui è citato '..name, name, false)
elseif ns == 'Indice' then
cat = c.category('Indici in cui è citato '..name, name, false)
end
end
elseif linkWp then
-- link = '[[:w:'..wpLang..':'..linkWp..'|'..text..']]'
link = '[[:w:'..linkWp..'|'..text..']]'
cat = '[[Categoria:Pagine con link a Wikipedia]]'
if parent.args[3] and parent.args[3]=="autore" then
if ns == '' then
cat = c.category('Testi in cui è citato '..linkWp, linkWp, false)
elseif ns == 'Pagina' then
cat = c.category('Pagine in cui è citato '..linkWp, linkWp, false)
elseif ns == 'Indice' then
cat = c.category('Indici in cui è citato '..linkWp, linkWp, false)
end
end
else
link='[[d:'..qid..'|'..text..']]'
cat=''
end
local span = '<span class="wl" title="'..label
if desc then
span = span..', '..desc
end
span = span..' ('..qid..')">'..link..'</span>'
return span..cat
end
return p