Modulo:Citazione: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica |
aggiungo parametro per indicare l'autore di una parte dell'opera citata e rimuovo parametro no_curatore, vedi discussione |
||
Riga 413: | Riga 413: | ||
options.pattern = mw.ustring.gsub( options.pattern, '([^%[]%[[^%[]%S+)$1(.-%])', '%1$2%2' ); |
options.pattern = mw.ustring.gsub( options.pattern, '([^%[]%[[^%[]%S+)$1(.-%])', '%1$2%2' ); |
||
end |
end |
||
return mw.ustring.format( '[[ |
return mw.ustring.format( '[[%s|%s]]%s%s', |
||
options.link, options.label, options.separator or " ", |
options.link, options.label, options.separator or " ", |
||
substitute( options.pattern, {mw.text.nowiki(options.id), url_string} ) |
substitute( options.pattern, {mw.text.nowiki(options.id), url_string} ) |
||
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'], |
|||
} |
|||
⚫ | |||
for k, t in pairs(parameters) do |
|||
local new_values = {} |
|||
for _, v in ipairs(t) do |
|||
table.insert( new_values, substitute(v, parent_name) ) |
|||
⚫ | |||
parameters[k] = new_values |
|||
⚫ | |||
⚫ | |||
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; |
||
⚫ | |||
--[[ =============================================================================== |
|||
Genera link a wikisource |
|||
===============================================================================]] |
|||
local function build_wikisource_link(language, title, chapter, anchor) |
|||
⚫ | |||
return mw.ustring.format("s:%s%s%s%s", is_set(language) and (language .. ":") or "" , |
|||
⚫ | |||
is_set(anchor) and ("#" .. anchor) or "") |
|||
⚫ | |||
end |
end |
||
Riga 950: | Riga 954: | ||
local Others = A['Others']; |
local Others = A['Others']; |
||
local Editors = A['Editors']; |
local Editors = A['Editors']; |
||
local No_editor = A['No_editor']; |
|||
local e = extract_names( args, 'EditorList' ); |
local e = extract_names( args, 'EditorList' ); |
||
Riga 1 249: | Riga 1 252: | ||
------------------------------------------------------------------------------ |
------------------------------------------------------------------------------ |
||
-- 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'] |
|||
-- se s=1 usa lo stesso valore di titolo/capitolo |
|||
⚫ | |||
if source == "1" then |
|||
TitleLink = build_wikisource_link(first_language, TitleLink, "", Anchor) |
|||
⚫ | |||
⚫ | |||
TitleLink = build_wikisource_link(first_language, Title, "", (is_set(Chapter) and "") or Anchor) |
|||
⚫ | |||
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 |
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 318: | Riga 1 318: | ||
Authors = Editors |
Authors = Editors |
||
Editors = "" |
Editors = "" |
||
end |
|||
------------------------------------------------------------------------------ |
|||
-- Recupero e formatto lista autori di un singolo capitolo dell'opera citata |
|||
------------------------------------------------------------------------------ |
|||
local Contributors |
|||
⚫ | |||
local c = extract_names( args, 'ContributorList', A:ORIGIN('Chapter') ); |
|||
control.etal = false |
|||
Contributors = list_people(control, c) |
|||
end |
end |
||
Riga 1 590: | Riga 1 600: | ||
elseif is_set(PublisherName) then |
elseif is_set(PublisherName) then |
||
PublisherName = PublisherName .. " " .. OrigDate |
PublisherName = PublisherName .. " " .. OrigDate |
||
elseif is_set( |
elseif is_set(Plase) then |
||
Place = Place .. " " .. OrigDate |
Place = Place .. " " .. OrigDate |
||
else |
else |
||
Riga 1 639: | Riga 1 649: | ||
fragment_citation:appends({fragment_Title, Editors}) |
fragment_citation:appends({fragment_Title, Editors}) |
||
else |
else |
||
if is_set(msg_editors |
if is_set(msg_editors) then |
||
if is_set(Editors) then |
if is_set(Editors) then |
||
Editors = wrap(msg_editors, Editors) |
Editors = wrap(msg_editors, Editors) |
||
Riga 1 645: | Riga 1 655: | ||
Authors = wrap(msg_editors, Authors) |
Authors = wrap(msg_editors, Authors) |
||
end |
end |
||
⚫ | |||
Authors, Editors = Contributors, Authors |
|||
end |
end |
||
fragment_citation = Fragment.new({Authors, Chapter}, sepc) |
fragment_citation = Fragment.new({Authors, Chapter}, sepc) |
||
Riga 1 673: | Riga 1 685: | ||
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 |
||
if config.CitationClass == "wikisource" then text = cfg.messages['Wikisource icon'] .. ' ' .. text end |
|||
-- Now enclose the whole thing in a <span/> element |
-- Now enclose the whole thing in a <span/> element |