Modulo:Citazione: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Moroboshi (discussione | contributi)
Moroboshi (discussione | contributi)
correzioni alla funzione per generare il formato
Riga 15:
Caricamente delle tabelle di configurazione del modulo.
===============================================================================]]
local cfg = mw.loadData( 'Modulo:Citazione/Configurazione' );
 
--[[ ===============================================================================
Riga 857:
 
return new_list;
end
 
--[[ ===============================================================================
Genera la tringa pe ril formato, se format non è definita tenta di ricavarlo dall'url
===============================================================================]]
local function get_format(format, url)
 
local try_format = format
if not is_set(Formattry_format) then
local try_format = mw.ustring.match( (is_set(ChapterURL) and ChapterURL) or URLurl, "^.*%.(.+)$" ) or ''
if cfg.external_link_type[try_format:lower()] then
Format =return try_format
else
try_format = mw.ustring.match(try_format, "^(.+)#.+$") or ''
local if f =not cfg.external_link_type[Formattry_format:lower()] then
try_format = ''
end
end
end
 
-- Se il formato esterno è tra quelli previsti imita lo stile dei template {{PDF}} o {{doc}}
if is_set(try_format) then
local f = cfg.external_link_type[try_format:lower()]
if f then
Format =return mw.ustring.format(' (<span style="font-weight: bolder; font-size:80%%"><abbr title="%s">%s</abbr></span>)', f.text, f.label)
else
table.insert( z.message_tail, { set_error('unknown_format', Formattry_format, true) } );
Format =return mw.ustring.format(' (%s)', Formattry_format)
end
end
return ''
end
 
Riga 1 235 ⟶ 1 266:
end
 
-- genera la stringa per il formato
-- Se il formato file non è specificato, prova a ricavarlo dalla fine dell'URL
ifFormat = get_format(Format, (is_set(URL) orand is_set(ChapterURL)URL) andor notChapterURL is_set(Format) then
local try_format = mw.ustring.match( (is_set(ChapterURL) and ChapterURL) or URL, "^.*%.(.+)$" ) or ''
if cfg.external_link_type[try_format:lower()] then
Format = try_format
end
end
 
-- Se il formato esterno è tra quelli previsti imita lo stile dei template {{PDF}} o {{doc}}
if is_set(Format) then
local f = cfg.external_link_type[Format:lower()]
if f then
Format = mw.ustring.format(' (<span style="font-weight: bolder; font-size:80%%"><abbr title="%s">%s</abbr></span>)', f.text, f.label)
else
table.insert( z.message_tail, { set_error('unknown_format', Format, true) } );
Format = mw.ustring.format(' (%s)', Format)
end
else
Format = ""
end
 
-- In maniera predefinita l'URL non è dichiarato morto
Riga 1 710 ⟶ 1 723:
rows[#rows+1] = "|}"
return table.concat(rows, '\n')
end
 
-- per formati esterni da altri template
function z.format(frame)
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(frame, {frameOnly = true})
return get_format(args[1])
end