Modulo:Sito ufficiale: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
valorizzo il parametro pid per il modulo Modifica su Wikidata
Riga 1:
--[[
* Modulo che implementa il template {{Sito ufficiale.}}
]]--
require('Modulo:No globals')
Riga 11:
local p = {}
 
local function formatWebsite(website, titolo)
return mw.getCurrentFrame():expandTemplate {
title = 'Cita web',
args = {
url = website.url,
titolo = 'Sito ufficiale'titolo,
lingua = table.concat(website.langs, ' ')
}
Riga 22:
end
 
--[[
local function getWebsites()
* @param int pid Wikidata Property ID
]]
local function getWebsites(pid)
local claims
local websites = {}
 
claims = mWikidata._getClaims('P856'pid) or {}
for idx, claim in ipairs(claims) do
local langs = mWikidata._formatQualifiers(claim, 'P407', { formatting = 'raw' }, true)
Riga 42 ⟶ 45:
end
 
--[[
-- * Entry-point per il template {{Sito ufficiale}}
]]
function p.main(frame)
frame.args.pid = frame.args and frame.args.pid or 'P856'
local websites = getWebsites()
frame.args.pidtitle = frame.args and frame.args.title or 'P856Sito ufficiale'
 
local websites = getWebsites(frame.args.pid)
for idx, website in ipairs(websites) do
-- P856 è di tipo "valore singolo", aggiunge l'elenco puntato solo per le eccezioni
websites[idx] = (idx > 1 and '*' or '') .. formatWebsite(website, frame.args.title) .. mEditAtWikidata(frame)
end
return #websites > 0 and