Modul:Citation/CS1/Identifiers: Pabidaan ralatan

Konten dihapus Konten ditambahkan
Uzume (pandir | sumbangan)
avoid bumping expensive count
Rachmat04 (pandir | sumbangan)
sKadada kasimpulan babakan
 
Baris 1:
 
local identifiers = {};
 
 
--[[--------------------------< F O R W A R D D E C L A R A T I O N S >--------------------------------------
Baris 8 ⟶ 11:
 
local cfg; -- table of configuration tables that are defined in Module:Citation/CS1/Configuration
 
local wd_int_lang = (mw.site.server:match ('wikidata') and mw.getCurrentFrame():preprocess('{{int:lang}}')) or '';
 
 
Baris 23 ⟶ 24:
local url_string = options.id;
local ext_link;
local this_wiki_code; -- wikipedia subdomain; 'en' for en.wikipedia.org
local wd_article; -- article title from wikidata
if options.encode == true or options.encode == nil then
url_string = mw.uri.encode( url_string );
end
 
ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or "", mw.text.nowiki(options.id));
if is_set(options.access) then
ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].classext_link, cfg.presentation[options.access].title, ext_link}); -- add the free-to-read / paywall lock
end
 
this_wiki_code = mw.language.getContentLanguage():getCode(); -- get this wikipedia's language code (subdomain)
if string.match (mw.site.server, 'wikidata') then
this_wiki_code = mw.getCurrentFrame():preprocess('{{int:lang}}'); -- on wikidata so use interface language setting instead
end
if is_set (options.q) and mw.wikibase then -- wikibase test here avoids script errors in third party wikis that aren't using mw.wikibase extension
wd_article = mw.wikibase.getSitelink (options.q, this_wiki_code .. 'wiki'); -- fetch article title from wd
if wd_article then
wd_article = table.concat ({':', this_wiki_code, ':', wd_article}); -- make interwiki link if taken from wd; leading colon required
end
end
 
return table.concat ({
make_wikilink (wd_article or options.link, options.label), -- wikidata link or locally specified
options.separator or '&nbsp;',
ext_link
Baris 63 ⟶ 49:
 
local function internal_link_id(options)
local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits); -- translate 'local' digits to Western 0-9
 
return table.concat (
Baris 73 ⟶ 58:
{
options.prefix,
options.id,
id, -- translated to western digits
options.suffix or ''
}),
mw.text.nowiki (options.id)
substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)}) -- bdi tags to prevent Latn script identifiers from being reversed at rtl language wikis
);
); -- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
});
end
Baris 198 ⟶ 183:
where:
<archive> is a string of alpha characters - may be hyphenated; no other punctuation
<class> is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
<date code> is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
first digit of YY for this form can only 9 and 0
Baris 221 ⟶ 206:
local handler = cfg.id_handlers['ARXIV'];
local year, month, version;
local err_cat = false''; -- assume no error message
local text; -- output text
if id:match("^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$") or id:match("^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$") then -- test for the 9108-0703 format w/ & w/o version
Baris 230 ⟶ 215:
if ((not (90 < year or 8 > year)) or (1 > month or 12 < month)) or -- if invalid year or invalid month
((91 == year and 7 > month) or (7 == year and 3 < month)) then -- if years ok, are starting and ending months ok?
err_cat = true' ' .. set_error( 'bad_arxiv' ); -- flag forset error message
end
 
