Modulo:Citazione: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Ripristino alla versione 92770056 datata 2017-11-25 12:49:00 di Sakretsu tramite popup
m riapplico modifica di Moroboshi
Riga 30:
 
-- Ritorna il nostro {{Collegamento interrotto}}
local function interrupted_url( frame )
return framemw.getCurrentFrame():expandTemplate{ title = 'Collegamento interrotto' }
end
 
Riga 133:
-- -- arguments: una lista di argomenti opzionali per la formattazione del messaggio
-- -- raw: ritorna una coppia: {messaggio di errore, visibilità} invece del messaggio
-- di errore formattato
-- -- prefix: stringa da aggiungere in testa al messaggio
-- -- suffix: stringa da aggiungere in coda al messaggio
Riga 292:
- self.first_priority: priorità del separatore di apertura
- self.sep_key: codice del carattere separatore di default da usare
se unita a un altro frammento
===============================================================================]]
local Fragment = {}
 
Fragment.priorityprecedence = {}cfg.style.separator_priority
local Fragment_mt = { __index = Fragment }
 
Fragment.new = function(texts, sep_key)
if type(texts) == "string" then texts = { texts } end
if not fpriorityFragment.precedence[sep_key] then sep_key = "" end
local fpriority = Fragment.priority
if not fpriority[sep_key] then sep_key = "" end
local separator = fpriority[sep_key]
local tx = { }
tx.last_priority = 0
Riga 312 ⟶ 310:
if el ~= "" then
tx[#tx+1] = el
tx[#tx+1] = fpriorityFragment.precedence[tx.sep_key].sep
end
end
if #tx > 1 then
tx.last_priority = fpriorityFragment.precedence[tx.sep_key].order
else
tx[1] = ""
Riga 327 ⟶ 325:
function Fragment:start(sep_key)
if #self == 0 then return self end
local separator = Fragment.priorityprecedence[sep_key] or Fragment.priorityprecedence[""]
self[1] = separator.sep
self.first_priority = separator.order
Riga 336 ⟶ 334:
function Fragment:last(sep_key)
if #self == 0 then return self end
local separator = Fragment.priorityprecedence[sep_key] or Fragment.priorityprecedence[""]
self[#self] = separator.sep
self.last_priority = separator.order
Riga 884 ⟶ 882:
Genera la citazione
===============================================================================]]
local function citation0( config, args, frame )
local A = argument_wrapper( args );
local i
Riga 892 ⟶ 890:
local PPPrefix = (is_set( A['NoPP'] ) and "") or Style.ppprefix
local PPrefix = (is_set( A['NoPP'] ) and "") or Style.pprefix
Fragment.priority = Style.separator_priority
-- Pick out the relevant fields from the arguments. Different citation templates
-- define different field names for the same underlying things.
Riga 937 ⟶ 934:
 
local isPubblicazione = (config.CitationClass == 'pubblicazione') or
(config.CitationClass=='testo' and is_set(Periodical))
 
------------------------------------------------------------------------------
Riga 988 ⟶ 985:
elseif check_error > 60 then
TimeError[#TimeError+1] = set_error('minutes_wrong')
end
ComposeTime[#ComposeTime+1] = Minutes .. ' min'
end
Riga 1 399 ⟶ 1 396:
Language_code = Language
else
local frameframe_lingue = {return_error='true', usacodice='sì'}
for lingua in mw.ustring.gmatch(Language, "%S+") do
frameframe_lingue[#frameframe_lingue+1] = lingua
end
if #frameframe_lingue > 1 or (#frameframe_lingue==1 and frameframe_lingue[1]:lower()~="it") then
local lg_error
localLanguage_code, lglg_error = require( "Modulo:Linguaggi" );.lingue(frame_lingue)
Language_code, lg_error = lg.lingue(frame)
if lg_error and #lg_error > 0 then
local error_string = mw.text.listToText(lg_error, ", ", " e " )
Riga 1 519 ⟶ 1 515:
 
local fragment_Title
local PostTitle = A['PostTitle']
if is_set(Title) then
 
if DeadURL and not is_set( ArchiveURL ) then
-- Report a dead URL without an archived URL
Title = Title .. interrupted_url( frame )
end
fragment_Title = Fragment.new({Title, Format, TitleType, PostTitle}, ' '):last(",")
 
fragment_Title = Fragment.new({Title, Format, TitleType}, ' '):last(",")
else
fragment_Title = Fragment.new({ })
if is_set(Chapter) then
Chapter = DeadURL and not is_set( ArchiveURL )
and tostring(Fragment.new({Chapter, interrupted_url( frame ), Format, TitleType, PostTitle}, ' '):last(""))
or tostring(Fragment.new({Chapter, Format, TitleType, PostTitle}, ' '):last(""))
end
end
Riga 1 569 ⟶ 1 564:
end
fragment_citation:appends( { Conference, Periodical, Translator, Illustrator, Others, Series,
Volume, Issue, Edition, Place, PublisherName, Station, Date, Position } )
local fragment_ID_list = Fragment.new(ID_list, sepc):append(ID):start(",")
local fragment_URL = Fragment.new(URL):start(",")
Riga 1 595 ⟶ 1 590:
end
 
-- if string.len(text:gsub("<span[^>/]*>.-</span>", ""):gsub("%b<>","")) <= 2 then
-- z.error_categories = {};
-- text = set_error('empty_citation');
-- z.message_tail = {};
-- end
 
if is_set(Ref) then
Riga 1 713 ⟶ 1 708:
end
end
return citation0( config, args, frame)
end
 
-- Funzione per generare direttamente una citazione web da un altro modulo
function z.citaweb(args)
return citation0( {CitationClass = 'web'}, args )
end
 
Riga 1 726:
for _,key in ipairs(keys) do
rows[#rows+1] = '|-\n|' .. key .. '|| [[' .. cfg.external_link_type[key].link ..
']] || (<span style="font-weight: bolder; font-size: smaller;">' ..
cfg.external_link_type[key].label .. '</span>)'
end
rows[#rows+1] = "|}"