2 354
contributi
Nessun oggetto della modifica |
m (una versione importata) |
||
(7 versioni intermedie di 2 utenti non mostrate) | |||
Riga 26: | Riga 26: | ||
--[[ =============================================================================== | --[[ =============================================================================== | ||
Caricamento delle tabelle di configurazione del modulo. | |||
===============================================================================]] | ===============================================================================]] | ||
local cfg = mw.loadData('Module:Citazione/Configurazione') | local cfg = mw.loadData('Module:Citazione/Configurazione') | ||
Riga 517: | Riga 517: | ||
if ( code == "A" ) then | if ( code == "A" ) then | ||
return link_id({link=handler.link, label=handler.label, | return link_id({link=handler.link, label=handler.label, | ||
pattern="[ | pattern="[[openlibrary:authors/OL$1|$1]]",id=id, separator=handler.separator, | ||
encode = handler.encode}) | encode = handler.encode}) | ||
elseif ( code == "M" ) then | elseif ( code == "M" ) then | ||
return link_id({link=handler.link, label=handler.label, | return link_id({link=handler.link, label=handler.label, | ||
pattern="[ | pattern="[[openlibrary:books/OL$1|$1]]",id=id, separator=handler.separator, | ||
encode = handler.encode}) | encode = handler.encode}) | ||
elseif ( code == "W" ) then | elseif ( code == "W" ) then | ||
return link_id({link=handler.link, label=handler.label, | return link_id({link=handler.link, label=handler.label, | ||
pattern= "[ | pattern= "[[openlibrary:works/OL$1|$1]]",id=id, separator=handler.separator, | ||
encode = handler.encode}) | encode = handler.encode}) | ||
else | else | ||
return link_id({link=handler.link, label=handler.label, | return link_id({link=handler.link, label=handler.label, | ||
pattern= "[ | pattern= "[[openlibrary:OL$1|$1]]",id=id, separator=handler.separator, | ||
encode = handler.encode}) .. | encode = handler.encode}) .. | ||
' ' .. set_error( 'bad_ol' ); | ' ' .. set_error( 'bad_ol' ); | ||
Riga 764: | Riga 764: | ||
if is_set(first) then | if is_set(first) then | ||
if invertorder then first, last = last, first end | if invertorder then first, last = last, first end | ||
fullname = | fullname = table.concat({first, person.last}, ' ') | ||
else | else | ||
fullname = | fullname = person.last | ||
end | end | ||
if is_set(person.link) then fullname = table.concat({"[[", person.link, "|", fullname, "]]"}) end | if is_set(person.link) then fullname = table.concat({"[[", person.link, "|", fullname, "]]"}) end | ||
Riga 799: | Riga 799: | ||
Estrae una lista di nomi (autori o editori) dalla lista argomenti | Estrae una lista di nomi (autori o editori) dalla lista argomenti | ||
===============================================================================]] | ===============================================================================]] | ||
local function extract_names(args, list_name) | local function extract_names(args, list_name, parent_name) | ||
local names = {}; | local names = {}; | ||
local i = 1; | local i = 1; | ||
local last; | 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 | while true do | ||
last = select_one( args, | last = select_one( args, parameters.last, 'redundant_parameters', i ); | ||
if not is_set(last) then | if not is_set(last) then | ||
local first = select_one( args, | local first = select_one( args, parameters.first, 'redundant_parameters', i ) | ||
if not is_set(first) then | if not is_set(first) then | ||
break; | break; | ||
Riga 814: | Riga 829: | ||
last = first, | last = first, | ||
first = '', | first = '', | ||
link = select_one( args, | link = select_one( args, parameters.link, 'redundant_parameters', i ), | ||
} | } | ||
end | end | ||
Riga 820: | Riga 835: | ||
names[i] = { | names[i] = { | ||
last = last, | last = last, | ||
first = select_one( args, | first = select_one( args, parameters.first, 'redundant_parameters', i ), | ||
link = select_one( args, | link = select_one( args, parameters.link, 'redundant_parameters', i ), | ||
}; | }; | ||
end | end | ||
Riga 827: | Riga 842: | ||
end | end | ||
return names; | return names; | ||
end | end | ||
Riga 950: | Riga 954: | ||
local Others = A['Others']; | local Others = A['Others']; | ||
local Editors = A['Editors']; | local Editors = A['Editors']; | ||
local e = extract_names( args, 'EditorList' ); | local e = extract_names( args, 'EditorList' ); | ||
Riga 1 179: | Riga 1 182: | ||
------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ||
local auto_Periodical = false | local auto_Periodical = false | ||
if in_array(config.CitationClass, {'web'}) and not is_set(Periodical | if in_array(config.CitationClass, {'web'}) and not is_set(Periodical) and is_set(URL) then | ||
Periodical = mw.ustring.match(URL, "//([^/#%?]*)") or '' | Periodical = mw.ustring.match(URL, "//([^/#%?]*)") or '' | ||
-- tolgo anche eventuale www. | -- tolgo anche eventuale www. | ||
Riga 1 186: | Riga 1 189: | ||
end | end | ||
-- evito ripetizione se il dominio è stato usato come titolo o editore | -- evito ripetizione se il dominio è stato usato come titolo o editore | ||
if Periodical | if is_set(Periodical) then | ||
if mw.ustring.lower(Title) == mw.ustring.lower(Periodical) then | |||
Periodical = '' | |||
end | |||
if mw.ustring.lower(PublisherName) == mw.ustring.lower(Periodical) then | |||
PublisherName = '' | |||
end | |||
end | end | ||
auto_Periodical = true | auto_Periodical = true | ||
Riga 1 216: | Riga 1 224: | ||
--------------------------------------------------------------- | --------------------------------------------------------------- | ||
-- Compone la stringa | -- Compone la stringa della lingua | ||
--------------------------------------------------------------- | --------------------------------------------------------------- | ||
local Language_code = "" | local Language_code = "" | ||
Riga 1 234: | Riga 1 242: | ||
first_language = frame_lingue[1]:lower(); | first_language = frame_lingue[1]:lower(); | ||
local lg_error; | local lg_error; | ||
Language_code, lg_error = require("Modulo: | Language_code, lg_error = require("Modulo:Lingue").lingue(frame_lingue) | ||
if lg_error and #lg_error > 0 then | if lg_error and #lg_error > 0 then | ||
local error_string = mw.text.listToText(lg_error, ", ", " e " ) | local error_string = mw.text.listToText(lg_error, ", ", " e " ) | ||
Riga 1 249: | Riga 1 257: | ||
------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ||
-- Aggiunge | -- Aggiunge il wikilink a Wikisource | ||
------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ||
if | if is_set(A['Source']) and not in_array(config.CitationClass, { "web", "video", "tv", "audio" } ) then | ||
local source = A['Source'] | |||
if | -- se s=1 usa lo stesso valore di titolo/capitolo | ||
if source == "1" then | |||
source = Title .. (is_set(Chapter) and ("/" .. Chapter) or "") | |||
end | end | ||
source = "s:" .. (is_set(first_language) and (first_language .. ":") or "") .. source | |||
if is_set(Chapter) then ChapterLink = source | |||
else TitleLink = source end | |||
end | end | ||
Riga 1 296: | Riga 1 301: | ||
-- Recupero e formatto lista curatori | -- Recupero e formatto lista curatori | ||
------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ||
local | local msg_editors | ||
local CuratoriEtal = A['Etalcuratori'] | local CuratoriEtal = A['Etalcuratori'] | ||
control.coauthors = false | control.coauthors = false | ||
control.etal = is_set(CuratoriEtal) | |||
if is_set(Editors) then | if is_set(Editors) then | ||
msg_editors = 'editors' | msg_editors = 'editors' | ||
else | else | ||
local EditorCount | |||
Editors, EditorCount = list_people(control, e) | Editors, EditorCount = list_people(control, e) | ||
if is_set(Editors) then | if is_set(Editors) then | ||
msg_editors = EditorCount <= 1 and 'editor' or 'editors' | |||
end | end | ||
end | end | ||
------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ||
-- | -- Recupero e formatto lista autori e curatori di un singolo capitolo dell'opera citata | ||
------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ||
if | local msg_chapter_editors | ||
local Contributors, ChapterEditors = "", "" | |||
if is_set(Chapter) then | |||
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 | end | ||
Riga 1 634: | Riga 1 646: | ||
fragment_citation:append(fragment_Title) | fragment_citation:append(fragment_Title) | ||
else | else | ||
if is_set( | if is_set(ChapterEditors) and (is_set(Contributors) or args["anteposizione-curatore"] == "no") then | ||
ChapterEditors = 'a cura di ' .. ChapterEditors | |||
fragment_citation = Fragment.new({ | fragment_citation = Fragment.new({Contributors, Chapter, ChapterEditors}, sepc) | ||
else | else | ||
if is_set( | if is_set(ChapterEditors) then | ||
if is_set( | ChapterEditors = wrap(msg_chapter_editors, ChapterEditors) | ||
end | |||
if is_set(Chapter) and not (is_set(Contributors) or is_set(ChapterEditors)) then | |||
if is_set(Authors) then | |||
Contributors, Authors = Authors, "" | |||
elseif is_set(Editors) and args["anteposizione-curatore"] ~= "no" then | |||
ChapterEditors, Editors = wrap(msg_editors, Editors), "" | |||
end | end | ||
end | end | ||
fragment_citation = Fragment.new({ | fragment_citation = Fragment.new({is_set(Contributors) and Contributors or ChapterEditors, Chapter}, sepc) | ||
end | |||
if is_set(Chapter) then | |||
-- antepone "su" anzichè "in" per i siti web | |||
if A:ORIGIN('Periodical') == 'sito' or auto_Periodical then | |||
fragment_citation:last("su") | |||
else | |||
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 | end | ||
fragment_citation:appends({Editors, fragment_Title}) | fragment_citation:appends({is_set(Authors) and Authors or Editors, fragment_Title}) | ||
end | end | ||
end | end | ||
Riga 1 665: | Riga 1 688: | ||
local fragment_Via = Fragment.new(Via):start(".") | local fragment_Via = Fragment.new(Via):start(".") | ||
local fragment_Quote = Fragment.new({Quote}):start(".") | local fragment_Quote = Fragment.new({Quote}):start(".") | ||
fragment_citation:appends({fragment_ID_list, fragment_URL, fragment_AccessDate, fragment_Archived, fragment_Via | fragment_citation:appends({fragment_ID_list, fragment_URL, fragment_AccessDate, fragment_Archived, fragment_Via}) | ||
if PostScript == 'nessuno' then | if PostScript == 'nessuno' then | ||
fragment_citation:last("nothing") | fragment_citation:last("nothing") | ||
Riga 1 671: | Riga 1 694: | ||
fragment_citation:last("..") | fragment_citation:last("..") | ||
end | end | ||
fragment_citation:appends({fragment_Quote}) | |||
fragment_citation:start(" ") | fragment_citation:start(" ") | ||
local text = Language_code .. tostring(fragment_citation) | local text = Language_code .. tostring(fragment_citation) | ||
--aggiungo l'icona per | -- aggiungo l'icona per video/audio | ||
if config.CitationClass == "video" then text = cfg.messages['icon_video'] .. ' ' .. text end | 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 == "audio" then text = cfg.messages['icon_audio'] .. ' ' .. text end | ||
-- Now enclose the whole thing in a <span/> element | -- Now enclose the whole thing in a <span/> element |
contributi