Modulo:Citazione/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Moroboshi (discussione | contributi)
fix
correggo
 
(29 versioni intermedie di 6 utenti non mostrate)
Riga 26:
 
--[[ ===============================================================================
CaricamenteCaricamento delle tabelle di configurazione del modulo.
===============================================================================]]
local cfg = mw.loadData('Module:Citazione/Configurazione/sandbox')
Riga 98:
 
--[[ ===============================================================================
Ritorna true/false a seconda che la stringa siasi esclusivamentepossa inscrivere caratteriin latinicorsivo
===============================================================================]]
local function is_latinis_italicizable( str )
return require('Modulo:IsLatinValido in corsivo')._IsLatin_main({ str })
end
 
Riga 476:
if type(links) == 'table' then
for _, t in ipairs(links) do
t[2] = is_latinis_italicizable( t[2] ) and wrap( 'italic-title', t[2] ) or t[2]
value = value .. ' / ' .. external_link( t[1], t[2] )
end
Riga 517:
if ( code == "A" ) then
return link_id({link=handler.link, label=handler.label,
pattern="[http[openlibrary://openlibrary.org/authors/OL$1 |$1]]",id=id, separator=handler.separator,
encode = handler.encode})
elseif ( code == "M" ) then
return link_id({link=handler.link, label=handler.label,
pattern="[http[openlibrary://openlibrary.org/books/OL$1 |$1]]",id=id, separator=handler.separator,
encode = handler.encode})
elseif ( code == "W" ) then
return link_id({link=handler.link, label=handler.label,
pattern= "[http[openlibrary://openlibrary.org/works/OL$1 |$1]]",id=id, separator=handler.separator,
encode = handler.encode})
else
return link_id({link=handler.link, label=handler.label,
pattern= "[http://[openlibrary.org/:OL$1 |$1]]",id=id, separator=handler.separator,
encode = handler.encode}) ..
' ' .. set_error( 'bad_ol' );
Riga 799:
Estrae una lista di nomi (autori o editori) dalla lista argomenti
===============================================================================]]
local function extract_names(args, list_name, parent_name)
local names = {};
local i = 1;
local last;
local parameters = {
first = cfg.aliases[list_name .. '-First'],
last = cfg.aliases[list_name .. '-Last'],
link = cfg.aliases[list_name .. '-Link'],
}
 
if parent_name then
for k, t in pairs(parameters) do
local new_values = {}
for _, v in ipairs(t) do
table.insert( new_values, substitute(v, parent_name) )
end
parameters[k] = new_values
end
end
 
while true do
last = select_one( args, cfgparameters.aliases[list_name .. '-Last']last, 'redundant_parameters', i );
if not is_set(last) then
local first = select_one( args, cfgparameters.aliases[list_name .. '-First']first, 'redundant_parameters', i )
if not is_set(first) then
break;
Riga 814 ⟶ 829:
last = first,
first = '',
link = select_one( args, cfgparameters.aliases[list_name .. '-Link']link, 'redundant_parameters', i ),
}
end
Riga 820 ⟶ 835:
names[i] = {
last = last,
first = select_one( args, cfgparameters.aliases[list_name .. '-First']first, 'redundant_parameters', i ),
link = select_one( args, cfgparameters.aliases[list_name .. '-Link']link, 'redundant_parameters', i ),
};
end
Riga 827 ⟶ 842:
end
return names;
end
 
--[[ ===============================================================================
Genera link a wikisource
===============================================================================]]
local function build_wikisource_link(language, title, chapter, anchor)
if is_set(title) then
return mw.ustring.format("s:%s%s%s%s", is_set(language) and (language .. ":") or "" ,
title, is_set(chapter) and ("/" .. chapter) or "" ,
is_set(anchor) and ("#" .. anchor) or "")
end
end
 
Riga 950 ⟶ 954:
local Others = A['Others'];
local Editors = A['Editors'];
local No_editor = A['No_editor'];
local e = extract_names( args, 'EditorList' );
 
Riga 982 ⟶ 985:
 
