Jump to content

Module:Category handler/shared

Kuva Wikipedia

Documentation for this module may be created atModule:Category handler/shared/doc

-- This module contains shared functions used by [[Module:Category handler]]
-- and its submodules.

localp={}

functionp.matchesBlacklist(page,blacklist)
fori,patterninipairs(blacklist)do
localmatch=mw.ustring.match(page,pattern)
ifmatchthen
returntrue
end
end
returnfalse
end

functionp.getParamMappings(useLoadData)
localdataPage='Module:Namespace detect/data'
ifuseLoadDatathen
returnmw.loadData(dataPage).mappings
else
returnrequire(dataPage).mappings
end
end

functionp.getNamespaceParameters(titleObj,mappings)
-- We don't use title.nsText for the namespace name because it adds
-- underscores.
localmappingsKey
iftitleObj.isTalkPagethen
mappingsKey='talk'
else
mappingsKey=mw.site.namespaces[titleObj.namespace].name
end
mappingsKey=mw.ustring.lower(mappingsKey)
returnmappings[mappingsKey]or{}
end

returnp