Module:Citation/CS1/Identifiers: Difference between revisions

Synch from sandbox;
m>Trappist the monk
(Synch from sandbox;)
m>Trappist the monk
(Synch from sandbox;)
Line 6: Line 6:
]]
]]


local is_set, in_array, set_error, select_one, add_maint_cat; -- functions in Module:Citation/CS1/Utilities
local is_set, in_array, set_error, select_one, add_maint_cat, substitute; -- functions in Module:Citation/CS1/Utilities


local z; -- table of tables defined in Module:Citation/CS1/Utilities
local z; -- table of tables defined in Module:Citation/CS1/Utilities
Line 21: Line 21:
local function external_link_id(options)
local function external_link_id(options)
local url_string = options.id;
local url_string = options.id;
local ext_link;
if options.encode == true or options.encode == nil then
if options.encode == true or options.encode == nil then
url_string = mw.uri.encode( url_string );
url_string = mw.uri.encode( url_string );
end
end
return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
options.link, options.label, options.separator or " ",
ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or "", mw.text.nowiki(options.id));
options.prefix, url_string, options.suffix or "",
if options.free then
mw.text.nowiki(options.id)
ext_link = substitute (cfg.presentation['free to read'], ext_link); -- add the free-to-read lock
);
end
return mw.ustring.format( '[[%s|%s]]%s%s', options.link, options.label, options.separator or " ", ext_link);
 
-- return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
-- options.link, options.label, options.separator or " ",
-- options.prefix, url_string, options.suffix or "",
-- mw.text.nowiki(options.id)
-- );
end
end


Line 313: Line 323:


text = external_link_id({link = handler.link, label = handler.label,
text = external_link_id({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, free=handler.free}) .. err_cat;


if is_set (class) then
if is_set (class) then
Line 508: Line 518:
else
else
text = external_link_id({link = handler.link, label = handler.label, -- no embargo date or embargo has expired, ok to link to article
text = external_link_id({link = handler.link, label = handler.label, -- no embargo date or embargo has expired, ok to link to article
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, free=handler.free}) .. err_cat;
end
end
return text;
return text;
Line 693: Line 703:
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–8 must be letter, ampersand, or dot (ampersand cannot directly precede a dot; &.
6 must be letter, ampersand, or dot (ampersand cannot directly precede a dot; &. )
9 must be letter or dot
7–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &. )
10–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


Line 711: Line 721:
err_type = 'length';
err_type = 'length';
else
else
year = id:match ("^(%d%d%d%d)[%a][%a&%.][%a&%.][%a&%.][%a%.][%a%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
Line 854: Line 864:
select_one = utilities_page_ptr.select_one;
select_one = utilities_page_ptr.select_one;
add_maint_cat = utilities_page_ptr.add_maint_cat;
add_maint_cat = utilities_page_ptr.add_maint_cat;
substitute = utilities_page_ptr.substitute;


z = utilities_page_ptr.z; -- table of tables in Module:Citation/CS1/Utilities
z = utilities_page_ptr.z; -- table of tables in Module:Citation/CS1/Utilities
Anonymous user