Module:Protection banner: Difference between revisions

add a p.getPagetype function
(add a p.renderBanner function)
(add a p.getPagetype function)
Line 52:
}
 
local nskeyscategoryNamespaces = {
[2] = 'user',
[3] = 'user',
Line 69:
sock = 'reasonFirst',
office = 'reasonFirst',
}
 
local pagetypeNamespaces = {
[0] = 'article',
[6] = 'file',
[10] = 'template',
[14] = 'category',
[828] = 'module',
default = 'page'
}
 
Line 103 ⟶ 112:
 
local p = {}
 
function p.getPagetype(ns)
-- Returns a string with the page's type. Takes a namespace number as input.
local pagetype = pagetypeNamespaces[ns] or pagetypeNamespaces.default
if not pagetype then
error('the page type could not be found; please define a name for the key "default"')
end
return pagetype
end
 
function p.matchNamespace(ns)
Line 110 ⟶ 128:
return nil
end
local nskey = nskeyscategoryNamespaces[ns]
if not nskey and ns % 2 == 1 then
nskey = 'talk'