Module:Pagetype: Difference between revisions

Content deleted Content added
move the default value for redirects to the config table
add some cfg values to be used, and improve comments
Line 41:
-- This table holds the names of the namespaces to be looked up from cfg.pagetypes by default.
cfg.defaultNamespaces = {'main', 'file', 'template', 'category', 'module', 'book'}
 
-- This table holds the different possible aliases for disambiguation-class pages.
cfg.dabAliases = {'disambiguation', 'disambig', 'disamb', 'dab'}
 
-- The default value for disambiguation pages.
cfg.dab = 'page'
 
-- This table holds the different possible aliases for N/A-class pages.
cfg.naAliases = {'na', 'n/a'}
 
-- The default value for N/A-class pages.
cfg.na = 'page'
 
-- The default value to use for redirects.
Line 64 ⟶ 76:
local p = {}
 
local function getNamespacePagetypecheckPagetypeInput(namespace, vval)
-- Checks to see whether we need the default value for the given namespace, and if so gets it from the pagetypes table.
local ret = yesno(vval, vval) -- Returns true/false for "yes", "no", etc., and returns vval for other input.
if ret and type(ret) ~= 'string' then
ret = pagetypes[namespace]
Line 73 ⟶ 86:
 
local function getNsDetectValue(args)
-- Builds the arguments to pass to [[Module:Namespace detect]] and returns the result.
local ndArgs = {}
-- Get the default values.
Line 80 ⟶ 94:
-- Add custom values passed in from the arguments. These overwrite the defaults.
for namespace in pairs(pagetypes) do
local ndArg = getNamespacePagetypecheckPagetypeInput(namespace, args[namespace])
if ndArg == false then
-- If any arguments are false, convert them to nil to protect against breakage by future changes