if is_set(OriginalTitle) and not is_set(TransTitle) then
TransTitle = TitleOriginalTitle
Title = OriginalTitle
end
 
Riga 1 084 ⟶ 1 086:
end
else
-- formatta Volume e Issue considerando numeri anche le stringhe del tipo n-n o n/n
if is_set(Volume) then
if tonumber(Volume:gsub('[-/]', ''), 10) or A:ORIGIN('Volume') == "vol" then
Volume = "vol. " .. Volume
end
end
if is_set(Issue) and A:ORIGIN('Periodical') ~= "collana" then
if tonumber(Issue:gsub('[-/]', ''), 10) then
Issue = "nº. " .. Issue
end
end
Riga 1 120 ⟶ 1 123:
local ID_list = extract_ids( args );
if ( isPubblicazione ) then
if not is_set(URL) and not is_set(TitleLink) then
if is_set(ID_list['PMC']) then
local Embargo = A['Embargo'];
Riga 1 179 ⟶ 1 182:
------------------------------------------------------------------------------
local auto_Periodical = false
if in_array(config.CitationClass, {'web'}) and not is_set(Periodical) and not is_set(PublisherName) and is_set(URL) then
Periodical = mw.ustring.match(URL, "//([^/#%?]*)") or ''
-- tolgo anche eventuale www.
Riga 1 186 ⟶ 1 189:
end
-- evito ripetizione se il dominio è stato usato come titolo o editore
if is_set(Periodical) andthen
if mw.ustring.lower(Title or '') == mw.ustring.lower(Periodical) then
Periodical = nil''
end
if mw.ustring.lower(PublisherName) == mw.ustring.lower(Periodical) then
PublisherName = ''
end
end
auto_Periodical = true
end
------------------------------------------------------------------------------
-- Per cambiare posizione alle collane nella citazione rispetto ai nomi
-- di rivista ed evitare che siano precedute da un "in"
------------------------------------------------------------------------------
local EditorialCollection = ''
if is_set(Periodical) and A:ORIGIN('Periodical') == "collana" then
EditorialCollection = "(collana " .. Periodical;
if is_set(Issue) then
EditorialCollection = EditorialCollection .. ', ' .. Issue;
Issue = '';
end
EditorialCollection = EditorialCollection .. ')';
Periodical = '';
end
 
Riga 1 206 ⟶ 1 228:
 
---------------------------------------------------------------
-- Compone la stringa deldella linguaggiolingua
---------------------------------------------------------------
local Language_code = ""
Riga 1 224 ⟶ 1 246:
first_language = frame_lingue[1]:lower();
local lg_error;
Language_code, lg_error = require("Modulo:LinguaggiLingue").lingue(frame_lingue)
if lg_error and #lg_error > 0 then
local error_string = mw.text.listToText(lg_error, ", ", " e " )
Riga 1 239 ⟶ 1 261:
 
------------------------------------------------------------------------------
-- Aggiunge automaticamente il wikilink se chiamato da citaa wikisourceWikisource
------------------------------------------------------------------------------
if is_set(A['Source']) and not in_array(config.CitationClass, =={ "wikisourceweb", "video", "tv", "audio" } ) then
Anchorlocal source = A['AnchorSource'];
-- se s=1 usa lo stesso valore di titolo/capitolo
if is_set(TitleLink) then
if source == "1" then
TitleLink = build_wikisource_link(first_language, TitleLink, "", Anchor)
source = Title .. (is_set(Chapter) and ("/" .. Chapter) or "")
elseif is_set(Title) then
TitleLink = build_wikisource_link(first_language, Title, "", (is_set(Chapter) and "") or Anchor)
end
if is_set(ChapterLink) then
ChapterLink = build_wikisource_link(first_language, ChapterLink, "", Anchor)
elseif is_set(Chapter) and is_set(Title) then
ChapterLink = build_wikisource_link(first_language, Title, Chapter, Anchor)
end
source = "s:" .. (is_set(first_language) and (first_language .. ":") or "") .. source
if is_set(Chapter) then ChapterLink = source
else TitleLink = source end
end
 
