Module:Citation/CS1/Identifiers: Difference between revisions
Content deleted Content added
m 45 revisions imported: Country infobox |
sync from sandbox; |
||
Line 8:
local cfg; -- table of configuration tables that are defined in Module:Citation/CS1/Configuration
Line 283 ⟶ 281:
1–4 must be digits and must represent a year in the range of 1000 – next year
5 must be a letter
9–18 must be letter, digit, or dot
19 must be a letter or dot
Line 302 ⟶ 299:
err_type = 'length';
else
year = id:match ("^(%d%d%d%d)[%a][%
if not year then -- if nil then no pattern match
err_type = 'value'; -- so value error
Line 393 ⟶ 390:
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_month, good;
if is_set(inactive_year) then▼
table.insert( z.error_categories, "Pages with DOIs inactive as of " .. inactive_year );▼
▲ if is_set (inactive_year) then
if 4 < inactive:len() then -- inactive date has more than just a year (could be anything)
local lang_obj = mw.getContentLanguage(); -- get a language object for this wiki
good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive); -- try to get the month name from the inactive date
inactive_month = nil; -- something went wrong so make sure this is unset
end▼
else
inactive_year = nil; -- |doi-broken= has something but it isn't a date
table.insert( z.error_categories, "Pages with inactive DOIs" ); -- when inactive doesn't contain a recognizable year▼
end
inactive = " (" .. cfg.messages['inactive'] .. " " .. inactive .. ")" ▼
if is_set(inactive_year) and is_set (inactive_month) then
table.insert( z.error_categories, 'Pages with DOIs inactive as of ' .. inactive_year .. ' ' .. inactive_month); -- use inactive month in category name
▲ table.insert( z.error_categories,
end
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 '')
if nil == id:match("^10%.[^%s–]-/[^%s–]-[^%.,]$")
id: match ('^10.5555') then -- test doi will never resolve
cat = ' ' .. set_error (
end
Line 834 ⟶ 849:
local function pmc(id, embargo)
local test_limit =
local handler = cfg.id_handlers['PMC'];
local err_cat = ''; -- presume that PMC is valid
Line 961 ⟶ 976:
A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional
format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/
temporary format is apparently eight digits. Anything else is an error
]]
Line 966 ⟶ 985:
local function zbl (id)
local handler = cfg.id_handlers['ZBL'];
local err_cat = '';
add_maint_cat ('zbl'); -- yes, add maint cat
err_cat = ' ' .. set_error( 'bad_zbl' ); -- no, set an error message▼
▲ end
▲ if id_num:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then
▲ else
▲ err_cat = ' ' .. set_error( 'bad_zbl' ); -- set an error message
end
Line 1,111 ⟶ 1,121:
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.
access-level values must match the case used in cfg.keywords['id-access'] (lowercase unless there is some special reason for something else)
]]
Line 1,117 ⟶ 1,129:
local id_accesses_list = {};
for k, v in pairs( cfg.id_handlers ) do
local access_param = v.custom_access; -- name of identifier's access-level parameter
if is_set(access_param) then
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
table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );
access_level = nil; -- invalid so unset
▲ end
▲ if not is_set(id_list[k]) then
table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k_lower}, true ) } );▼
end
if not is_set(id_list[k]) then -- identifer access-level must have a matching identifier
▲ if is_set(access_level) then
▲ table.insert( z.message_tail, { set_error( 'param_access_requires_param', {
end
id_accesses_list[k] = access_level;
|