Modulo:StagioniTV/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
prove tecniche di trasmissione
 
Nessun oggetto della modifica
Riga 2:
 
local wikidata = require('Modulo:Wikidata')
local navbox = require('Modulo:Navbox')
local mNumeroRomano = require('Modulo:Numero romano')
local getArgs = require('Modulo:Arguments').getArgs
local errorCategory = '[[Categoria:Errori di compilazione del template Stagioni televisive]]'
local p = {}
 
local function p.data(args)
local id, tipo, titolo, etichetta, sitelink, stagioni
id = wikidata.getId(args[1])
if wikidata._instanceOf({ 'Q581714', from = id }) == true then tipo = 'animata'
elseif wikidata._instanceOf({ 'Q5398426', from = id }) == true then tipo = 'serie TV'
else tipo = 'programma'
end
titolo = wikidata._getLink({ id })
stagionietichetta = wikidata._getProperty_getLabel({ id, 'P2437it', n = 1, from = entityId })
sitelink = mw.wikibase.sitelink( id )
stagioni = wikidata._getProperty({ 'P2437', n = 1, from = id })
return id, tipo, titolo, etichetta, sitelink, stagioni
end
 
local function ordinalefemminile(num)
return mw.getCurrentFrame():expandTemplate {
title = 'Ordinale femminile',
args = { num }
}
end
 
function p.prova(args)
local template, sfondo, categoria, target, stagioneoedizione, title, preposizione
local id, tipo, titolo, etichetta, sitelink, stagioni = data(args)
local tbl = {}
local lang = mw.language.getContentLanguage()
local sep = args.debug and '<br />' or '&nbsp;<b>&middot;</b>&#32;'
if tipo == 'animata' then sfondo = 'background:#ab110c;'
elseif tipo == 'serie TV' then sfondo = 'background:#115806;'
elseif tipo == 'programma' then sfondo = 'background:#161e8e;'
end
if tipo == 'programma' then
title = mw.title.new(string.format('Categoria:Edizioni de %s', etichetta))
preposizione = (title and title.exists) and 'de' or 'di'
else title = mw.title.new(string.format('Episodi de %s (prima stagione)', etichetta))
preposizione = (title and title.exists) and 'de' or 'di'
end
for i = 1, stagioni do
local ordinaleF = ordinalefemminile(i)
if tipo == 'programma' then
target = string.format('%s (%s edizione)', etichetta, ordinaleF) else
target = string.format('Episodi %s %s (%s stagione)', preposizione, etichetta, ordinaleF)
end
if tipo == 'programma' then stagioneoedizione = 'edizione' 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 then
if stagioni > 1 then
if tipo == 'programma' then
categoria = string.format('[[Categoria:Edizioni %s %s|%02d]]', preposizione, etichetta, i) else
categoria = string.format('[[Categoria:Stagioni %s %s|%02d]]', preposizione, etichetta, i)
end
elseif stagioni == 1 then
if tipo == 'programma' then
categoria = string.format('[[Categoria:Edizioni di programmi televisivi|%s]]', etichetta) else
categoria = string.format('[[Categoria:Liste di episodi di serie televisive|%s]]', etichetta)
end
end
end
end
local links = mw.text.listToText(tbl, sep, sep) .. (categoria or '')
if not id or not tipo or not stagioni then
template = mw.title.getCurrentTitle().namespace == 0 and errorCategory or nil
-- elseif elenco == 'ok' or args.lista == 'xx' then
-- template = links
else
template = navbox._navbox({
name = 'Stagioni televisive',
title = string.format("[[%s|<span style=\"color:white;\">''%s''</span>]]", sitelink, etichetta),
titlestyle = sfondo,
list1 = links
})
end
 
return template
end
 
 
return p