Riga 1 286 ⟶ 1 305:
-- Recupero e formatto lista curatori
------------------------------------------------------------------------------
local EditorCount, msg_editors
local CuratoriEtal = A['Etalcuratori']
control.coauthors = false
ifcontrol.etal = is_set(CuratoriEtal) then
control.etal = true
else
control.etal = false
end
if is_set(Editors) then
msg_editors = 'editors'
else
local EditorCount
Editors, EditorCount = list_people(control, e)
if is_set(Editors) then
ifmsg_editors = EditorCount <= 1 then msg_editors =and 'editor' else msg_editors =or 'editors' end
end
end
 
------------------------------------------------------------------------------
-- SeRecupero none sonoformatto definitilista autori sostituisco cone curatori di un singolo capitolo dell'opera citata
------------------------------------------------------------------------------
local msg_chapter_editors
if not is_set(Authors) and is_set(Editors) then
local Contributors, ChapterEditors = "", ""
Authors = Editors
if is_set(Chapter) then
Editors = ""
local ChapterEditorCount
control.etal = false
Contributors = list_people(control,
extract_names( args, 'ContributorList', A:ORIGIN('Chapter') ))
ChapterEditors, ChapterEditorCount = list_people(control,
extract_names( args, 'ChapterEditorList', A:ORIGIN('Chapter') ))
if is_set(ChapterEditors) then
msg_chapter_editors = ChapterEditorCount <= 1 and 'editor' or 'editors'
end
end
 
Riga 1 431 ⟶ 1 457:
end
end
Chapter = is_latinis_italicizable( Chapter ) and wrap( 'italic-title', Chapter ) or Chapter;
if is_set(TransChapter) then Chapter = Chapter .. " " .. TransChapter end
if is_set(Chapter) then
Riga 1 468 ⟶ 1 494:
end
end
Title = is_latinis_italicizable( Title ) and wrap('italic-title', Title ) or Title;
if is_set(TransTitle) then Title = Title .. " " .. TransTitle end
if is_set(Title) then
Riga 1 580 ⟶ 1 606:
elseif is_set(PublisherName) then
PublisherName = PublisherName .. " " .. OrigDate
elseif is_set(PlasePlace) then
Place = Place .. " " .. OrigDate
else
Riga 1 588 ⟶ 1 614:
 
