Modulo:StagioniTV/sandbox: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
m c1 |
mNessun oggetto della modifica |
||
Riga 29:
if not args[1] or args.titolo then
if string.find(mw.title.getCurrentTitle().text, '^Episodi d[ei]') then
localID = wikidata._getProperty({ 'P361', n = 1, from = mw.wikibase.getEntityIdForCurrentPage(), formatting = 'raw' })
localID2 = wikidata._getProperty({ 'P179', n = 1, from = mw.wikibase.getEntityIdForCurrentPage(), formatting = 'raw' })
end
id = localID
id = localID2
else
end
Riga 43 ⟶ 44:
-- ed estrae gli altri dati fondamentali da Wikidata (etichetta in italiano, numero stagioni, sitelink)
-- se uno di essi non è presente è generato un messaggio di errore
if wikidata._instanceOf({ 'Q581714', from = id }) then
tipo = 'animata' elseif wikidata._instanceOf({ 'Q5398426', from = id }) then
tipo = 'serie TV' else
tipo = 'programma' end
if id then
else
end
-- Questa parte del codice genere i collegamenti alle singole edizioni/stagioni e la relativa categoria
if not etichetta or not sitelink or not stagioni then
else
---- per rendere l'uso del template più leggero prova a estrarre il nome del programma e la preposizione usata nei link direttamente
---- dalle voci in cui è usato, altrimenti verifica l'esistenza della voce della prima stagione con la sintassi standard
if args[2] ~= 'elenco' and string.find(mw.title.getCurrentTitle().text, '^.+%(%a+edizione%)$') then
nome = string.match(mw.title.getCurrentTitle().text, '^(.+) %(%a+edizione%)$')
preposizione = mw.title.new(string.format('Categoria:Edizioni de %s', nome)).exists and 'de' or 'di'
elseif mw.title.new(string.format('%s (prima edizione)', etichetta)).exists then
nome = etichetta
preposizione = mw.title.new(string.format('Categoria:Edizioni de %s', etichetta)).exists and 'de' or 'di'
else
nome = sitelink
preposizione = mw.title.new(string.format('Categoria:Edizioni de %s', sitelink)).exists and 'de' or 'di'
end
if args[2] ~= 'elenco' and string.find(mw.title.getCurrentTitle().text, '^Episodi d[ei] ') then
if string.find(mw.title.getCurrentTitle().text, '^Episodi d[ei].+stagione%)$') then
nome = string.match(mw.title.getCurrentTitle().text, '^Episodi d[ei] (.+) %(%a+ stagione%)$')
preposizione = string.match(mw.title.getCurrentTitle().text, '^Episodi (d[ei])')
elseif string.find(mw.title.getCurrentTitle().text, '^Episodi d[ei].+$') then
nome = string.match(mw.title.getCurrentTitle().text, '^Episodi d[ei] (.+)$')
preposizione = string.match(mw.title.getCurrentTitle().text, '^Episodi (d[ei])')
end▼
elseif mw.title.new(string.format('Episodi di %s (prima stagione)', etichetta)).exists then▼
nome = etichetta▼
preposizione = 'di'▼
elseif mw.title.new(string.format('Episodi de %s (prima stagione)', etichetta)).exists then▼
nome = etichetta▼
preposizione = 'de'▼
preposizione = mw.title.new(string.format('Episodi de %s (prima stagione)', sitelink)).exists and 'de' or 'di'▼
end
▲ elseif mw.title.new(string.format('Episodi di %s (prima stagione)', etichetta)).exists then
▲ nome = etichetta
▲ preposizione = 'di'
▲ elseif mw.title.new(string.format('Episodi de %s (prima stagione)', etichetta)).exists then
▲ nome = etichetta
▲ preposizione = 'de'
▲ else nome = sitelink
▲ preposizione = mw.title.new(string.format('Episodi de %s (prima stagione)', sitelink)).exists and 'de' or 'di'
end
end▼
---- qui vengono generati i link alle stagioni/edizioni e la categoria appropriata
local ordinaleF = ordinalefemminile(i)
if tipo == 'programma' then
target = string.format('%s (%s edizione)', nome, ordinaleF)
else target = string.format('Episodi %s %s (%s stagione)', preposizione, nome, ordinaleF)
if tipo == 'programma' then▼
else
stagioneoedizione = 'stagione'▼
end▼
local label = args.formato == 'numeri romani' and mNumeroRomano.main({ i }) or (args.formato == 'forma breve' and string.format('%dª', i) or string.format('%s %s', lang:ucfirst(ordinaleF), stagioneoedizione))
table.insert(tbl, string.format('[[%s|%s]]', target, label))▼
if (target == mw.title.getCurrentTitle().text and mw.title.getCurrentTitle().namespace == 0) or (mw.title.getCurrentTitle().text == string.format('Episodi %s %s', preposizione, nome) and mw.title.getCurrentTitle().namespace == 0) or args.debugcat then
if stagioni == '1' or stagioni == '1±0' then▼
if tipo == 'programma' then
elseif tipo == 'animata' then
else
end
elseif tipo == 'programma' then
else
end
end
▲ if tipo == 'programma' then
▲ stagioneoedizione = 'edizione' else
▲ stagioneoedizione = 'stagione'
end
▲ table.insert(tbl, string.format('[[%s|%s]]', target, label))
▲ if stagioni == '1' or stagioni == '1±0' then
▲ if tipo == 'programma' then categoria = string.format('[[Categoria:Edizioni di programmi televisivi|%s]]', nome)
▲ elseif tipo == 'animata' then categoria = string.format('[[Categoria:Liste di episodi di serie animate|%s]]', nome)
▲ else categoria = string.format('[[Categoria:Liste di episodi di serie televisive|%s]]', nome)
▲ end
▲ elseif tipo == 'programma' then categoria = string.format('[[Categoria:Edizioni %s %s|%02d]]', preposizione, nome, i)
▲ else categoria = string.format('[[Categoria:Stagioni %s %s|%02d]]', preposizione, nome, i)
▲ end
▲ end
▲ end
▲ local catsp
▲ if mw.title.getCurrentTitle().text == string.format('Episodi speciali %s %s', preposizione, nome) then
▲ catsp = string.format('[[Categoria:Stagioni %s %s|Episodi speciali]]', preposizione, nome)
end
▲ links = mw.text.listToText(tbl, sep, sep) .. (speciali or '') .. (categoria or '')
-- Infine è generato il navbox con i dati su estratti e formattati
---- con sfondo del titolo del template diverso a seconda del tipo di programma
if tipo == 'animata' then
sfondo = 'background:#ab110c;' elseif tipo == 'serie TV' then
sfondo = 'background:#206600;' elseif tipo == 'programma' then
sfondo = 'background:#2e2eff;' end
---- evitando il corsivo per il titolo del template se il titolo della serie usa caratteri speciali/non latini
local titolotemplate, charval, len, pos
if etichetta ~= nil then
while ( pos <= len ) do
charval = mw.ustring.codepoint(mw.ustring.sub(etichetta, pos))
if charval>=370 and charval<2000 then
titolotemplate = string.format("[[%s|<span style=\"color:white;\">%s</span>]]", sitelink, etichetta)
elseif charval>=2100 and charval~=8364 then
titolotemplate = string.format("[[%s|<span style=\"color:white;\">%s</span>]]", sitelink, etichetta)
else
titolotemplate = string.format("[[%s|<span style=\"color:white;\">''%s''</span>]]", sitelink, etichetta)
end
pos = pos + 1;
Riga 162 ⟶ 187:
if not id or not etichetta or not stagioni then
template = mw.title.getCurrentTitle().namespace == 0 and errorCategory or nil
elseif args[2] == 'elenco' then
template = links elseif stagioni == '1' or stagioni == '1±0' then
template = categoria else
template = navbox._navbox({ name = 'Stagioni televisive',
title = titolotemplate,
|