Modulo:FictionTV
Questo è un modulo scritto in Lua. Le istruzioni che seguono sono contenute nella sottopagina Modulo:FictionTV/man (modifica · cronologia)
Sandbox: Modulo:FictionTV/sandbox (modifica · cronologia) · Sottopagine: lista · Test: Modulo:FictionTV/test (modifica · cronologia · esegui)
Modulo a supporto del template {{FictionTV}}, per gestirne le funzioni di categorizzazione automatica per anno.
--[[
* Modulo a supporto del template FictionTV.
]]--
require('strict')
local getArgs = require('Modulo:Arguments').getArgs
local errorCategory = 'Errori di compilazione del template FictionTV'
local p = {}
-- Parsifica il parametro anno prima visione
local function annoprimavisione(anno)
local inizio, produzione, fine, err
-- fiction trasmesse in un solo anno, esempio "[[2010]]" (con o senza wikilink)
if anno:match('^%[?%[?%d%d%d%d%]?%]?$') then
inizio = anno:match('^%[?%[?(%d%d%d%d)%]?%]?$')
fine = inizio
-- fiction trasmesse su più anni, esempio "[[2010]]-[[2015]]" (con o senza wikilink)
elseif mw.ustring.match(anno, '^%[?%[?%d%d%d%d%]?%]?%s*[–-]%s*%[?%[?%d%d%d%d%]?%]?$') then
inizio, fine = mw.ustring.match(anno, '^%[?%[?(%d%d%d%d)%]?%]?%s*[–-]%s*%[?%[?(%d%d%d%d)%]?%]?$')
-- fiction in corso "[[2010]] - in produzione/corso" (con o senza wikilink)
elseif mw.ustring.match(anno, '^%[?%[?%d%d%d%d%]?%]?%s*[–-]%s*in produzione$') or
mw.ustring.match(anno, '^%[?%[?%d%d%d%d%]?%]?%s*[–-]%s*in corso$') then
inizio = anno:match('^%[?%[?(%d%d%d%d)%]?%]?')
produzione = ' – in produzione'
end
-- verifica l'anno di debutto sia rilevato e gli anni di inizio e fine siano compresi tra 1900 e 2050
inizio = tonumber(inizio)
fine = tonumber(fine)
if not inizio or inizio <= 1900 or inizio >= 2050 or
(fine and (fine <= 1900 or fine >= 2050)) then
err = true
end
return inizio, produzione, fine, err
end
-- Funzione per {{#invoke:FictionTV|categorie_anno}}
-- Restituisce un formato standard per il parametro anno prima visione e le categorie
function p.categorie_anno(frame)
local args, inizio, produzione, fine, tipofiction, err, cat, finecat
local ret = {}
args = getArgs(frame)
-- con il parametro nocatperanno restituisce direttamente anno prima visione
if args.nocatperanno == 'sì' then
return args['anno prima visione']
end
-- anno prima visione e tipo fiction sono obbligatori
if args['anno prima visione'] and args['tipo fiction'] then
inizio, produzione, fine, err = annoprimavisione(args['anno prima visione'])
tipofiction = args['tipo fiction']:lower()
else
err = true
end
if err then
cat = errorCategory
elseif tipofiction == 'webserie' then
-- per le webserie non sono generate categorie
elseif tipofiction == 'miniserie tv' then
cat = 'Miniserie televisive del ' .. inizio
elseif tipofiction == 'film tv' then
cat = 'Film per la televisione del ' .. inizio
elseif tipofiction == 'serie tv' then
if inizio then
cat = 'Serie televisive iniziate nel ' .. inizio
end
if produzione then
finecat = 'Serie televisive in produzione'
elseif fine then
finecat = 'Serie televisive terminate nel ' .. fine
end
elseif tipofiction == 'serial tv' then
if inizio then
cat = 'Serial televisivi iniziati nel ' .. inizio
end
if produzione then
finecat = 'Serial televisivi in produzione'
elseif fine then
finecat = 'Serial televisivi terminati nel ' .. fine
end
end
if mw.title.getCurrentTitle().namespace == 0 or args.debug then
if cat then
table.insert(ret, string.format('[[Categoria:%s]]', cat))
end
if finecat then
table.insert(ret, string.format('[[Categoria:%s]]', finecat))
end
end
if inizio then
table.insert(ret, string.format('[[%s]]', inizio))
end
if fine and fine ~= inizio then
table.insert(ret, string.format('-[[%s]]', fine))
end
if produzione then
table.insert(ret, produzione)
end
return args.debug and table.concat(ret):gsub('%[%[Cat(.-)%]%]', '[[:Cat%1]]<br />') or
table.concat(ret)
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.