Module:Citation/CS1: திருத்தங்களுக்கு இடையிலான வேறுபாடு
உள்ளடக்கம் நீக்கப்பட்டது உள்ளடக்கம் சேர்க்கப்பட்டது
Fix via/subscription bug |
Subscription/Registration help; Via cat fix; identifier protocol relative urls; PMC identifier fix; iso639-1 support; |
||
வரிசை 216:
label=handler.label , prefix="//www.amazon."..domain.."/dp/",id=id,
encode=handler.encode, separator = handler.separator})
end
--[[
Formats a PMC and checks for embargoed articles. The embargo parameter takes a date for a value. If the embargo date is in the futue
the PMC identifier will not be linked to the article. If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].link.
The {{citation/core}} version of {{cite journal}} links the citation title (if url parameter is empty) when embargo date is in the past
or when embargo parameter is missing or empty. That behavior is inconsistent with the behavior of other identifiers used in CS1 and is
not supported here.
]]
function pmc(id, embargo)
local handler = cfg.id_handlers['PMC'];
local text;
if is_set(embargo) then
local lang = mw.getContentLanguage();
local good1, embargo_date, good2, todays_date;
good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
good2, todays_date = pcall( lang.formatDate, lang, 'U' );
if good1 and good2 and tonumber( embargo_date ) < tonumber( todays_date ) then --if embargo date is in the past then
text = externallinkid({link = handler.link, label = handler.label, --ok to link to article
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
else
text="[[" .. handler.link .. "|" .. handler.label .. "]]:" .. handler.separator .. id; --still embargoed so no external link
end
else
text = externallinkid({link = handler.link, label = handler.label, --no embargo date, ok to link to article
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
end
return text
end
வரி 445 ⟶ 478:
local lang = mw.getContentLanguage();
local good, result;
good, result = pcall( lang.formatDate, lang, 'Y', str );
if good then
return result;
else
--
local seasons={"winter", "spring", "summer", "fall", "autumn"};
local date_string_split=mw.text.split (str, "[%s%-/–]"); -- split date string into parts; white space, hyphen, forward slash, and ndash are allowed separators
local has_season=false;
for n,season_value in ipairs(seasons) do -- for each season ...
for n,split_value in ipairs(date_string_split) do -- ... loop through date string values
if split_value == season_value then -- does the split value match the season value?
if has_season==false then -- found one. if this one is the first we've found ...
has_season=true; -- ... remember that we found a season
end
elseif has_season==true then -- if split_value isn't a season, and we've previously found a season ...
num = tonumber( split_value ); -- ... convert current split value to a number if we can
if num ~= nil and num > 0 and num < 2100 and num == math.floor(num) then -- if it's a suitable number
return tostring( num ); -- return it as a string
end -- if num
end -- if string.find
end -- for split value loop
end -- season value loop
end -- if good
end -- if num
end -- selectyear
-- Attempts to convert names to initials.
வரி 588 ⟶ 639:
elseif k == 'OL' then
table.insert( new_list, {handler.label, openlibrary( v ) } );
elseif k == 'PMC' then
table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
elseif k == 'ISBN' then
local ISBN = internallinkid( handler );
வரி 863 ⟶ 916:
local ASINTLD = A['ASINTLD'];
local IgnoreISBN = A['IgnoreISBN'];
local Embargo = A['Embargo'];
local ID_list = extractids( args );
வரி 878 ⟶ 932:
local use_lowercase = ( sepc ~= '.' );
local this_page = mw.title.getCurrentTitle(); --Also used for COinS and for language
if not is_set(no_tracking_cats) then
வரி 885 ⟶ 939:
no_tracking_cats = "true";
break;
end
end
வரி 1,281 ⟶ 1,315:
At = At .. Section .. Inset;
end
--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them. If a match is found,
use that value; if not, then use the value that was provided with the language parameter.
Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
]]
if is_set (Language) then
local name = cfg.iso639_1[Language:lower()]; -- get the language name if Language parameter has a valid iso 639-1 code
if nil == name then
Language=" " .. wrap( 'language', Language ); -- no match, use parameter's value
else
if 0 == this_page.namespace and 'en' ~= Language:lower() then --found a match; is this page main / article space and English not the language?
Language=" " .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' ); -- in main space and not English: categorize
else
Language=" " .. wrap( 'language', name ); --not in mainspace or language is English so don't categorize
end
end
else
Language=""; -- language not specified so make sure this is an empty string;
end
Others = is_set(Others) and (sepc .. " " .. Others) or "";
TitleType = is_set(TitleType) and (" (" .. TitleType .. ")") or "";
TitleNote = is_set(TitleNote) and (sepc .. " " .. TitleNote) or "";
Edition = is_set(Edition) and (" " .. wrap( 'edition', Edition )) or "";
Issue = is_set(Issue) and (" (" .. Issue .. ")") or "";
வரி 1,300 ⟶ 1,353:
------------------------------------ totally unrelated data
--[[
behind a registration or paywall. So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
Subscription implies paywall; Registration does not. If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
]]
if is_set(Via) then
Via = " " .. wrap( 'via', Via );
end
if is_set(SubscriptionRequired) then
SubscriptionRequired = sepc .. " " .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
elseif is_set(RegistrationRequired) then
SubscriptionRequired = sepc .. " " .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
வரி 1,321 ⟶ 1,377:
if is_set(ID) then ID = sepc .." ".. ID; end
ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );
if is_set(URL) then
| |||