Vai al contenuto

Modulo:Citazione: differenze tra le versioni

m
una versione importata
(non inverto title e originaltitle)
 
m (una versione importata)
(9 versioni intermedie di 2 utenti non mostrate)
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( '[[%s|%s]]%s%s',
return mw.ustring.format( '[[wikipedia:it:%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="[http://openlibrary.org/authors/OL$1 $1]",id=id, separator=handler.separator,
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="[http://openlibrary.org/books/OL$1 $1]",id=id, separator=handler.separator,
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= "[http://openlibrary.org/works/OL$1 $1]",id=id, separator=handler.separator,
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= "[http://openlibrary.org/OL$1 $1]",id=id, separator=handler.separator,
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 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, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
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, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i )
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, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
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, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
first = select_one( args, parameters.first, 'redundant_parameters', i ),
link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
link = select_one( args, parameters.link, 'redundant_parameters', i ),
};
};
end
end
Riga 827: Riga 842:
end
end
return names;
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
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 automaticamente il wikilink se chiamato da cita wikisource
-- Aggiunge il wikilink a Wikisource
------------------------------------------------------------------------------
------------------------------------------------------------------------------
if config.CitationClass == "wikisource" then
if is_set(A['Source']) and not in_array(config.CitationClass, { "web", "video", "tv", "audio" } ) then
Anchor = A['Anchor'];
local source = A['Source']
if is_set(TitleLink) then
-- se s=1 usa lo stesso valore di titolo/capitolo
TitleLink = build_wikisource_link(first_language, TitleLink, "", Anchor)
if source == "1" then
elseif is_set(Title) then
source = Title .. (is_set(Chapter) and ("/" .. Chapter) or "")
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
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
if is_set(Chapter) then
local c = extract_names( args, 'ContributorList', A:ORIGIN('Chapter') );
control.etal = false
Contributors = list_people(control, c)
end
end


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) and not is_set(No_editor) then
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
elseif is_set(Contributors) and is_set(Title) then
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 cita video
-- 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