Content deleted Content added
add some cfg values to be used, and improve comments |
add detection for disambig and na classes from the first positional parameter |
||
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'}
-- The parameter name to use for disambiguation pages page.
cfg.dab = 'dab'
-- This table holds the different possible aliases for disambiguation-class pages.
Line 46 ⟶ 49:
-- The default value for disambiguation pages.
cfg.
-- The parameter name to use for N/A-class page.
cfg.na = 'na'
-- This table holds the different possible aliases for N/A-class pages.
Line 52 ⟶ 58:
-- The default value for N/A-class pages.
cfg.
-- The
cfg.redirect = 'redirect'
-- The default value to use for redirects.
cfg.redirectDefault = 'redirect'
-- The value used if the module matches a namespace that has not been specified.
Line 83 ⟶ 92:
end
return ret
end
local function getPagetypeFromClass(class, param, aliasTable, default)
-- Gets the pagetype from a class specified from the first positional parameter.
param = yesno(param, param)
if param ~= false then -- Check for classes unless they are specifically disallowed.
for _, alias in ipairs(aliasTable) do
if class == alias then
if type(param) == 'string' then
return param
else
return default
end
end
end
end
end
Line 101 ⟶ 126:
elseif ndArg then
ndArgs[namespace] = ndArg
end
end
-- If the main namespace argument is present, check for disambiguation-class and N/A-class pages.
if ndArgs.main then
local class = args[1]
local dab = getPagetypeFromClass(class, args[cfg.dab], cfg.dabAliases, cfg.dabDefault)
if dab then
ndArgs.main = dab
else
local na = getPagetypeFromClass(class, args[cfg.na], cfg.naAliases, cfg.naDefault)
if na then
ndArgs.main = na
end
end
end
Line 115 ⟶ 153:
local function detectRedirects(args)
local redirect = args[cfg.redirect]
redirect = yesno(redirect, redirect) -- Returns true/false for "yes", "no", etc., and returns redirect for other input.
if redirect == false then return end
Line 128 ⟶ 166:
return redirect
else
return cfg.
end
end
|