Module:Category handler: Difference between revisions

Content added Content deleted
(pass through page parameter to Module:Namespace detect, tweak comments a bit)
(fix default parameter main namespace bug)
Line 85: Line 85:
}
}


-- This is a table of namespaces to categorise by default.
-- This is a table of namespaces to categorise by default. They
-- should be in the format of parameter names accepted by
-- [[Module:Namespace detect]].
cfg.defaultNamespaces = {
cfg.defaultNamespaces = {
0, -- Main
'main',
6, -- File
'file',
12, -- Help
'help',
14 -- Category
'category'
}
}


Line 195: Line 197:
if needsBlacklistCheck( args ) and not findBlacklistMatch( pageObject ) then
if needsBlacklistCheck( args ) and not findBlacklistMatch( pageObject ) then
if not nsParamsExist( mappings, args ) then
if not nsParamsExist( mappings, args ) then
-- No namespace parameters exist; basic usage.
-- No namespace parameters exist; basic usage. Pass args[1] to
-- [[Module:Namespace detect]] using the default namespace
-- parameters, and return the result.
local ndargs = {}
local ndargs = {}
for _, nsid in ipairs( cfg.defaultNamespaces ) do
for _, ndarg in ipairs( cfg.defaultNamespaces ) do
ndargs[ mw.ustring.lower( mw.site.namespaces[ nsid ].name ) ] = args[1]
ndargs[ndarg] = args[1]
end
end
ndargs.page = args.page
ndargs.page = args.page