require('strict');local getArgs = require ('Module:Arguments').getArgs;
local cfg = mw.loadData ('Module:Citation/CS1/Configuration'); -- load the configuration modulelocal whitelist = mw.loadData ('Module:Citation/CS1/Whitelist'); -- load the whitelist module
local exclusion_lists =
--script-= lang codes always use override names so dagger is omitted
local function add_to_list (code_list, name_list, override_list, code, name, dagger) if false
if override_list[code] then -- look in the override table for this code code_list[code] = override_list[code] .. dagger; -- use the name from the override table; mark with dagger name_list[override_list[code]] = code .. dagger; else code_list[code] = name; -- use the MediaWiki name and code name_list[name] = code; endend
--
local function list_format (result, list) for k, v in pairs (list) do table.insert (result, k .. ': ' .. v); endend
--lang_lister|list=}}
where <selector> is one of the values:
2char – list of ISO 639-1 codes and names sorted by code
3char – list of ISO 639-2, -3 codes and names sorted by code
ietf – list of IETF language tags and names sorted by tag
ietf2 – list of ISO 639-1 based IETF language tags and names sorted by tag
ietf3 – list of list of ISO 639-2, -3 based IETF language tags and names sorted by tag
name – list of language names and codes sorted by name
all - list all language codes/tags and names sorted by code/tag
where <code> is a MediaWiki supported 2, 3, or ietf-like language code; because of fall-back, language names may
be the English-language names.
local function lang_lister (frame) local lang = (frame.args.lang and ~= frame.args.lang) and frame.args.lang or mw.getContentLanguage:getCode local source_list = mw.language.fetchLanguageNames(lang, 'all'); local override = cfg.lang_tag_remap; local code_1_list=; local code_2_list=; local ietf_list=; local ietf_list2=; local ietf_list3=; local name_list=; if not [frame.args.list] then return '
unknown list selector: ' .. frame.args.list .. ''; endfor code, name in pairs (source_list) do if 'all'
code:len then add_to_list (code_1_list, name_list, override, code, name); elseif 3
if '2char'
frame.args.list then -- iso 639-1 list_format (result, code_1_list); elseif '3char'
frame.args.list then -- all ietf tags list_format (result, ietf_list); elseif 'ietf2'
frame.args.list then -- 3 character ietf tags list_format (result, ietf_list3); else --must be 'name' list_format (result, name_list); end local templatestyles = frame:extensionTag table.sort (result); table.insert (result, 1, templatestyles .. '
'); table.insert (out, table.concat (result, '\n*')); table.insert (out, '
'); return table.concat (out, '\n');end
--script-= parameters.
used in Help:CS1 errors
local function script_lang_lister (frame) local lang_code_src = cfg.script_lang_codes ; -- get list of allowed script language codes local override = cfg.lang_tag_remap; local this_wiki_lang = mw.language.getContentLanguage.code; -- get this wiki's language
local code_list = ; -- interim list of aliases local name_list=; -- not used; defined here so that we can reuse add_to_list local out = ; -- final output (for now an unordered list) for _, code in ipairs (lang_code_src) do -- loop through the list of codes local name = mw.language.fetchLanguageName (code, this_wiki_lang); -- get the language name associated with this code add_to_list (code_list, name_list, override, code, name, false); -- name_list not used but provided so that we can reuse add_to_list; don't add superscript dagger end local result = ; local out = ;
list_format (result, code_list); local templatestyles = frame:extensionTag
table.sort (result); table.insert (result, 1, templatestyles .. '
'); table.insert (out, table.concat (result, '\n*')); table.insert (out, '
'); return table.concat (out, '\n');end
--alias_lister}}
local function alias_lister local alias_src = cfg.aliases; -- get master list of aliases local key; -- key for k/v in a new table local list = ; -- interim list of aliases local out = ; -- final output (for now an unordered list) for _, aliases in pairs (alias_src) do -- loop throu the master list of aliases if 'table'
i then -- first 'alias' is the canonical parameter name key = alias; -- so it becomes the key in list else list[key] = list[key] and (list[key] .. ', ' .. alias) or alias; -- make comma-separated list of aliases list[alias] = 'see ' .. key; -- make a back reference from this alias to the canonical parameter end end end end for k, v in pairs (list) do -- loop through the list to make a simple unordered list table.insert (out, table.concat); end table.sort (out); -- sort it return table.concat (out, '\010'); -- concatenate with \n-- return (mw.dumpObject (list))end
--canonical_param_lister|}}
local function canonical_param_lister (frame) local template = frame.args[1]; if
if template then template = mw.text.trim (template:lower); end
local alias_src = cfg.aliases; -- get master list of aliases local id_src = cfg.id_handlers; -- get master list of identifiers local list = ; -- interim list of aliases local out = ; -- final output (for now an unordered list) for _, aliases in pairs (alias_src) do -- loop through the master list of aliases local name; if 'table'
if not template then -- no template name, add this parameter table.insert (list, name); elseif not exclusion_lists[template] then -- template name but no exclusion list table.insert (list, name); elseif not exclusion_lists[template][name] then -- template name and exclusion list but name not in list table.insert (list, name); end end for k, ids in pairs (id_src) do -- spin through the list of identifiers local name = id_src[k].parameters[1]; -- get the first (left-most) parameter name local access = id_src[k].custom_access; -- get the access-icon parameter if it exists for this identifier if not template then -- no template name table.insert (list, name); -- add this parameter if access then table.insert (list, access); -- add this access-icon parameter end elseif not exclusion_lists[template] then -- template name but no exclusion list table.insert (list, name); if access then table.insert (list, access); end elseif not exclusion_lists[template][name] then -- template name and exclusion list but name not in list table.insert (list, name); if access then table.insert (list, access); end end end for _, param in ipairs (list) do -- loop through the list to make a simple unordered list table.insert (out, table.concat); end local function comp(a, b) -- used in following table.sort return a:lower < b:lower; end table.sort (out, comp); -- sort the list return table.concat (out, '\010'); -- concatenate with \n-- return (mw.dumpObject (list))end
--doi-access= is, for the purposes of this function, DOIaccess, etc
Some lists of aliases might be better served when a particular alias is identified as the canonical alias for a particular use case. If, for example,
While for this function, it would be just as simple to not use the function, this mechanism is implemented here to match similar functionality in alias_names_get (there are slight differences)
(and which would be best for News: ? |newspaper= or |work=? can't solve all of the worlds problems at once).
output format is controlled by |format= plain - renders in plain text in a
tag; may have id attribute para - renders as it would inlocal function canonical_name_get (frame) local alias_src = cfg.aliases; -- get master list of aliases local id_src = cfg.id_handlers; -- get master list of identifiers local args = getArgs (frame);
local name; local meta = args[1] local override = args[2];
local access; -- for id-access parameters if meta:match ('^(%u+)access') then -- the metaparameter (which is not used in ~/Configuration) is id_handlers key concatenated with access: BIBCODEaccess meta, access = meta:gsub ('^(%u+)access', '%1'); -- strip 'access' text from meta and use returned count value as a flag end
if alias_src[meta] then name = alias_src[meta]; -- name is a string or a table if 'table'
override then name = v; -- declare override to be the canonical param for this use case break; end end end end
elseif id_src[meta]then -- if there is an id handler if access then -- and if this is a request for the handler's custom access parameter if id_src[meta].custom_access then -- if there is a custom access parameter name = id_src[meta].custom_access; -- use it else return ; -- nope, return empty string end else if not override then name = id_src[meta].parameters[1]; -- get canonical id handler parameter else for _, v in ipairs (id_src[meta].parameters) do -- here when override is set; spin throu the aliases to make sure override matches alias in table if v
args.format then -- format and return the output if args.id then return string.format ('
%s', args.id, name); -- plain text with id attribute else return name; -- plain text end elseif 'para'|%s=
', name); -- same as endreturn string.format ('%s', args.id or , name); -- because bolds param namesend
--format= plain - renders in plain text in a tag; may have id attribute para - renders as it would in when not specified, refurns the default bold format used for
local function alias_names_get (frame) local alias_src = cfg.aliases; -- get master list of aliases local id_src = cfg.id_handlers; -- get master list of identifiers local args = getArgs (frame); local meta = args[1]; local override = args[2];
local out = ; local source; -- selected parameter or id aliases list local aliases;
source = alias_src[meta] or (id_src[meta] and id_src[meta].parameters); if not source then if meta:match ('%u+access') then return 'no'
args.none and or 'none'; end if not override then aliases = source; -- normal skip-canonical param case else local flag = 'all'
'all' aliases = ; -- spoof to push alias_src[meta][1] and id_src[meta][1] into aliases[2] for _, v in ipairs (source) do -- here when override is set; spin through the aliases to make sure override matches alias in table if v ~= override then table.insert (aliases, v); -- add all but overridden param to the the aliases list for this use case else flag = true; -- set the flag so we know that
if 'table'
args.format then -- format and return the output table.insert (out, alias); -- plain text elseif 'para'
|%s=
', alias)); -- same as else table.insert (out, string.format ("%s", alias)); -- because csdoc bolds param names end end end return table.concat (out, ', '); -- make pretty list and quit endreturn 'no'
----------------------------< I S _ B O O K _ C I T E _ T E M P L A T E >------------------------------------
fetch the title of the current page; if it is a preprint template, return true; empty string else
local book_cite_templates =
local function is_book_cite_template local title = mw.title.getCurrentTitle.rootText; -- get title of current page without namespace and without sub-pages; from Template:Cite book/new -> Cite book title = title and title:lower or ; return book_cite_templates[title] or ;end
----------------------------< I S _ L I M I T E D _ P A R A M _ T E M P L A T E >----------------------------
fetch the title of the current page; if it is a preprint template, return true; empty string else
local limited_param_templates =
local function is_limited_param_template local title = mw.title.getCurrentTitle.rootText; -- get title of current page without namespace and without sub-pages; from Template:Cite book/new -> Cite book title = title and title:lower or ; return limited_param_templates[title] or ;end
----------------------------< H E A D E R _ M A K E >--------------------------------------------------------
makes a section header from
local function _header_make (args) if not args[1] then return ; -- no header text end local level = args[2] and tonumber (args[2]) or 2; level = string.rep ('=', level); return level .. args[1] .. level;end
--
local function header_make (frame) local args = getArgs (frame); return _header_make (args);end
--id_limits_get|
local function id_limits_get (frame) local args = getArgs (frame); local handlers = cfg.id_handlers; -- get id_handlers table from ~/Configuration
return args[1] and handlers[args[1]:upper].id_limit or ('
No limit defined for identifier: ' .. (args[1] or '----------------------------< C A T _ L I N K _ M A K E >----------------------------------------------------
local function cat_link_make (cat) return table.concat ;end
----------------------------< S C R I P T _ C A T _ L I S T E R >--------------------------------------------
utility function to get script-language categories
local lang_list_t = mw.language.fetchLanguageNames ('en', 'all'); local function script_cat_lister (script_lang_codes_t, lang_tag_remap_t, cats_list_t) for _, lang_code in ipairs (script_lang_codes_t) do local lang_name = lang_tag_remap_t[lang_code] or lang_list_t[lang_code]; -- use remap table to get Bengali instead of Bangla and the like; else use standard MediaWiki names local cat = 'CS1 uses ' .. lang_name .. '-language script (' .. lang_code .. ')'; -- build a category name cats_list_t[cat] = 1; -- and save it endend
--select= -- (required) takes one of three values: error, maint, prop |sandbox= -- takes one value: no |hdr-lvl= -- base header level (number of
This tool will automatically attempt to load a sandbox version of ~/Configuration if one exists.Setting |sandbox=no will defeat this.
local function cat_lister (frame) local args = getArgs (frame);
local list_live_cats = ; -- list of live categories local list_sbox_cats = ; -- list of sandbox categories local live_sbox_out = -- list of categories that are common to live and sandbox modules local live_not_in_sbox_out = -- list of categories in live but not sandbox local sbox_not_in_live_out = -- list of categories in sandbox but not live local out = ; -- final output assembled here local sandbox; -- boolean; true: evaluate the sandbox module local hdr_lvl; -- local sb_cfg; local sandbox, sb_cfg = pcall (mw.loadData, 'Module:Citation/CS1/Configuration/sandbox'); -- get sandbox configuration
local cat;
local select = args.select; if 'no'
if 'error'
select then -- error and main categorys handling different from poperties cats for _, t in pairs (cfg.error_conditions) do -- get the live module's categories if ('error'
select and not t.message) then cat = t.category:gsub ('|(.*)$', ); -- strip sort key if any list_live_cats[cat] = 1; -- add to the list end end if sandbox then -- if ~/sandbox module exists and |sandbox= not set to 'no' for _, t in pairs (sb_cfg.error_conditions) do -- get the sandbox module's categories if ('error'
select and not t.message) then cat = t.category:gsub ('|(.*)$', ); -- strip sort key if any list_sbox_cats[cat] = 1; -- add to the list end end end elseif 'prop'
script_cat_lister (cfg.script_lang_codes, cfg.lang_tag_remap, list_live_cats); -- get live module's foriegn language script cats
if sandbox then -- if ~/sandbox module exists and |sandbox= not set to 'no' for _, cat in pairs (sb_cfg.prop_cats) do -- get the sandbox module's categories cat = cat:gsub ('|(.*)$', ); -- strip sort key if any list_sbox_cats[cat] = 1; -- add to the list end
script_cat_lister (sb_cfg.script_lang_codes, sb_cfg.lang_tag_remap, list_sbox_cats); -- get sandbox module's foriegn language script cats end else return '
error: unknown selector: ' .. select .. '' endfor k, _ in pairs (list_live_cats) do -- separate live/sbox common cats from cats not in sbox if not list_sbox_cats[k] and sandbox then table.insert (live_not_in_sbox_out, cat_link_make (k)); -- in live but not in sbox else table.insert (live_sbox_out, cat_link_make (k)); -- in both live and sbox end end
for k, _ in pairs (list_sbox_cats) do -- separate sbox/live common cats from cats not in live if not list_live_cats[k] then table.insert (sbox_not_in_live_out, cat_link_make (k)); -- in sbox but not in live end end
local function comp (a, b) -- local function for case-agnostic category name sorting return a:lower < b:lower; end
local header; -- initialize section header with name of selected category list if 'error'
select then header = 'maintenance'; else header = 'properties'; end header = table.concat
local templatestyles = frame:extensionTag
header = table.concat ;
table.sort (live_sbox_out, comp); -- sort case agnostic acsending table.insert (live_sbox_out, 1, header); -- insert the header at the top table.insert (out, table.concat (live_sbox_out, '\n*')); -- make a big string of unordered list markup table.insert (out, '
if 0 ~= #live_not_in_sbox_out then -- when there is something in the table header = table.concat ; header = table.concat ; table.sort (live_not_in_sbox_out, comp); table.insert (live_not_in_sbox_out, 1, header); table.insert (out, table.concat (live_not_in_sbox_out, '\n*')); table.insert (out, '\n'); end if 0 ~= #sbox_not_in_live_out then -- when there is something in the table header = table.concat ; header = table.concat ; table.sort (sbox_not_in_live_out, comp); table.insert (sbox_not_in_live_out, 1, header); table.insert (out, table.concat (sbox_not_in_live_out, '\n*')); table.insert (out, '\n'); end
return table.concat (out); -- concat into a huge string and doneend
--[=[--------------------------< H E L P _ T E X T _ C A T S >-------------------------------------------------- To create category links at the bottom of each error help text section and on the individual error category pages; fetches category names from ~/Configuration; replaces this: {{#ifeq:{{FULLPAGENAME}}|Category:CS1 errors: bioRxiv|Category:CS1 errors: bioRxiv|[[:Category:CS1 errors: bioRxiv]]}}with this: where is the error_conditions key from Module:Citation/CS1/Configuration
add |pages=yes to append the number of pages in the category
]=]
local function help_text_cats (frame) local args_t = getArgs (frame); local error_conditions_t = cfg.error_conditions; -- get the table of error conditions local replacements_t = ; -- table to hold replacement parameters for $1 etc placeholders in category names for k, v in pairs (args_t) do -- look for |$1=
if args_t[1] and error_conditions_t[args_t[1]] then -- must have error_condition key and it must exist local error_cat = error_conditions_t[args_t[1]].category; -- get error category from cs1|2 configuration if error_cat:match ('$%d') then -- look for placeholders in
title_obj.text) then -- if this is the category page for the error message return table.concat ; -- no link; just category name else -- here when currently displayed page is other than the error message category local pages = ; -- default empty strin for concatenation if 'yes'
--help_text_error_messages|err_bad_biorxiv}}
assign a single underscore to any of the |$n= parameters to insert an empty string in the error message: -> Check |issn= value -> Check |eissn= value
error message is rendered at 120% font size; to specify another font size use |size=; must include unit specifier (%, em, etc)
local function help_text_error_messages (frame) local args_t = getArgs (frame); local error_conditions = mw.loadData ('Module:Citation/CS1/Configuration').error_conditions;-- local span_o = '
'local message; local out = ; -- output goes here if args_t[1] and error_conditions[args_t[1]] then -- must have error_condition key and it must exist message = error_conditions[args_t[1]].message; local i=1; local count; local rep; repeat rep = '$'..i args_t[rep] = args_t[rep] and args_t[rep]:gsub ('^%s*_%s*$', ) or nil; -- replace empty string marker with actual empty string message, count = message:gsub (rep, args_t[rep] or rep) i = i + 1; until (0
table.insert (out, span_o); table.insert (out, message); table.insert (out, span_c); else return '
unknown error_conditions key: ' .. (args_t[1] or 'key missing') .. ''; end local out_str = table.concat (out); return table.concat ;end--2template names : Template:Cite AV media -> citeavmedia Each subsequence table holds: [1] documentation page where the TemplateData json is stored (Book: is the oddball) [2] key to 'preprint_arguments_t' and unique_arguments_t' tables in Module:Citation/CS1/Whitelist; these keys dictate which of the basic or limited arguments and numbered arguments tables will be used to validate the content of the TemplateData
local templates_t =, -- preprint arguments citeavmedia =, -- unique arguments citeavmedianotes =, -- no template data citebiorxiv =, -- preprint arguments citebook =, citeciteseerx =, -- no template data; preprint uses limited arguments citeconference =, -- unique arguments citedocument =, -- special case; uses whitelist.document_parameters_t citeencyclopedia =, citeepisode =, -- unique arguments citeinterview =, citejournal =, citemagazine =, citemailinglist =, -- unique arguments -- no template data citemap =, -- unique arguments citemedrxiv =, -- preprint arguments citenews =, citenewsgroup =, -- unique arguments citepodcast =, citepressrelease =, citereport =, -- unique arguments citeserial =, -- unique arguments -- no template data citesign =, citespeech =, -- unique arguments -- no template data citessrn =, -- preprint arguments -- no template data citetechreport =, citethesis =, -- unique arguments citeweb =, citation =, .
----------------------------< N O _ P A G E _ T E M P L A T E S _ T >----------------------------------------
local no_page_templates_t = ;
----------------------------< I D E N T I F I E R _ A L I A S E S _ T >--------------------------------------
a table of the identifier aliases
local identifier_aliases_t = for identifier, handler in pairs (cfg.id_handlers) do -- for each identifier local aliases_t = ; -- create a table for _, alias in ipairs (handler.parameters) do -- get the alaises aliases_t[alias] = true; -- and add them to the table in a form that mimics the whitelist tables end identifier_aliases_t[identifier:lower] = aliases_t; -- add new table to the identifier aliases table; use lowercase identifier base name for the keyend
--
local function template_data_json_get (template) local json = mw.title.new (template):getContent or ; -- get the content of the article or ; new pages edited w/ve do not have 'content' until saved; ve does not preview; phab:T221625 json = json:match ('<[Tt]emplate[Dd]ata>(.-)[Tt]emplate[Dd]ata>'); -- remove everything exept the content of the TemplatData tags return json and mw.text.jsonDecode (json); -- decode the json string and return as a table; nil if not foundend
----------------------------< V A L I D A T E _ D O C U M E N T _ P A R A M >--------------------------------
looks for (can be the canonical parameter name or can be an alias) in whitelist.document_parameters_t.When found, returns true; nil else
is the parameter's name as listed in the TemplateData
local function validate_document_param (param) if true
----------------------------< V A L I D A T E _ U N I Q U E _ P A R A M >------------------------------------
looks for (can be the canonical parameter name or can be an alias) in whitelist.basic_arguments and ifnecessary in whitelist.numbered_arguments. When found, returns true; nil else
is the parameter's name as listed in the TemplateData
local function validate_basic_param (param) if true
----------------------------< V A L I D A T E _ P R E P R I N T _ P A R A M >--------------------------------
looks for (can be the canonical parameter name or can be an alias) in whitelist.preprint_arguments_t orwhitelist.limited_basic_arguments or whitelist.limited_numbered_arguments. When found, returns true; nil else
is the parameter's name as listed in the TemplateData
local function validate_preprint_param (param, key) if true
whitelist.limited_parameters_t[param] then-- true
whitelist.limited_numbered_arguments_t[param] then return true; endend
----------------------------< V A L I D A T E _ U N I Q U E _ P A R A M >------------------------------------
looks for (can be the canonical parameter name or can be an alias) in whitelist.unique_arguments_t orwhitelist.basic_arguments or whitelist.numbered_arguments. When found, returns true; nil else
is the parameter's name as listed in the TemplateData
local function validate_unique_param (param, key, cfg_aliases_t) if true
validate_basic_param (param) then return true; endend
----------------------------< V A L I D A T E _ I D _ P A R A M >--------------------------------------------
looks for
is the parameter's name as listed in the TemplateData
local function validate_id_alias (param, alias) return identifier_aliases_t[param] and identifier_aliases_t[param][alias];end
----------------------------< P A R A M _ E R R O R_ M S G >-------------------------------------------------
local function param_error_msg (param) return '
|' .. param .. '= is not a valid parameter';end----------------------------< D U P _ A L I A S _ E R R O R_ M S G >-----------------------------------------
local function dup_alias_error_msg (param, alias) return '
|' .. param .. '= has duplicate aliases: |' .. alias .. '=';end----------------------------< D U P _ A L I A S E S _ C H E C K >--------------------------------------------
create an associative array of aliases. if
local function dup_aliases_check (param, alias, aliases_t, out_t) if not aliases_t[alias] then aliases_t[alias] = true; else table.insert (out_t, dup_alias_error_msg (param, alias)); endend
----------------------------< A L I A S _ E R R O R_ M S G >-------------------------------------------------
local function alias_error_msg (param, alias) return '|' .. alias .. '=
is not a valid alias of: |' .. param .. '=
';end
--accessdate= is an aliases of |access-date=: if out_t['access-date']
local function cfg_aliasts_t_make local out_t = ; for meta, params_t in pairs (cfg.aliases) do if 'table'
--2 template's TemplateData structure (everything between
When called from a different page: where the
local function template_data_validate (frame) local args_t = getArgs (frame);
if not args_t[1] then return '
Error: cs1|2 template name required'; endlocal template_idx = args_t[1]:lower:match ('cit[ae][^/]+'); -- args_t[1] has something if not template_idx then -- but if not a cs1|2 template abandon with error message return '
Error: cs1|2 template name required'; else template_idx = template_idx:gsub (' ', ); -- is what appears to be a cs1|2 template so strip spaces endlocal cfg_aliases_t = cfg_aliasts_t_make ;
local template_t = templates_t[template_idx]; local out = ;
local template_doc = template_t[1]; local json_t = template_data_json_get (template_doc); if not json_t then table.insert (out, 'Error: can\'t find TemplateData'); else for param, param_t in pairs (json_t['params']) do local param_i; -- this will be the parameter name that gets validated if param:find ('[Ss]2[Cc][Ii][Dd]') then -- |s2cid*= parameters are not enumerated ... param_i = param; -- ... so don't convert the '2' to '#' else param_i = param:gsub ('%d+', '#'); -- for enumerated parameters, convert the enumerator digits to a single '#' character; all others unmolested end
local param_is_valid; -- boolean true when param is valid; nil else if template_t[2] then -- if template is a preprint or uses unique parameters of 'document' parameters if 'document'
---------- this emits errors when page/pages/at listed in templatedata of templates that don't support those parameters ------------ if json_t then-- if [template_idx] then-- local insource_params_t = ; -- build sequence of pagination params not supported by these templates-- for _, meta_param in ipairs do-- if 'table'
if 0 ~= #out then table.sort (out); out[1] = '*' .. out[1]; -- add a splat to the first error message
-- return table.concat ; return table.concat ; else return; -- no errors detected; return nothing endend
--error_cat_page_tally}}
local function error_cat_page_tally local error_conditions_t = cfg.error_conditions; -- get the table of error conditions local tally = 0; local cat_t = ; -- some error message share a category; save tallied cats here so we don't recount the already counted local i = 0; -- number of categories for k, v_t in pairs (error_conditions_t) do if k:match ('^err') then if not cat_t[v_t.category] then cat_t[v_t.category] = true; tally = tally + mw.site.stats.pagesInCategory (v_t.category, 'pages'); -- get category page count; ignore subcats and files i = i + 1; end end end
return mw.language.getContentLanguage:formatNum (tally)end
--maint_cat_page_tally}}
Dynamic subcats of CS1 maint: DOI inactive not counted because these names come and go as time goes by.
local function maint_cat_page_tally local error_conditions_t = cfg.error_conditions; -- get the table of error conditions local tally = 0; local cat_t = ; -- some error message share a category; save tallied cats here so we don't recount the already counted local i = 0; -- number of categories for k, v_t in pairs (error_conditions_t) do if not k:match ('^err') then -- if not an error key its a maint key if not cat_t[v_t.category] then cat_t[v_t.category] = true; if 'maint_mult_names'
k then local special_case_translation_t = cfg.special_case_translation; for _, name in ipairs do local cat_name = v_t.category:gsub ('$1', special_case_translation_t[name]); -- replace $1 with translated list name tally = tally + mw.site.stats.pagesInCategory (cat_name, 'pages'); -- get category page count; ignore subcats and files i = i + 1; end else tally = tally + mw.site.stats.pagesInCategory (v_t.category, 'pages'); -- get category page count; ignore subcats and files i = i + 1; end end end end
return mw.language.getContentLanguage:formatNum (tally)end
--2 does not categorize.
For convenience,
returns a list of all namespace names and identifiers used on the current wiki. Any namespace with anidentifier less than 1, currently Mainspace (0), Special (-1), and Media (-2), is excluded from the list.
local function uncategorized_namespace_lister (frame) local list_t = ; local function compare (a, b) -- local function to sort namespaces numerically by the identifiers local a_num = tonumber (a:match ('%d+')); -- get identifiers and convert to numbers local b_num = tonumber (b:match ('%d+')); return a_num < b_num; -- do the comparison end for i, _ in pairs (mw.site.namespaces) do -- for each namespace in the table if
if not frame.args.all then -- when |all= not set, format list of uncategorized namespaces and identifiers list_t[#list_t] = 'and ' .. list_t[#list_t]; -- add 'and ' to the last name/identifier pair return table.concat (list_t, ', '); -- make a big string and done else -- make list of all namespaces and identifiers return table.concat (list_t, '\n'); -- make a big string and done endend
--single_ltr_2nd_lvl_domain_lister}}
local function single_ltr_2nd_lvl_domain_lister local out_t = ; -- output goes here for _, tld in ipairs (cfg.single_letter_2nd_lvl_domains_t) do -- fetch each tld table.insert (out_t, '.' .. tld); -- prefix with a dot and save in out_t end return table.concat (out_t, ', '); -- make a big string and doneend
----------------------------< E X P O R T E D F U N C T I O N S >------------------------------------------
return ;