添加的内容 删除的内容
(修改自此处;原许可:CC BY-SA 3.0[网站升级迁移]) |
小 (已保护“Module:Citation/CS1/Identifiers”([编辑=仅允许裁决委员](无限期)[移动=仅允许裁决委员](无限期))) |
||
(未显示7个用户的19个中间版本) | |||
第2行: | 第2行: | ||
]] |
]] |
||
local is_set, in_array, |
local is_set, in_array, wrap_style; -- functions in Module:Citation/CS1/Utilities |
||
local append_error, set_error, throw_error, select_one, add_maint_cat; -- functions in Module:Citation/CS1/Error |
|||
⚫ | |||
local |
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 |
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 " ", |
options.link, options.label, options.separator or " ", |
||
第32行: | 第29行: | ||
); |
); |
||
if is_set (options.access) then |
if is_set (options.access) then |
||
ext_link = |
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| |
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 " ", |
options.link, options.label, options.separator or " ", |
||
第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 |
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) |
|||
⚫ | |||
⚫ | |||
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- |
-- CSBN由三部分组成,第一部分为中国人民大学图书分类法代号,取值1-17(前缀不补零); |
||
-- 第二部分为出版社代号,三位;第三部分为种次号,取值不限。 |
-- 第二部分为出版社代号,三到五位;第三部分为种次号,取值不限。 |
||
-- 二、三部分间有小圆点;若取值不合该格式,则不合法。 |
-- 二、三部分间有小圆点;若取值不合该格式,则不合法。 |
||
-- 此外,虽然小圆点用"-"取代不合 |
-- 此外,虽然小圆点用"-"取代不合规定,但误用较多,亦有出版物采用,故兼容。 |
||
invalid = true; |
invalid = true; |
||
else |
else |
||
local catNumOk = nil |
|||
⚫ | |||
local |
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 |
|||
⚫ | |||
category = id:match ("^([1-9]%d-)%d?%d%d%d·%d+$"); |
|||
⚫ | |||
if (nil == catNumOk and nil ~= category) then catNumOk = csbn_checkCatNum(category) end |
|||
⚫ | |||
⚫ | |||
if (nil == catNumOk and nil ~= category) then catNumOk = csbn_checkCatNum(category) end |
|||
⚫ | |||
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 |
||
set_error('doi_inactive_dated', {inactive_year}); |
|||
else |
else |
||
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 = |
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_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 = |
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 = |
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 |
||
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 |
||
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 |
||
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 |
||
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; |
is_set = utilities_page_ptr.is_set; |
||
in_array = utilities_page_ptr.in_array; |
in_array = utilities_page_ptr.in_array; |
||
wrap_style = utilities_page_ptr.wrap_style; |
|||
⚫ | |||
append_error = error_page_ptr.append_error; |
|||
⚫ | |||
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; |
|||
⚫ | |||
⚫ | |||
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; |
||
⚫ | |||
end |
end |
||