Modulo:Sito ufficiale/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m commenti
m title, valori di default
Riga 8:
local p = {}
 
local function formatWebsite(website, title)
return mw.getCurrentFrame():expandTemplate {
title = 'Cita web',
args = {
url = website.url,
titolo = title or 'Sito ufficiale',
lingua = table.concat(website.langs, ' ')
}
Riga 19:
end
 
local function getWebsites(framepid)
local claims
local websites = {}
 
claims = mWikidata._getClaims(frame.args.pid) or {}
for idx, claim in ipairs(claims) do
local langs = mWikidata._formatQualifiers(claim, 'P407', { formatting = 'raw' }, true)
Riga 41:
-- Funzione per i template {{Sito ufficiale}} e {{Blog ufficiale}}
function p.main(frame)
local websites = getWebsites(frame.args.pid or 'P856')
for idx, website in ipairs(websites) do
-- P856 e P1581 sono di tipo "valore singolo", aggiunge l'elenco puntato solo per le eccezioni
websites[idx] = (idx > 1 and '*' or '') .. formatWebsite(website, frame.args.title or 'Sito ufficiale')
end
return #websites > 0 and table.concat(websites, '\n') or ''