Module:Citation/CS1: திருத்தங்களுக்கு இடையிலான வேறுபாடு
உள்ளடக்கம் நீக்கப்பட்டது உள்ளடக்கம் சேர்க்கப்பட்டது
sync with sandbox, reposition translation error to avoid wrapping in url |
sync to sandbox, add additional redundant parameters checks, check for malformed URLs, removal of wikilinks in COinS data, and various code formatting. |
||
வரிசை 1:
local z = {
error_categories = {};
error_ids = {};
message_tail = {};
}
வரி 65 ⟶ 66:
cfg.message_list['help page label'] .. "]])";
z.error_ids[ error_id ] = true;
if (error_id == 'bare_url_missing_title' or error_id == 'trans_missing_title')
and z.error_ids['citation_missing_title'] then
end▼
if raw == true then
return message, error_state.hidden;
end
return errorcomment( message, error_state.hidden );
வரி 104 ⟶ 111:
return "[[" .. options.link .. "|" .. options.label .. "]]" .. sep .. "[[" ..
options.prefix .. options.id .. options.suffix .. "|" .. mw.text.nowiki(options.id) .. "]]"
end
-- Format an external link with error checking
function externallink( URL, label )
local error_str = "";
if label == nil or label == "" then
end▼
if not checkurl( URL ) then
error_str = seterror( 'bad_url' ) .. error_str;
end
return "[" .. URL .. ' ' .. safeforurl( label ) .. "]" .. error_str;
end
வரி 161 ⟶ 182:
encode = handler.encode}) ..
' ' .. seterror( 'bad_ol' );
end
end
--[[
Determines whether an URL string is valid
At present the only check is whether the string appears to
be prefixed with a URI scheme. It is not determined whether
the URI scheme is valid or whether the URL is otherwise well
formed.
]]
function checkurl( url_str )
-- Protocol-less URLs
elseif url_str:match( "^[^/]*:" ) ~= nil then
-- Look for ":" prefix and assume it is a URI scheme
return true;
else
-- Anything else is an error
return false;
end
end
வரி 193 ⟶ 235:
return temp % 10 == 0;
end
end
-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
str = str:gsub( "%[%[[^|%]]*|([^%]]*)%]%]", "%1" );
str = str:gsub( "%[%[([^%]]*)%]%]", "%1" );
return str
end
வரி 395 ⟶ 444:
-- Generates a CITEREF anchor ID.
function anchorid( options )
▲ if encoded == false then
▲ encoded = "";
▲ end
end
வரி 544 ⟶ 581:
elseif k == 'ISBN' then
local ISBN = internallinkid( handler );
if not checkisbn( v ) and (IgnoreISBN == nil or IgnoreISBN == "") then
ISBN = ISBN .. seterror( 'bad_isbn' );
end
வரி 621 ⟶ 658:
local a = extractauthors( args );
local Coauthors = selectone( args
local Others = args.others
local Editors = args.editors
வரி 627 ⟶ 664:
local Year = args.year
local PublicationDate = selectone( args
local OrigYear = args.origyear
local Date = args.date
வரி 635 ⟶ 672:
local BookTitle = args.booktitle
local Conference = args.conference
local TransTitle = selectone( args
local TitleNote = args.department
local TitleLink = selectone( args
local Chapter = selectone( args, {'chapter', 'contribution', 'entry' }, 'redundant_parameters' );
local ChapterLink = args.chapterlink
local TransChapter = selectone( args
local TitleType = args.type
local ArchiveURL = selectone( args
local URL = selectone( args
local ChapterURL = selectone( args
local ConferenceURL = selectone( args
local Periodical = selectone( args, {'journal', 'newspaper', 'magazine', 'work', 'website',
'periodical', 'encyclopedia', 'encyclopaedia'}, 'redundant_parameters' );
வரி 685 ⟶ 722:
local Edition = args.edition
local PublicationPlace = selectone( args
local Place = selectone( args, {'place', 'location'}, 'redundant_parameters' );
if PublicationPlace == nil and Place ~= nil then
வரி 695 ⟶ 732:
local SubscriptionRequired = args.subscription
local Via = args.via
local AccessDate = selectone( args
local ArchiveDate = selectone( args
local Agency = args.agency
local DeadURL = args.deadurl or "yes" -- Only used
local Language = selectone( args, {'language', 'in'}, 'redundant_parameters' );
local Format = args.format
local Ref = selectone( args
local DoiBroken = selectone( args
local ID = selectone( args, {'id', 'ID', 'docket'}, 'redundant_parameters' );
local ASINTLD = selectone( args
local IgnoreISBN = selectone( args, {'ignore-isbn-error', 'ignoreisbnerror'}, 'redundant_parameters' );
local ID_list = extractids( args );
வரி 714 ⟶ 752:
local LaySource = args.laysource
local Transcript = args.transcript
local TranscriptURL = selectone( args
local sepc = args.separator or "."
local LastAuthorAmp = args.lastauthoramp
local no_tracking_cats = selectone( args
if ( config.CitationClass == "journal" ) then
வரி 844 ⟶ 882:
local OCinStitle = "ctx_ver=" .. ctx_ver -- such as "Z39.88-2004"
for name,value in pairs(OCinSdata) do
OCinStitle = OCinStitle .. "&" .. name .. "=" .. mw.uri.encode( removewikilink(value) );
end
for _, value in ipairs(OCinSauthors) do
OCinStitle = OCinStitle .. "&rft.au=" .. mw.uri.encode( removewikilink(value) );
end
for name,value in pairs(OCinSids) do
OCinStitle = OCinStitle .. "&rft_id=" .. mw.uri.encode(name .. "/" .. removewikilink(value) );
end
வரி 872 ⟶ 910:
-- various parts of the citation, but only when they are non-nil.
if ( Authors == nil ) then
local Maximum = tonumber( (selectone( args
-- Preserve old-style implicit et al.
வரி 885 ⟶ 923:
sep = (args["author-separator"] or ";") .. " ",
namesep = (args["author-name-separator"] or args["name-separator"] or ",") .. " ",
format = selectone( args
maximum = Maximum,
lastauthoramp = LastAuthorAmp
வரி 900 ⟶ 938:
local EditorCount
if ( Editors == nil ) then
local Maximum = tonumber( (selectone( args
-- Preserve old-style implicit et al.
வரி 913 ⟶ 951:
sep = (args["editor-separator"] or ";") .. " ",
namesep = (args["editor-name-separator"] or args["name-separator"] or ",") .. " ",
format = selectone( args
maximum = Maximum,
lastauthoramp = LastAuthorAmp
வரி 1,029 ⟶ 1,067:
if Chapter ~= "" then
if ( ChapterLink == nil ) then
if ( ChapterURL and "" < ChapterURL ) then
Chapter =
if URL == nil or URL == "" then
Chapter = Chapter .. Format;
வரி 1,036 ⟶ 1,074:
end
elseif ( URL and "" < URL ) then
Chapter =
URL = nil
Format = ""
வரி 1,043 ⟶ 1,081:
end
elseif ChapterURL ~= nil and ChapterURL ~= "" then
Chapter = Chapter .. "
TransError
else
Chapter = Chapter .. TransError;
வரி 1,050 ⟶ 1,088:
Chapter = Chapter .. sepc .. " " -- with end-space
elseif ChapterURL ~= nil and ChapterURL ~= "" then
Chapter = "
end
வரி 1,079 ⟶ 1,116:
if Title ~= "" then
if ( TitleLink == nil and URL and "" < URL ) then
Title =
URL = nil
Format = ''
வரி 1,099 ⟶ 1,136:
if ( Conference ~= nil and Conference ~="" ) then
if ( ConferenceURL ~= nil ) then
Conference =
end
Conference = " " .. Conference
elseif ConferenceURL ~= nil and ConferenceURL ~= "" then
Conference = "
▲ seterror( 'bare_url_missing_title' );
else
Conference = ""
வரி 1,205 ⟶ 1,241:
if ( ID ~= nil and ID ~="") then ID = sepc .." ".. ID else ID="" end
ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN} );
if ( URL ~= nil and URL ~="") then
URL = " " ..
local error_text = seterror( 'bare_url_missing_title' );
if config.CitationClass == "web" then
வரி 1,238 ⟶ 1,274:
ArchiveDate = " " .. seterror('archive_missing_date') .. " "
end
local arch_text =
if (sepc ~= ".") then arch_text = arch_text:lower() end
if ( "no" == DeadURL ) then
Archived = sepc .. "
cfg.message_list['from'] .. " " .. cfg.message_list['original'] .. " " ..
cfg.message_list['on'] .. ArchiveDate
வரி 1,249 ⟶ 1,285:
else
if OriginalURL ~= nil and OriginalURL ~= '' then
Archived = sepc .. " " .. arch_text .. " " .. cfg.message_list['from']
.. cfg.message_list['on'] .. ArchiveDate
else
if config.CitationClass ~= 'web' then
Archived = sepc .. " " .. arch_text .. " " .. cfg.message_list['from'] .. " " ..
seterror('archive_missing_url') .. " " .. cfg.message_list['on'] .. ArchiveDate
else
Archived = sepc .. " " .. arch_text .. " " .. cfg.message_list['from'] ..
" " .. cfg.message_list['original'] .. " " ..
cfg.message_list['on'] .. ArchiveDate
வரி 1,282 ⟶ 1,319:
end
if ( nil ~= Transcript and "" ~= Transcript ) then
if ( TranscriptURL ~= nil ) then Transcript =
elseif TranscriptURL ~= nil and TranscriptURL ~= "" then
Transcript =
else
Transcript = ""
வரி 1,448 ⟶ 1,484:
local names = {} --table of last names & year
if ( "" ~= Authors ) then
for i,v in ipairs(a) do
elseif ( "" ~= Editors ) then
for i,v in ipairs(e) do
▲ elseif ( names[2] == nil ) then
▲ names[2] = Year
▲ names[3] = Year
names[4] = Year▼
▲ else
names[5] = Year▼
end
id = anchorid(names)
end
வரி 1,480 ⟶ 1,512:
end
local empty_span = '<span style="display:
-- Note: Using display: none on then COinS span breaks some clients.
வரி 1,488 ⟶ 1,520:
if #z.message_tail ~= 0 then
for i,v in ipairs( z.message_tail ) do
if
text = text .. errorcomment( v[1], v[2] );
▲ else
text = text .. errorcomment( v[1] .. "; ", v[2] );
end
end
| |||