-- Several of the above rely upon detecting this as nil, so do it last.
if is_set(Periodical) then Periodical = wrap( 'italic-title', Periodical ) end
local Book_series = ''
if is_set(Periodical) then
-- Per cambiare posizione a collane o serie di libri nella citazione, rispetto a nomi di rivista
-- ed evitare di precederle con un "in"
if A:ORIGIN('Periodical') == "opera" or A:ORIGIN('Periodical') == "collana" then
Book_series = Periodical
Periodical = ''
else
Periodical = wrap( 'italic-title', Periodical )
end
end
if (config.CitationClass=="news" or config.CitationClass=="pubblicazione") then
local post_title = {}
if is_set(Institution) then
post_title[1] = Institution
Institution = ''
end
if is_set(Place) then
post_title[#post_title+1] = Place
Place = ''
end
if is_set(PublisherName) then
post_title[#post_title+1] = PublisherName
PublisherName = ''
end
if #post_title > 0 then
if is_set(Periodical) then
Periodical = Periodical .. ' (' .. table.concat(post_title, ',') .. ')'
elseif is_set(Title) then
Title = Title .. ' (' .. table.concat(post_title, ',') .. ')'
end
end
end
 
-- set translator / illustrator
Riga 1 656 ⟶ 1 650:
fragment_citation:append(fragment_Title)
else
if is_set(AuthorsChapterEditors) and (is_set(EditorsContributors) andor is_set(Title)args["anteposizione-curatore"] and== not is_set(Chapter"no") then
EditorsChapterEditors = 'a cura di ' .. EditorsChapterEditors
fragment_citation = Fragment.new({AuthorsContributors, Chapter, ChapterEditors}, sepc)
fragment_citation:appends({fragment_Title, Editors})
else
if is_set(msg_editors) and not is_set(No_editorChapterEditors) then
ChapterEditors = wrap(msg_chapter_editors, ChapterEditors)
if is_set(Editors) then
end
Editors = wrap(msg_editors, Editors)
if is_set(Chapter) and not (is_set(Contributors) or is_set(ChapterEditors)) then
else
Authorsif = wrapis_set(msg_editors, Authors) then
Contributors, Authors = Authors, ""
elseif is_set(Editors) and args["anteposizione-curatore"] ~= "no" then
ChapterEditors, Editors = wrap(msg_editors, Editors), ""
end
end
fragment_citation = Fragment.new({Authorsis_set(Contributors) and Contributors or ChapterEditors, Chapter}, sepc)
end
if Chapter ~= "" or Editors ~= "" then
if is_set(Chapter) then
if A:ORIGIN('Periodical') == 'sito' or auto_Periodical then -- antepone "su" anzichè "in" per i siti web
-- antepone "su" anzichè "in" per i siti web
fragment_citation:last("su")
if A:ORIGIN('Periodical') == 'sito' or auto_Periodical then
else
fragment_citation:last("insu")
endelse
fragment_citation:last("in")
end
end
if is_set(Editors) and (is_set(Authors) or args["anteposizione-curatore"] == "no" and not is_set(Chapter)) then
Editors = 'a cura di ' .. Editors
fragment_citation:appends({Authors, fragment_Title, Editors})
else
if is_set(Editors) then
Editors = wrap(msg_editors, Editors)
end
fragment_citation:appends({is_set(Authors) and Authors or Editors, fragment_Title})
end
end
fragment_citation:appends( { Conference, Periodical, Translator, Illustrator, Others, Series, Volume, Issue,
VolumeEdition, Issue, EditionInstitution, Place, PublisherName, Station, Date, Book_series, Position } )
local fragment_ID_list = Fragment.new(ID_list, sepc):append(ID):start(",")
local fragment_URL = Fragment.new(URL):start(",")
Riga 1 687 ⟶ 1 692:
local fragment_Via = Fragment.new(Via):start(".")
local fragment_Quote = Fragment.new({Quote}):start(".")
fragment_citation:appends({fragment_ID_list, EditorialCollection, fragment_URL, fragment_AccessDate, fragment_Archived, fragment_Via, fragment_Quote})
if PostScript == 'nessuno' then
fragment_citation:last("nothing")
Riga 1 693 ⟶ 1 698:
fragment_citation:last("..")
end
fragment_citation:appends({fragment_Quote})
fragment_citation:start(" ")
local text = Language_code .. tostring(fragment_citation)
-- aggiungo l'icona per cita video/audio
if config.CitationClass == "video" then text = cfg.messages['icon_video'] .. ' ' .. text end
if config.CitationClass == "audio" then text = cfg.messages['icon_audio'] .. ' ' .. text end
if config.CitationClass == "wikisource" then text = cfg.messages['Wikisource icon'] .. ' ' .. text end
 
-- Now enclose the whole thing in a <span/> element
Riga 1 804 ⟶ 1 809:
else
if #suggestions == 0 then
suggestions = mw.loadDdataloadData('Modulo:Citazione/Suggerimenti');
--suggestions = load_configuration_table( 'Modulo:Citazione/Suggerimenti');
end
Riga 1 830 ⟶ 1 835:
end
return citation0( config, args )
end
 
-- Temporanea per retrocompatibilità
function z.collegamenti(args)
return citation0( {CitationClass = 'web'}, args )
end
 
-- Funzione per generare direttamente una citazione da un altro modulo
function z.cita_da_modulo(classe, args)
-- mi assicuro che le code messaggi di errore siano vuote per evitare problemi in caso
-- per citazioni multiple dall'interno dello stesso modulo
z.error_categories = {}; -- lista delle categorie di errore
z.error_ids = {}; -- lista dei codici di errore
z.message_tail = {}; -- messaggi di errore da visualizzare in coda alla citazione
return citation0( {CitationClass = classe}, args )
end