Module:Pagetype: Difference between revisions

Content deleted Content added
put the class value in lower case to match both "Dab" and "dab" etc., and some more comment tweaking
get the namespace parameter names from Module:Namespace detect automatically in case any new namespaces are added
Line 82:
local nsDetectModule = require('Module:Namespace detect')
local nsDetect = nsDetectModule._main
local getParamMappings = nsDetectModule.getParamMappings
local getPageObject = nsDetectModule.getPageObject
 
Line 119 ⟶ 120:
end
-- Add custom values passed in from the arguments. These overwrite the defaults.
-- The possible argument names are fetched from [[Module:Namespace detect]] automatically in case new namespaces are added.
for namespace in pairs(cfg.pagetypes) do
local mappings = getParamMappings()
local ndArg = checkPagetypeInput(namespace, args[namespace])
for namespacens, paramNames in pairs(cfg.pagetypesmappings) do
if ndArg == false then
for _, paramName in ipairs(paramNames) do
-- If any arguments are false, convert them to nil to protect against breakage by future changes
local ndArg = checkPagetypeInput(namespaceparamName, args[namespaceparamName])
-- to [[Module:Namespace detect]].
if ndArg == false then
ndArgs[namespace] = nil
-- If any arguments are false, convert them to nil to protect against breakage by future changes
elseif ndArg then
-- to [[Module:Namespace detect]].
ndArgs[namespace] = ndArg
ndArgs[namespaceparamName] = nil
elseif ndArg then
ndArgs[namespaceparamName] = ndArg
end
end
end
-- If the main namespace argument is present, checkCheck for disambiguation-class and N/A-class pages in mainspace.
if ndArgs.main then
local class = args[1]