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
encodedreturn ='', ""false;
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
label = elseURL;
error_str = seterror( 'bare_url_missing_title' );
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 )
if encodedurl_str:sub(1,2) == false"//" then
-- Protocol-less URLs
return elsetrue;
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 )
localreturn P1"CITEREF" =.. mw.uri.anchorEncode( table.concat( options[1] or) "");
local P2 = options[2] or ""
local P3 = options[3] or ""
local P4 = options[4] or ""
local P5 = options[5] or ""
-- Bugzilla 46608
local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
if encoded == false then
encoded = "";
end
return "CITEREF" .. encoded;
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., {'coauthors', or args.'coauthor' }, 'redundant_parameters' );
local Others = args.others
local Editors = args.editors
வரி 627 ⟶ 664:
 
local Year = args.year
local PublicationDate = selectone( args., {'publicationdate', or args["'publication-date"]' }, 'redundant_parameters' );
local OrigYear = args.origyear
local Date = args.date
வரி 635 ⟶ 672:
local BookTitle = args.booktitle
local Conference = args.conference
local TransTitle = selectone( args., {'trans-title', 'trans_title' }, 'redundant_parameters' );
local TitleNote = args.department
local TitleLink = selectone( args., {'titlelink', or args.'episodelink' }, 'redundant_parameters' );
local Chapter = selectone( args, {'chapter', 'contribution', 'entry' }, 'redundant_parameters' );
local ChapterLink = args.chapterlink
local TransChapter = selectone( args[", {'trans-chapter"]', or args.'trans_chapter' }, 'redundant_parameters' );
local TitleType = args.type
local ArchiveURL = selectone( args[", {'archive-url"]', or args.'archiveurl' }, 'redundant_parameters' );
local URL = selectone( args., {'url', or args.'URL'}, 'redundant_parameters' );
local ChapterURL = selectone( args[", {'chapter-url"]', or args.'chapterurl', or args["'contribution-url"]', 'contributionurl' }, 'redundant_parameters' );
local ConferenceURL = selectone( args[", {'conference-url"]', or args.'conferenceurl' }, 'redundant_parameters' );
local Periodical = selectone( args, {'journal', 'newspaper', 'magazine', 'work', 'website',
'periodical', 'encyclopedia', 'encyclopaedia'}, 'redundant_parameters' );
வரி 685 ⟶ 722:
local Edition = args.edition
local PublicationPlace = selectone( args[", {'publication-place"]', or args.'publicationplace' }, 'redundant_parameters' );
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[", {'access-date"]', or args.'accessdate' }, 'redundant_parameters' );
local ArchiveDate = selectone( args[", {'archive-date"]', or args.'archivedate' }, 'redundant_parameters' );
local Agency = args.agency
local DeadURL = args.deadurl or "yes" -- Only used isif ArchiveURL is present.
local Language = selectone( args, {'language', 'in'}, 'redundant_parameters' );
local Format = args.format
local Ref = selectone( args., {'ref', or args.'Ref'}, 'redundant_parameters' );
 
local DoiBroken = selectone( args., {'doi_inactivedate', or args.'doi_brokendate', or args.'DoiBroken'}, 'redundant_parameters' );
local ID = selectone( args, {'id', 'ID', 'docket'}, 'redundant_parameters' );
local ASINTLD = selectone( args[", {'ASIN-TLD"]', or args["'asin-tld"]'}, 'redundant_parameters' );
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[", {'transcript-url"]', or args.'transcripturl'}, 'redundant_parameters' );
local sepc = args.separator or "."
local LastAuthorAmp = args.lastauthoramp
local no_tracking_cats = selectone( args[, {"template doc demo"], or args.'nocat or',
args.'notracking', or args["no-tracking"]}, 'redundant_parameters' ) or "";
 
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[, {"display-authors"], or args."displayauthors"}, 'redundant_parameters' )) );
-- 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[, {"author-format"], or args."authorformat" }, 'redundant_parameters' ),
maximum = Maximum,
lastauthoramp = LastAuthorAmp
வரி 900 ⟶ 938:
local EditorCount
if ( Editors == nil ) then
local Maximum = tonumber( (selectone( args[, {"display-editors"], or args."displayeditors"}, 'redundant_parameters' )) );
 
-- 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[, {"editor-format"], or args."editorformat" }, 'redundant_parameters' ),
maximum = Maximum,
lastauthoramp = LastAuthorAmp
வரி 1,029 ⟶ 1,067:
if Chapter ~= "" then
if ( ChapterLink == nil ) then
if ( ChapterURL and "" < ChapterURL ) then
Chapter = "[" ..externallink( ChapterURL .. " " .. safeforurl(, Chapter ) .. "]" .. TransError;
if URL == nil or URL == "" then
Chapter = Chapter .. Format;
வரி 1,036 ⟶ 1,074:
end
elseif ( URL and "" < URL ) then
Chapter = "[" ..externallink( URL .. " " .. safeforurl(, Chapter ) .. "]" .. TransError .. Format;
URL = nil
Format = ""
வரி 1,043 ⟶ 1,081:
end
elseif ChapterURL ~= nil and ChapterURL ~= "" then
Chapter = Chapter .. " [" .. ChapterURL .. " " .. safeforurlexternallink( ChapterURL ) .. "]" ..
TransError .. " " .. seterror( 'bare_url_missing_title' );
else
Chapter = Chapter .. TransError;
வரி 1,050 ⟶ 1,088:
Chapter = Chapter .. sepc .. " " -- with end-space
elseif ChapterURL ~= nil and ChapterURL ~= "" then
Chapter = " [" .. ChapterURL .. " " .. safeforurlexternallink( ChapterURL ) .. "]"sepc .. " ";
seterror( 'bare_url_missing_title' ) .. sepc .. " ";
end
வரி 1,079 ⟶ 1,116:
if Title ~= "" then
if ( TitleLink == nil and URL and "" < URL ) then
Title = "[" ..externallink( URL, Title ) .. " "TransError .. safeforurl(Format Title ) .. "]" .. TransError .. Format
URL = nil
Format = ''
வரி 1,099 ⟶ 1,136:
if ( Conference ~= nil and Conference ~="" ) then
if ( ConferenceURL ~= nil ) then
Conference = "[" ..externallink( ConferenceURL .. " " .. safeforurl(, Conference ) .. "]";
end
Conference = " " .. Conference
elseif ConferenceURL ~= nil and ConferenceURL ~= "" then
Conference = " [" .. ConferenceURL .. " " .. safeforurlexternallink( ConferenceURL ) .. "]" .. ;
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 = " " .. "["externallink( ..URL, URL .. " " .. mw.text.nowiki(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 = " " .. cfg.message_list['archived'];
if (sepc ~= ".") then arch_text = arch_text:lower() end
if ( "no" == DeadURL ) then
Archived = sepc .. " [" .. externallink( ArchiveURL, ..arch_text arch_text) .. "] " ..
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'] .. " [" .. OriginalURL .. " " ..
cfg.message_list['original'] .. "] " .. externallink( OriginalURL, cfg.message_list['onoriginal'] ) .. ArchiveDate" "
.. 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 = "[" ..externallink( TranscriptURL .., Transcript .. "]") end
elseif TranscriptURL ~= nil and TranscriptURL ~= "" then
Transcript = "[" .. TranscriptURL .. " " .. safeforurlexternallink( TranscriptURL ) .. "]" ..
seterror( 'bare_url_missing_title' )
else
Transcript = ""
வரி 1,448 ⟶ 1,484:
local names = {} --table of last names & year
if ( "" ~= Authors ) then
for i,v in ipairs(a) do names[i] = v.last end
names[2i] = Yearv.last
elseif ( names[2] if i == nil )4 then break end
names[3] = Yearend
elseif ( "" ~= Editors ) then
for i,v in ipairs(e) do names[i] = v.last end
end names[i] = v.last
if ( names[1] if i == nil )4 then break end
names[1] = Year end
elseif ( names[2] == nil ) then
names[2] = Year
elseif ( names[3] == nil ) then
names[3] = Year
elseif ( names[4] == nil ) then
names[4] = Year
else
names[5] = Year
end
names[ #names + 1 names[4] = Year;
id = anchorid(names)
end
வரி 1,480 ⟶ 1,512:
end
 
local empty_span = '<span style="display: none;">&nbsp;</span>';
-- 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 iv[1] ~= nil and v[1] ~= #z.message_tail"" then
textif i == text #z.. errorcomment( v[1], v[2]message_tail );then
text = text .. errorcomment( v[1], v[2] );
else
text = text .. errorcomment( v[1] .. "; ", v[2] );else
text = text .. errorcomment( v[1] .. "; ", v[2] );
names[5] = Yearend
end
end
"https://tamilar.wiki/w/Module:Citation/CS1" இலிருந்து மீள்விக்கப்பட்டது