elseif id:match("^%d%d[01]%d%.%d%d%d%d$") or id:match("^%d%d[01]%d%.%d%d%d%dv%d+$") then -- test for the 0704-1412 w/ & w/o version
year, month = id:match("^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$");
Baris 239 ⟶ 223:
if ((7 > year) or (14 < year) or (1 > month or 12 < month)) or -- is year invalid or is month invalid? (doesn't test for future years)
((7 == year) and (4 > month)) then --or -- when year is 07, is month invalid (before April)?
err_cat = true' ' .. set_error( 'bad_arxiv' ); -- flag forset error message
end
 
elseif id:match("^%d%d[01]%d%.%d%d%d%d%d$") or id:match("^%d%d[01]%d%.%d%d%d%d%dv%d+$") then -- test for the 1501- format w/ & w/o version
year, month = id:match("^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$");
Baris 247 ⟶ 230:
month = tonumber(month);
if ((15 > year) or (1 > month or 12 < month)) then -- is year invalid or is month invalid? (doesn't test for future years)
err_cat = true' ' .. set_error( 'bad_arxiv' ); -- flag forset error message
end
 
else
err_cat = true' ' .. set_error( 'bad_arxiv' ); -- notarXiv aid recognizeddoesn't format;match flagany for error messageformat
end
 
text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
err_cat = err_cat and table.concat ({' ', set_error ('bad_arxiv')}) or ''; -- set error message if flag is true
text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
 
if is_set (class) then
textclass = table.concat ({text, ' [[' .. '//arxiv.org/archive/', .. class, .. ' ', .. class, .. ']]'}); -- external link within square brackets, not wikilink
if id:match ('^%d+') then
else
text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'}); -- external link within square brackets, not wikilink
class = ''; -- empty string for concatenation
else
text = table.concat ({text, ' ', set_error ('class_ignored')});
end
end
 
return text .. class;
end
 
Baris 295 ⟶ 273:
local year;
 
local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
access=access});
Baris 340 ⟶ 318:
end
return external_link_id({link = handler.link, label = handler.label, q = handler.q,
prefix=handler.prefix,id=id,separator=handler.separator,
encode=handler.encode, access=handler.access}) .. err_cat;
Baris 357 ⟶ 335:
local matched;
local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
access=handler.access});
Baris 394 ⟶ 372:
local inactive_year = inactive:match("%d%d%d%d") or ''; -- try to get the year portion from the inactive date
if is_set(inactive_year) then
table.insert( z.error_categories, "Pages with DOIs inactive as ofsince " .. inactive_year );
else
table.insert( z.error_categories, "Pages with inactive DOIs" ); -- when inactive doesn't contain a recognizable year
Baris 400 ⟶ 378:
inactive = " (" .. cfg.messages['inactive'] .. " " .. inactive .. ")"
end
text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '')
 
Baris 431 ⟶ 409:
local handler = cfg.id_handlers['HDL'];
local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})
 
Baris 511 ⟶ 489:
local handler = cfg.id_handlers['ASIN'];
return external_link_id({link=handler.link,
label=handler.label, q = handler.q, prefix=handler.prefix .. domain .. "/dp/",
id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end
Baris 598 ⟶ 576:
end
text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
Baris 634 ⟶ 612:
end
return external_link_id({link = handler.link, label = handler.label, q = handler.q,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
Baris 691 ⟶ 669:
end
 
return external_link_id({link = handler.link, label = handler.label, q = handler.q,
prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
Baris 723 ⟶ 701:
end
return external_link_id({link = handler.link, label = handler.label, q = handler.q,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
Baris 730 ⟶ 708:
--[[--------------------------< O C L C >----------------------------------------------------------------------
 
Validate and format an oclc id. https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html
 
]]
Baris 764 ⟶ 741:
end
local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;
 
Baris 785 ⟶ 762:
 
if not is_set (ident) then -- if malformed return an error
return external_link_id({link=handler.link, label=handler.label, q = handler.q,
prefix=handler.prefix .. 'OL',
id=id, separator=handler.separator, encode = handler.encode,
Baris 794 ⟶ 771:
if ( code == "A" ) then
return external_link_id({link=handler.link, label=handler.label, q = handler.q,
prefix=handler.prefix .. 'authors/OL',
id=id, separator=handler.separator, encode = handler.encode,
Baris 801 ⟶ 778:
if ( code == "M" ) then
return external_link_id({link=handler.link, label=handler.label, q = handler.q,
prefix=handler.prefix .. 'books/OL',
id=id, separator=handler.separator, encode = handler.encode,
Baris 808 ⟶ 785:
 
if ( code == "W" ) then
return external_link_id({link=handler.link, label=handler.label, q = handler.q,
prefix=handler.prefix .. 'works/OL',
id=id, separator=handler.separator, encode = handler.encode,
Baris 834 ⟶ 811:
 
local function pmc(id, embargo)
local test_limit = 65000008000000; -- update this value as PMCs approach
local handler = cfg.id_handlers['PMC'];
local err_cat = ''; -- presume that PMC is valid
Baris 868 ⟶ 845:
});
else
text = external_link_id({link = handler.link, label = handler.label, q = handler.q, -- no embargo date or embargo has expired, ok to link to article
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
end
Baris 884 ⟶ 861:
 
local function pmid(id)
local test_limit = 3200000033000000; -- update this value as PMIDs approach
local handler = cfg.id_handlers['PMID'];
local err_cat = ''; -- presume that PMID is valid
Baris 897 ⟶ 874:
end
return external_link_id({link = handler.link, label = handler.label, q = handler.q,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
Baris 930 ⟶ 907:
end
text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
 
Baris 947 ⟶ 924:
local handler = cfg.id_handlers['USENETID'];
 
local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
Baris 983 ⟶ 960:
end
return external_link_id({link = handler.link, label = handler.label, q = handler.q,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
Baris 1.160 ⟶ 1.137:
end
 
 
--[[--------------------------< E X P O R T E D F U N C T I O N S >------------------------------------------
]]
 
return {