Modulo:CategoriaMusicale: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
←Nuova pagina: local p = {} local subject2infobox = { ['Gruppi musicali'] = 'Artista musicale', ['Musicisti'] = 'Artista musicale', ['Cantanti'] = 'Artista musicale', ['Disc jock... |
grassetto standard |
||
(10 versioni intermedie di un altro utente non mostrate) | |||
Riga 1:
local p = {}
['Gruppi musicali'] = 'Artista musicale',▼
local subject2wikilink = {
['
['
['Cantanti'] = '[[Cantante|cantanti]]',
['Disc jockey'] = '[[disc jockey]]',
['EP'] = '[[Extended play|EP]]',
['
['
['
}
function p.categoriamusicale(frame)▼
questa funzione è chiamata sia da p.main che dal template,
tramite il codice {{#invoke:CategoriaMusicale|get_subject}}
function p.get_subject()
local title = mw.title.getCurrentTitle().text
for k, v in pairs(subject2wikilink) do
if title:sub(1,string.len(k))==k then
return k
end
end
return nil
end
--[[
questa è la funzione principale che genera il wikicodice per il template,
da invocare con il codice {{#invoke:CategoriaMusicale|main|genere|link_genere}}
]]
local args = frame.args
local
local
local subject = p.get_subject()
▲ -- verifica quali delle chiavi della tabella subject2wikilink
local text = ""
▲ -- è presente all'inizio del titolo della categoria
text = "Questa categoria raggruppa voci su '''" .. subject2wikilink[subject] .. " [["
if forced_link ~= "" then text = text .. forced_link .. "|" end
text = text .. genre .. "]]'''.\n\n"
end
text = text .. "Categorie correlate:\n<div class=\"colonne_strette\">"
if subject == "Gruppi musicali" or subject == "Musicisti" or subject == "Cantanti" or subject == "Disc jockey" then
text = text .. string.format("\n* [[:Categoria:%s per nazionalità|%s per nazionalità]]", subject, subject)
end
if subject then
text = text .. string.format("\n* [[:Categoria:%s per genere|%s per genere (tutti)]]", subject, subject)
end
-- aggiungi link alle categorie correlate se diverse da quella attuale
for k, v in pairs(subject2wikilink) do
if
text = text .. string.format("\n* [[:Categoria:%s %s|%s %s]]", k, genre, k, genre)
▲ subject = k
end
end
text = text .. "</div>"
return text
▲ --[[
▲ ]]
end
|