Modulo:FictionTV: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
mNessun oggetto della modifica |
m modulo no globals obsoleto |
||
(28 versioni intermedie di 3 utenti non mostrate) | |||
Riga 3:
]]--
require('
local getArgs = require('Modulo:Arguments').getArgs
Riga 9:
local p = {}
-- Parsifica il parametro
local function
local inizio, produzione, fine, err
--
-- fiction trasmesse su più anni, esempio "[[2010]]-[[2015]]" (con o senza wikilink)
▲ inizio = annoprimatv:match('^%[?%[?(%d+)%]?%]?%s*[–-]')
elseif mw.ustring.match(anno, '^%[?%[?%d%d%d%d%]?%]?%s*[–-]%s*%[?%[?%d%d%d%d%]?%]?$') then
produzione = annoprimatv:match('produzione$')▼
inizio, fine =
-- 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)%]?%]?')
end
-- verifica
inizio =
fine =
if not inizio or
(fine
err = true
end
Riga 34 ⟶ 39:
-- 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
-- annoprimatv e tipofiction sono obbligatori▼
if args.
return args['anno prima visione']
inizio, produzione, fine, err = parse_annoprimatv(args.annoprimatv)▼
end▼
if args['anno prima visione'] and args['tipo fiction'] then
▲ inizio, produzione, fine, err =
tipofiction = args['tipo fiction']:lower()
else
err = true
Riga 48 ⟶ 61:
if err then
cat = errorCategory
elseif
-- per le webserie non sono generate categorie
elseif tipofiction == 'miniserie tv' then
cat = 'Miniserie televisive del ' .. inizio
elseif
cat = 'Film per la televisione del ' .. inizio
elseif
if inizio then
cat = 'Serie televisive iniziate nel ' .. inizio
end
if
elseif produzione then▼
finecat = 'Serie televisive in produzione'
elseif fine then
finecat = 'Serie televisive terminate nel ' .. fine
end
elseif
if inizio then
cat = 'Serial televisivi iniziati nel ' .. inizio
end
if
finecat = 'Serial televisivi in produzione'
elseif fine then
Riga 76 ⟶ 87:
end
if mw.title.getCurrentTitle().namespace == 0 or args.debug then
cat = cat and string.format('[[Categoria:%s]]', cat) or ''▼
finecat = finecat and string.format('[[Categoria:%s]]', finecat) or ''▼
end
if finecat then
▲end
end
end
table.insert(ret, string.format('[[%s]]', inizio))
▲ if err then
▲ elseif inizio then
end
if fine and fine ~= inizio then
end
table.insert(ret, produzione)
end
▲ annofine = annofine and string.format('-[[%s]]', annofine) or ''
return args.debug and table.concat(ret):gsub('%[%[Cat(.-)%]%]', '[[:Cat%1]]<br />') or
table.concat(ret)
end
|