Module:Citation/CS1/Identifiers:修订间差异

求闻百科,共笔求闻
添加的内容 删除的内容
(修改自此处;原许可:CC BY-SA 3.0[网站升级迁移])
 
(已保护“Module:Citation/CS1/Identifiers”([编辑=仅允许裁决委员](无限期)[移动=仅允许裁决委员](无限期)))
 

(未显示7个用户的19个中间版本)

第2行: 第2行:
]]
]]


local is_set, in_array, set_error, select_one, add_maint_cat, substitute, make_wikilink, is_valid_date_from_a_point;
local is_set, in_array, wrap_style; -- functions in Module:Citation/CS1/Utilities
-- functions in Module:Citation/CS1/Utilities or Module:Citation/CS1/Date_validation
local append_error, set_error, throw_error, select_one, add_maint_cat; -- functions in Module:Citation/CS1/Error
local make_internal_link; -- functions in Module:Citation/CS1/Links

local z; -- table of tables defined in Module:Citation/CS1/Utilities
local is_valid_date_from_a_point; -- functions in Module:Citation/CS1/Date_validation


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 '';



--============================<< H E L P E R F U N C T I O N S >>============================================
--============================<< H E L P E R F U N C T I O N S >>============================================
第26行: 第23行:
url_string = mw.uri.encode( url_string );
url_string = mw.uri.encode( url_string );
end
end
ext_link = mw.ustring.format( '[%s%s%s \<span title\=\"%s\"\>%s%s%s\<\/span\>]',
ext_link = mw.ustring.format( '[%s%s%s <span title=\"%s\">%s%s%s</span>]',
options.prefix, url_string, options.suffix or "",
options.prefix, url_string, options.suffix or "",
options.link, options.label, options.separator or "&nbsp;",
options.link, options.label, options.separator or "&nbsp;",
第32行: 第29行:
);
);
if is_set (options.access) then
if is_set (options.access) then
ext_link = substitute (cfg.presentation['access-signal'], {ext_link, cfg.presentation[options.access]}); -- add the free-to-read / paywall lock
ext_link = wrap_style ('access-signal', {ext_link, cfg.presentation[options.access]}); -- add the free-to-read / paywall lock
end
end
return ext_link;
return ext_link;
第42行: 第39行:
]]
]]
local function internal_link_id(options)
local function internal_link_id(options)
return mw.ustring.format( '[[%s%s%s|\<span title\=\"%s\"\>%s\<\/span\>%s%s]]',
return mw.ustring.format( '[[%s%s%s|<span title=\"%s\">%s</span>%s%s]]',
options.prefix, options.id, options.suffix or "",
options.prefix, options.id, options.suffix or "",
options.link, options.label, options.separator or "&nbsp;",
options.link, options.label, options.separator or "&nbsp;",
第449行: 第446行:
id = id, separator = handler.separator, encode = handler.encode});
id = id, separator = handler.separator, encode = handler.encode});
else
else
text = mw.ustring.format( "<span title\=\"%s\"\>%s%s%s\<\/span\>",
text = mw.ustring.format( "<span title=\"%s\">%s%s%s</span>",
handler.link, handler.label, handler.separator,
handler.link, handler.label, handler.separator,
mw.text.nowiki (id)
mw.text.nowiki (id)
第462行: 第459行:
--[[--------------------------< C S B N >----------------------------------------------------------------------
--[[--------------------------< C S B N >----------------------------------------------------------------------
判断CSBN的合法性及产生指向豆瓣网的链接。
判断CSBN的合法性及产生指向豆瓣网的链接。
CSBN格式参考《谈谈国家统一书号与国际标准书号》。
CSBN格式参考《谈谈国家统一书号与国际标准书号》及最新实例
]]
]]

local function csbn_checkCatNum (cat)
local cat_num = tonumber(cat)
return not (cat_num <=0 or cat_num >17) -- 若分类号取值不在1-17范围内,则不合法。
end


local function csbn (id)
local function csbn (id)
第470行: 第472行:
local invalid = false;
local invalid = false;
id = id:gsub ("%-","·");
id = id:gsub ("%-","·");
if (nil == id:match ("^[1-9]%d?%d%d%d·%d+$")) then
if (nil == id:match ("^[1-9]%d?%d?%d?%d%d%d·%d+$")) then
-- CSBN由三部分组成,第一部分为中国人民大学图书分类法代号,取值1-17;
-- CSBN由三部分组成,第一部分为中国人民大学图书分类法代号,取值1-17(前缀不补零);
-- 第二部分为出版社代号,三位;第三部分为种次号,取值不限。
-- 第二部分为出版社代号,三到五位;第三部分为种次号,取值不限。
-- 二、三部分间有小圆点;若取值不合该格式,则不合法。
-- 二、三部分间有小圆点;若取值不合该格式,则不合法。
-- 此外,虽然小圆点用"-"取代不合,但站内误用较多,这里兼容
-- 此外,虽然小圆点用"-"取代不合规定,但误用较多,亦有出版物采用,故兼容。
invalid = true;
invalid = true;
else
else
local catNumOk = nil
local category = id:match ("^([1-9]%d?)%d%d%d·%d+$");
local cat_num = tonumber (category);
local category
category = id:match ("^([1-9]%d-)%d?%d?%d%d%d·%d+$"); -- Lua无法非贪婪特定部分或指定重复次数,分别检查
if (cat_num <=0 or cat_num >17) then
if (nil == catNumOk and nil ~= category) then catNumOk = csbn_checkCatNum(category) end
-- 若分类号取值不在1-17范围内,则不合法。
category = id:match ("^([1-9]%d-)%d?%d%d%d·%d+$");
invalid = true;
if (nil == catNumOk and nil ~= category) then catNumOk = csbn_checkCatNum(category) end
end
category = id:match ("^([1-9]%d-)d%d%d·%d+$");
if (nil == catNumOk and nil ~= category) then catNumOk = csbn_checkCatNum(category) end
invalid = not catNumOk;
end
end
-- 豆瓣网以连接号取代小圆点,故替换之。
-- 豆瓣网以连接号取代小圆点,故替换之。
第521行: 第526行:
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
if is_set(inactive_year) then
table.insert( z.error_categories, "自" .. inactive_year .. "年含有不活躍DOI的頁面" );
set_error('doi_inactive_dated', {inactive_year});
else
else
table.insert( z.error_categories, "含有不活躍DOI的頁面" ); -- when inactive doesn't contain a recognizable year
set_error('doi_inactive'); -- when inactive doesn't contain a recognizable year
end
end
inactive = " (" .. cfg.messages['inactive'] .. " " .. inactive .. ")"
inactive = " (" .. cfg.messages['inactive'] .. " " .. inactive .. ")"
第956行: 第961行:


local function pmc(id, embargo)
local function pmc(id, embargo)
local test_limit = 10000000; -- update this value as PMCs approach
local test_limit = 12000000; -- 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
第984行: 第989行:
text = table.concat ( -- still embargoed so no external link
text = table.concat ( -- still embargoed so no external link
{
{
make_wikilink (handler.link, handler.label),
make_internal_link (handler.link, handler.label),
handler.separator,
handler.separator,
id,
id,
第1,006行: 第1,011行:


local function pmid(id)
local function pmid(id)
local test_limit = 35400000; -- update this value as PMIDs approach
local test_limit = 40000000; -- update this value as PMIDs approach
local handler = cfg.id_handlers['PMID'];
local handler = cfg.id_handlers['PMID'];
local err_cat = ''; -- presume that PMID is valid
local err_cat = ''; -- presume that PMID is valid
第1,034行: 第1,039行:


local function s2cid (id, access)
local function s2cid (id, access)
local test_limit = 235000000;
local test_limit = 300000000;
local handler = cfg.id_handlers['S2CID'];
local handler = cfg.id_handlers['S2CID'];
local err_cat = ''; -- presume that S2CID is valid
local err_cat = ''; -- presume that S2CID is valid
第1,158行: 第1,163行:
table.insert( new_list, {handler.label, internal_link_id( handler ) } );
table.insert( new_list, {handler.label, internal_link_id( handler ) } );
elseif handler.mode ~= 'manual' then
elseif handler.mode ~= 'manual' then
error( cfg.messages['unknown_ID_mode'] );
throw_error( 'unknown_ID_mode' );
elseif k == 'ARXIV' then
elseif k == 'ARXIV' then
table.insert( new_list, {handler.label, arxiv( v, options.Class ) } );
table.insert( new_list, {handler.label, arxiv( v, options.Class ) } );
第1,221行: 第1,226行:
table.insert( new_list, {handler.label, zbl( v ) } );
table.insert( new_list, {handler.label, zbl( v ) } );
else
else
error( cfg.messages['unknown_manual_ID'] );
throw_error( 'unknown_manual_ID' );
end
end
end
end
第1,273行: 第1,278行:
if is_set(access_level) then
if is_set(access_level) then
if not in_array (access_level:lower(), 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 ) } );
append_error( 'invalid_param_val', {access_param, access_level});
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', {k_lower}, true ) } );
append_error( 'param_access_requires_param', {k_lower});
end
end
if is_set(access_level) then
if is_set(access_level) then
第1,296行: 第1,301行:
]]
]]


