Open main menu

Changes

Module:Citation/CS1/Identifiers

1,194 bytes added, 14:28, 18 January 2020
sync doi() from sandbox to fix minor error because same time fixed lua script error in ~/Date validation;
local url_string = options.id;
local ext_link;
local this_wiki_code = cfg.this_wiki_code; -- wikipedia subdomain; 'en' for en.wikipedia.org
local wd_article; -- article title from wikidata
end
-- this_wiki_code = mw.language.getContentLanguage():getCode(); -- get this wikipedia's language code (subdomain)
if string.match (mw.site.server, 'wikidata') then
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '')
if nil =local registrant = id:match("'^10%.([^%s–/]-+)/[^%s–]-[^%.,]$"') or ; -- registrant set when doi must begin has the proper basic form registrant_err_patterns = { -- these patterns are for code ranges that are not supported '^[^1-3]%d%d%d%d%.%d%d*$', -- 5 digits with subcode (0xxxx, 40000+); accecpts: 10000–39999 '10^[^1-3]%d%d%d%d$', -- 5 digits without subcode (0xxxx, 40000+); accecpts: 10000–39999 '^[^1-9]%d%d%d%.%d%d*$', must contain a fwd slash -- 4 digits with subcode (0xxx); accecpts: 1000–9999 '^[^1-9]%d%d%d$', must not contain spaces -- 4 digits without subcode (0xxx); accecpts: 1000–9999 '^%d%d%d%d%d%d+', -- 6 or endashesmore digits '^%d%d?%d?$', and must not end -- less than 4 digits without subcode (with period or commasubcode is legitimate) '^5555$', -- test registrant will never resolve } if registrant then -- when doi has proper form idfor i, pattern in ipairs (registrant_err_patterns) do -- spin through error patterns if registrant: match (pattern) then -- to validate registrant codes cat = '^10' ..5555set_error ('bad_doi') then ; -- test when found, mark this doi will never resolveas bad break; -- and done end end else cat = ' ' .. set_error ('bad_doi'); -- invalid directory or malformed
end
if isbn_str:match( "^97[89]%d*$" ) == nil then
return false, 'invalid prefix'; -- fail when isbn13 does not begin with 978 or 979
end
if isbn_str:match ('^9790') then
return false, 'invalid group id'; -- group identifier '0' is reserved to ismn
end
return is_valid_isxn_13 (isbn_str), 'checksum';
function as they are directly rendered as free without using an additional parameter.
access-level values must match the case used in cfg.keywordskeywords_lists['id-access'] (lowercase unless there is some special reason for something else)
]]
local access_level = args[access_param]; -- get the assigned value if there is one
if is_set (access_level) then
if not in_array (access_level, cfg.keywordskeywords_lists['id-access']) then -- exact match required
table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );
access_level = nil; -- invalid so unset
table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k:lower()}, true ) } ); -- param name is uppercase in cfg.id_handlers (k); lowercase for error message
end
id_accesses_list[k] = cfg.keywords_xlate[access_level]; -- get translated keyword
end
end