Module:Citation/CS1/sandbox: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 4,524:
--[[--------------------------< H A S _ T W L _ U R L >--------------------------------------------------------
 
look for The Wikipedia Library urls in url-holding parameters. TWL urls are accessible only for readers who are not
active extended confirmed Wikipedia editors. This function emitssets an error message when such urls are discovered.
and when appropriate, sets the |<param>-url-access=subscription. returns nothing.
 
looks for: '.wikipedialibrary.idm.oclc.org'
Line 4,531 ⟶ 4,532:
]]
 
local function has_twl_url (url_params_t, cite_args_t)
local url_error_t = {}; -- sequence of url-holding parameters that have a TWL url
for param, value in pairs (url_params_t) do
if value:find ('%.wikipedialibrary%.idm%.oclc%.org') then -- has the TWL base url?
table.insert (url_error_t, utilities.wrap_style ('parameter', param)); -- add parameter name to the error list
end
end
if 0 ~= #url_error_t then -- non-zero when there are errors
table.sort (url_error_t); -- sor for error messaging
for i, param in ipairs (url_error_t) do
if cfg.url_access_map_t[param] then -- if <param> has a matching -access parameter
cite_args_t[cfg.url_access_map_t[param]] = cfg.keywords_xlate.subscription; -- set |<param>-url-access=subscription
end
url_error_t[i] = utilities.wrap_style ('parameter', param); -- make the parameter pretty for error message
end
 
utilities.set_message ('err_param_has_twl_url', {utilities.make_sep_list (#url_error_t, url_error_t)}); -- add this error message
return true;
end
end
Line 4,684 ⟶ 4,691:
 
has_extraneous_url (non_url_param_t); -- look for url in parameter values where a url does not belong
if has_twl_url (url_param_t, cite_args_t) then ; -- look for url-holding parameters that hold a The Wikipedia Library url
 
cite_args_t['url-access'] = 'subscription';
end
return table.concat ({
frame:extensionTag ('templatestyles', '', {src='Module:Citation/CS1' .. sandbox .. '/styles.css'}),