local function set_selected_modules (cfg_table_ptr, utilities_page_ptr, validation_page_ptr)
local function set_selected_modules (cfg_table_ptr, utilities_page_ptr, error_page_ptr, links_page_ptr, validation_page_ptr)
cfg = cfg_table_ptr;
cfg = cfg_table_ptr;


is_set = utilities_page_ptr.is_set; -- import functions from select Module:Citation/CS1/Utilities module
is_set = utilities_page_ptr.is_set;
in_array = utilities_page_ptr.in_array;
in_array = utilities_page_ptr.in_array;
set_error = utilities_page_ptr.set_error;
wrap_style = utilities_page_ptr.wrap_style;
select_one = utilities_page_ptr.select_one;
append_error = error_page_ptr.append_error;
add_maint_cat = utilities_page_ptr.add_maint_cat;
set_error = error_page_ptr.set_error;
substitute = utilities_page_ptr.substitute;
throw_error = error_page_ptr.throw_error;
make_wikilink = utilities_page_ptr.make_wikilink;
select_one = error_page_ptr.select_one;
add_maint_cat = error_page_ptr.add_maint_cat;
make_internal_link = links_page_ptr.make_internal_link;
is_valid_date_from_a_point = validation_page_ptr.is_valid_date_from_a_point;
is_valid_date_from_a_point = validation_page_ptr.is_valid_date_from_a_point;
z = utilities_page_ptr.z; -- table of tables in Module:Citation/CS1/Utilities
end
end