در حال ویرایش پودمان:Citation/CS1/Identifiers
این ویرایش را میتوان خنثی کرد. لطفاً تفاوت زیر را بررسی کنید تا تأیید کنید که این چیزی است که میخواهید انجام دهید، سپس تغییرات زیر را ذخیره کنید تا خنثیسازی ویرایش را به پایان ببرید.
نسخهٔ فعلی | متن شما | ||
خط ۱: | خط ۱: | ||
local identifiers = {}; | |||
--[[--------------------------< F O R W A R D D E C L A R A T I O N S >-------------------------------------- | --[[--------------------------< F O R W A R D D E C L A R A T I O N S >-------------------------------------- | ||
خط ۸: | خط ۱۱: | ||
local cfg; -- table of configuration tables that are defined in Module:Citation/CS1/Configuration | 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 ''; | |||
خط ۳۹: | خط ۴۴: | ||
end | end | ||
if is_set (options.q) | if is_set (options.q) then | ||
wd_article = mw.wikibase.getEntity (options.q):getSitelink (this_wiki_code .. 'wiki'); -- fetch article title from wd | wd_article = mw.wikibase.getEntity (options.q):getSitelink (this_wiki_code .. 'wiki'); -- fetch article title from wd | ||
if wd_article then | if wd_article then | ||
خط ۶۱: | خط ۶۶: | ||
local function internal_link_id(options) | local function internal_link_id(options) | ||
return table.concat ( | return table.concat ( | ||
خط ۷۱: | خط ۷۵: | ||
{ | { | ||
options.prefix, | options.prefix, | ||
id, | options.id, | ||
options.suffix or '' | options.suffix or '' | ||
}), | }), | ||
mw.text.nowiki (options.id) | |||
); | ); | ||
}); | }); | ||
end | end | ||
خط ۲۸۱: | خط ۲۸۵: | ||
1–4 must be digits and must represent a year in the range of 1000 – next year | 1–4 must be digits and must represent a year in the range of 1000 – next year | ||
5 must be a letter | 5 must be a letter | ||
6 must be letter, ampersand, or dot (ampersand cannot directly precede a dot; &. ) | |||
7–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &. ) | |||
9–18 must be letter, digit, or dot | 9–18 must be letter, digit, or dot | ||
19 must be a letter or dot | 19 must be a letter or dot | ||
خط ۲۹۹: | خط ۳۰۴: | ||
err_type = 'length'; | err_type = 'length'; | ||
else | else | ||
year = id:match ("^(%d%d%d%d)[%a][% | year = id:match ("^(%d%d%d%d)[%a][%a&%.][%a&%.%d][%a&%.%d][%a%d%.]+[%a%.]$") -- | ||
if not year then -- if nil then no pattern match | if not year then -- if nil then no pattern match | ||
err_type = 'value'; -- so value error | err_type = 'value'; -- so value error | ||
خط ۳۹۰: | خط ۳۹۵: | ||
if is_set(inactive) then | if is_set(inactive) then | ||
local inactive_year = inactive:match("%d%d%d%d") or ''; -- try to get the year portion from the inactive date | 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 since " .. inactive_year ); | |||
if is_set (inactive_year) then | |||
else | else | ||
table.insert( z.error_categories, "Pages with inactive DOIs" ); -- when inactive doesn't contain a recognizable year | |||
end | end | ||
inactive = " (" .. cfg.messages['inactive'] .. " " .. inactive .. ")" | |||
inactive = " (" .. cfg.messages['inactive'] .. | |||
end | end | ||
text = external_link_id({link = handler.link, label = handler.label, q = handler.q, | 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 '') | prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '') | ||
if nil == id:match("^10%.[^%s–]-/[^%s–]-[^%.,]$") | if nil == id:match("^10%.[^%s–]-/[^%s–]-[^%.,]$") then -- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma | ||
cat = ' ' .. set_error( 'bad_doi' ); | |||
end | end | ||
خط ۷۴۵: | خط ۷۳۲: | ||
--[[--------------------------< O C L C >---------------------------------------------------------------------- | --[[--------------------------< O C L C >---------------------------------------------------------------------- | ||
Validate and format an oclc id. | Validate and format an oclc id. https://www.oclc.org/batchload/controlnumber.en.html | ||
]] | ]] | ||
خط ۸۴۹: | خط ۸۳۵: | ||
local function pmc(id, embargo) | local function pmc(id, embargo) | ||
local test_limit = | local test_limit = 6500000; -- update this value as PMCs approach | ||
local handler = cfg.id_handlers['PMC']; | local handler = cfg.id_handlers['PMC']; | ||
local err_cat = ''; -- presume that PMC is valid | local err_cat = ''; -- presume that PMC is valid | ||
خط ۹۷۶: | خط ۹۶۲: | ||
A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional | A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional | ||
]] | ]] | ||
خط ۹۸۵: | خط ۹۶۷: | ||
local function zbl (id) | local function zbl (id) | ||
local handler = cfg.id_handlers['ZBL']; | local handler = cfg.id_handlers['ZBL']; | ||
local id_num; | |||
local err_cat = ''; | local err_cat = ''; | ||
id_num = id:match ('^[Zz][Bb][Ll](.*)$'); -- identifier with zbl prefix; extract identifier | |||
add_maint_cat (' | |||
if is_set (id_num) then | |||
err_cat = ' ' .. set_error( 'bad_zbl' ); -- | add_maint_cat ('zbl_format'); | ||
else -- plain number without zbl prefix | |||
id_num = id; -- if here id does not have prefix | |||
end | |||
if id_num:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then | |||
id = id_num; -- id matches pattern | |||
else | |||
err_cat = ' ' .. set_error( 'bad_zbl' ); -- set an error message | |||
end | end | ||
خط ۱٬۱۲۱: | خط ۱٬۱۱۲: | ||
Parameters which have a predefined access level (e.g. arxiv) do not use this | Parameters which have a predefined access level (e.g. arxiv) do not use this | ||
function as they are directly rendered as free without using an additional parameter. | function as they are directly rendered as free without using an additional parameter. | ||
]] | ]] | ||
خط ۱٬۱۲۹: | خط ۱٬۱۱۸: | ||
local id_accesses_list = {}; | local id_accesses_list = {}; | ||
for k, v in pairs( cfg.id_handlers ) do | for k, v in pairs( cfg.id_handlers ) do | ||
local access_param = v.custom_access; | local access_param = v.custom_access; | ||
local k_lower = string.lower(k); | |||
if is_set(access_param) then | if is_set(access_param) then | ||
local access_level = args[access_param]; | local access_level = args[access_param]; | ||
if is_set (access_level) then | if is_set(access_level) then | ||
if not in_array (access_level, cfg.keywords['id-access']) then | if not in_array (access_level:lower(), cfg.keywords['id-access']) then | ||
table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } ); | table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } ); | ||
access_level = nil; | access_level = nil; | ||
end | end | ||
if not is_set(id_list[k]) then | if not is_set(id_list[k]) then | ||
table.insert( z.message_tail, { set_error( 'param_access_requires_param', { | table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k_lower}, true ) } ); | ||
end | |||
if is_set(access_level) then | |||
access_level = access_level:lower(); | |||
end | end | ||
id_accesses_list[k] = access_level; | id_accesses_list[k] = access_level; | ||
خط ۱٬۱۶۸: | خط ۱٬۱۶۱: | ||
end | end | ||
return { | return { |