Modulo:FictionTV e Categoria:Chiese di Cagli: differenze tra le pagine

(Differenze fra le pagine)
Contenuto cancellato Contenuto aggiunto
Nuovo modulo
 
FrescoBot (discussione | contributi)
 
Riga 1:
{{interprogetto}}
--[[
* Modulo a supporto del template FictionTV.
]]--
 
[[Categoria:Architetture di Cagli]]
require('Modulo:No globals')
[[Categoria:Chiese della provincia di Pesaro e Urbino|Cagli]]
 
local errorCategory = '[[Categoria:Errori di compilazione del template FictionTV]]'
local p = {}
 
-- Parsifica il parametro annoprimatv
local function parse_annoprimatv(annoprimatv)
local inizio, produzione, fine, err
 
-- annoprimatv senza intervallo, esempio "2010" o "[[2010]]"
inizio = annoprimatv:match('^%[?%[?(%d+)%]?%]?$')
-- altrimenti è un intervallo tipo "[[2010]]-[[2015]]" o "[[2010]] - in produzione"
if not inizio then
inizio = annoprimatv:match('^%[?%[?(%d+)%]?%]?%s*%-')
produzione = annoprimatv:match('produzione$')
fine = annoprimatv:match('^%[?%[?%d+%]?%]?%s*%-%s*%[?%[?(%d+)%]?%]?$')
end
 
-- verifica che inizio e fine siano compresi tra 1880 e 2020
inizio = inizio and tonumber(inizio)
fine = fine and tonumber(fine)
if not inizio or (inizio and (inizio <= 1880 or inizio >= 2030)) or
(fine and not produzione and (fine <= 1880 or fine >= 2030)) then
return nil, nil, nil, true
end
 
return inizio, produzione, fine, err
end
 
-- Funzione per {{#invoke:FictionTV|categorie_anno}}
function p.categorie_anno(frame)
local args, inizio, produzione, fine, err, cat, finecat
 
args = frame.args
inizio, produzione, fine, err = parse_annoprimatv(args.annoprimatv)
 
if args.tipofiction == 'miniserie TV' and inizio then
cat = 'Miniserie televisive del ' .. inizio
elseif args.tipofiction == 'film TV' and inizio then
cat = 'Film per la televisione del ' .. inizio
elseif args.tipofiction == 'serie TV' then
if inizio then
cat = 'Serie televisive iniziate nel ' .. inizio
end
if produzione then
cat = 'Serie televisive in produzione'
elseif fine then
cat = ' Serie televisive terminate nel ' .. fine
end
elseif args.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
 
cat = cat and string.format('[[Categoria:%s]]', cat) or ''
finecat = finecat and string.format('[[Categoria:%s]]', finecat) or ''
 
return cat .. finecat .. (err and errorCategory or '')
end
 
return p