Module:Citation/CS1: திருத்தங்களுக்கு இடையிலான வேறுபாடு
உள்ளடக்கம் நீக்கப்பட்டது உள்ளடக்கம் சேர்க்கப்பட்டது
D'oh, meant to edit sandbox |
sync to sandbox, mostly translation handles almost uniformity for archiveurl errors. |
||
வரிசை 4:
message_tail = {};
}
local SEEN = {};
local DATA = {};
-- Include translation message hooks, ID and error handling configuration settings.
local cfg =
-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
-- Populates numbered arguments in a message string using
-- an argument table.
function substitute( message, arguments )
if arguments == nil then
return message;
end
message = message .. " ";
for k, v in ipairs( arguments ) do
v = v:gsub( "%%", "%%%%" );
message = message:gsub( "$" .. k .. "(%D)", v .. "%1" );
end
message = message:sub(1,-2);
return message;
end
--[[
Argument wrapper. This function provides support for argument
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
DATA = args;
local tbl = {};
local mt = {
__index = function ( tbl, k )
if SEEN[k] then
return nil;
end
local list = cfg.argument_map[k];
if list == nil then
error( cfg.message_list['unknown_argument_map'] );
elseif type( list ) == 'string' then
v = DATA[list];
else
v = selectone( DATA, cfg.argument_map[k],
'redundant_parameters' );
end
if v == nil then
v = cfg.default_values[k];
end
SEEN[k] = true;
tbl = rawset( tbl, k, v );
return v;
end,
}
return setmetatable( tbl, mt );
end
-- Checks that parameter name is valid using the whitelist
function validate( name )
name = tostring( name );
வரி 33 ⟶ 89:
function errorcomment( content, hidden )
if hidden then
return substitute( cfg.message_list['
else
return substitute( cfg.message_list['
end
end
வரி 43 ⟶ 99:
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id,
local error_state = cfg.error_conditions[ error_id ];
prefix = prefix or "";
வரி 57 ⟶ 113:
local message = error_state.message;
message = substitute( message, arguments );
message = wikiescape(message) .. " ([[" .. cfg.message_list['help page link'] ..
வரி 91 ⟶ 142:
[']'] = ']',
['{'] = '{',
['|'] = '|',
['}'] = '}' } );
return text;
வரி 289 ⟶ 340:
if str:sub(1,1) == "'" then str = "<span />" .. str; end
if str:sub(-1,-1) == "'" then str = str .. "<span />"; end
-- Remove newlines as they break italics.
return str:gsub( '\n', ' ' );
end
வரி 458 ⟶ 511:
end
-- Gets
function
local
local i = 1;
local last;
while true do
last = selectone( args, cfg.argument_map[list_name .. '-Last'], 'redundant_parameters', i );
if ( last and "" < last ) then -- just in case someone passed in an empty parameter
first = selectone( args,
mask = selectone( args,
}
else
break;
வரி 550 ⟶ 531:
i = i + 1;
end
return
end
வரி 617 ⟶ 598:
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
local value = nil;
local selected = '';
local error_list = {};
if index ~= nil then index = tostring(index); end
-- Handle special case of "#" replaced by empty string
if index == '1' then
for _, v in ipairs( possible ) do
v = v:gsub( "#", "" );
if args[v] ~= nil then
if value ~= nil and selected ~= v then
table.insert( error_list, v );
else
value = args[v];
selected = v;
end
end
end
end
for _, v in ipairs( possible ) do
if index ~= nil then
v = v:gsub( "#", index );
end
if args[v] ~= nil then
if value ~= nil then
வரிசை 632:
end
end
if #error_list > 0 then
local error_str = "";
வரிசை 656:
]]
function citation0( config, args)
--[[
Load Input Parameters
The argment_wrapper facillitates the mapping of multiple
aliases to single internal variable.
]]
local A = argument_wrapper( args );
local i
local PPrefix =
local PPPrefix =
if ( nil ~=
-- Pick out the relevant fields from the arguments. Different citation templates
-- define different field names for the same underlying things.
local Authors =
local a =
local Coauthors =
local Others =
local Editors =
local e =
local Year =
local PublicationDate =
local OrigYear =
local Date =
local LayDate =
------------------------------------------------- Get title data
local Title = A['Title'];
local BookTitle =
local Conference =
local TransTitle =
local TitleNote =
local TitleLink =
local Chapter =
local ChapterLink =
local TransChapter =
local TitleType =
local ArchiveURL =
local URL =
local ChapterURL = A['ChapterURL'];
local ConferenceURL =
local Periodical =
if ( config.CitationClass == "encyclopaedia" ) then
if (
if (
Chapter = Title
TransChapter = TransTitle
வரி 710 ⟶ 711:
TransTitle = nil
end
end
end
local
local Volume = A['Volume'];
local Issue = A['Issue'];
local Position = nil
local Page, Pages, At, page_type;
Page = A['Page'];
Pages = hyphentodash(
At = A['At'];
if Page ~= nil then
Page = Page .. " " .. seterror('extra_pages');
end
elseif Pages ~= nil then
if At ~= nil then
Pages = Pages .. " " .. seterror('extra_pages');
At = nil;
end
end
local Edition =
local PublicationPlace =
local Place =
if PublicationPlace == nil and Place ~= nil then
PublicationPlace = Place;
வரி 739 ⟶ 744:
if PublicationPlace == Place then Place = nil end
local PublisherName =
local SubscriptionRequired =
local Via =
local AccessDate =
local ArchiveDate =
local Agency =
local DeadURL =
local Language =
local Format =
local Ref =
local DoiBroken =
local ID =
local ASINTLD =
local IgnoreISBN =
local ID_list = extractids( args );
local Quote =
local PostScript =
local LaySummary =
local LaySource =
local Transcript =
local TranscriptURL =
local sepc =
local LastAuthorAmp =
local no_tracking_cats =
if ( config.CitationClass == "journal" ) then
if (URL == nil or URL == "") then
if (ID_list['PMC'] ~= nil) then
local Embargo =
if Embargo ~= nil then
local lang = mw.getContentLanguage();
வரி 801 ⟶ 805:
-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
if config.CitationClass == "episode" then
local AirDate =
local SeriesLink =
local Season =
local SeriesNumber =
local Network =
local Station =
local s = {}
if Issue ~= nil then table.insert(s, cfg.message_list["episode"] .. " " .. Issue) Issue = nil end
வரி 821 ⟶ 825:
TitleLink = SeriesLink
TransTitle = nil
local Sep =
Series = table.concat(s, Sep)
ID = table.concat(n, Sep)
வரி 880 ⟶ 884:
end
if last ~= nil and first ~= nil then
table.insert( OCinSauthors, last ..
elseif last ~= nil then
table.insert( OCinSauthors, last );
வரி 923 ⟶ 927:
-- various parts of the citation, but only when they are non-nil.
if ( Authors == nil ) then
local Maximum = tonumber(
-- Preserve old-style implicit et al.
வரி 934 ⟶ 938:
local control = {
sep =
namesep = (
format =
maximum = Maximum,
lastauthoramp = LastAuthorAmp
வரி 951 ⟶ 955:
local EditorCount
if ( Editors == nil ) then
local Maximum = tonumber(
-- Preserve old-style implicit et al.
வரி 962 ⟶ 966:
local control = {
sep =
namesep = (
format =
maximum = Maximum,
lastauthoramp = LastAuthorAmp
வரி 994 ⟶ 998:
Date = Year
if ( Date ~= nil and Date ~="") then
local Month =
if ( Month ~= nil and Month ~= "") then
Date = Month .. " " .. Date
local Day =
if ( Day ~= nil ) then Date = Day .. " " .. Date end
else Month = ""
வரி 1,057 ⟶ 1,061:
end
if ( TransTitle and "" < TransTitle ) then TransTitle = "
if ( TransChapter and "" < TransChapter ) then TransChapter = "
-- Format chapter / article title
வரி 1,065 ⟶ 1,069:
if ( Periodical and "" < Periodical ) and (Title ~= nil and Title ~= "" )
then
Chapter =
else
Chapter =
end
else
வரி 1,109 ⟶ 1,113:
Title = "[[" .. TitleLink .. "|" .. Title .. "]]" end
if ( Periodical and "" < Periodical ) then
Title =
elseif ( config.CitationClass == "web"
or config.CitationClass == "news"
or config.CitationClass == "pressrelease" ) and
Chapter == "" then
Title =
else
Title =
end
else
வரி 1,139 ⟶ 1,143:
if ( Place ~= nil and Place ~= "" ) then
if sepc == '.' then
Place = " " .. substitute( cfg.message_list['written'],
else
Place = " " .. substitute( cfg.message_list['written']:lower(),
end
else
வரி 1,159 ⟶ 1,163:
if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
if ( nil == Position and "" ~= Position ) then
local Minutes =
if ( nil ~= Minutes ) then
Position = " " .. Minutes .. " " .. cfg.message_list['minutes'];
else
local Time =
if ( nil ~= Time ) then
local TimeCaption =
if TimeCaption == nil then
TimeCaption = cfg.message_list['event'];
வரி 1,218 ⟶ 1,222:
TitleNote = sepc .. " " .. TitleNote else TitleNote = "" end
if ( Language ~= nil and Language ~="" ) then
Language = "
if ( Edition ~= nil and Edition ~="" ) then
Edition = "
if ( Volume ~= nil and Volume ~="" )
then
வரி 1,239 ⟶ 1,243:
if ( Date ~= nil ) then Date = Date else Date = "" end
if ( Via ~= nil and Via ~="" ) then
Via = "
if ( AccessDate ~= nil and AccessDate ~="" )
then local retrv_text = " " .. cfg.message_list['retrieved']
if (sepc ~= ".") then retrv_text = retrv_text:lower() end
AccessDate = '<span class="reference-accessdate">' .. sepc
.. substitute( retrv_text,
else AccessDate = "" end
if ( SubscriptionRequired ~= nil and
வரி 1,273 ⟶ 1,277:
end
Quote = sepc .."
PostScript = ""
else
வரி 1,282 ⟶ 1,286:
local Archived
if ( nil ~= ArchiveURL and "" ~= ArchiveURL ) then
if ( ArchiveDate
ArchiveDate =
end
if ( "no" == DeadURL ) then
if (sepc ~= ".") then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( cfg.message_list['
{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
if OriginalURL == nil or OriginalUrl == '' then
Archived = Archived .. " " .. seterror('
end
else
if OriginalURL ~= nil and OriginalURL ~= '' then
if (sepc
Archived =
{ externallink( OriginalURL, cfg.message_list['original'] ), ArchiveDate } );
else
if (sepc
Archived =
end
end
வரி 1,355 ⟶ 1,354:
if ( PublicationDate and PublicationDate ~="" ) then
if Publisher ~= '' then
Publisher = Publisher .. ", " .. substitute( cfg.message_list['published'],
else
Publisher = PublicationDate;
வரி 1,365 ⟶ 1,364:
else
if ( PublicationDate and PublicationDate ~="" ) then
PublicationDate = " (" .. substitute( cfg.message_list['published'],
else
PublicationDate = ""
வரி 1,384 ⟶ 1,383:
if ( Periodical ~= nil and Periodical ~="" ) then
if ( Title and Title ~= "" ) or ( TitleNote and TitleNote ~= "" ) then
Periodical = sepc .. "
else
Periodical =
end
else Periodical = "" end
வரி 1,417 ⟶ 1,416:
if ( "" ~= Authors ) then
if (Coauthors ~= "")
then Authors = Authors .. A['AuthorSeparator'] .. "
end
if ( "" ~= Date )
வரி 1,531 ⟶ 1,530:
if #z.message_tail ~= 0 then
text = text .. " ";
for i,v in ipairs( z.message_tail ) do
if v[1] ~= nil and v[1] ~= "" then
வரிசை 1,542:
end
if no_tracking_cats ==
for _, v in ipairs( z.error_categories ) do
text = text .. '[[Category:' .. v ..']]';
வரிசை 1,601:
return z
| |||