Jump to content

Module:Protection banner: Difference between revisions

add a p.getPagetype function
(add a p.renderBanner function)
(add a p.getPagetype function)
Line 52: Line 52:
}
}


local nskeys = {
local categoryNamespaces = {
[2] = 'user',
[2] = 'user',
[3] = 'user',
[3] = 'user',
Line 69: Line 69:
sock = 'reasonFirst',
sock = 'reasonFirst',
office = 'reasonFirst',
office = 'reasonFirst',
}
local pagetypeNamespaces = {
[0] = 'article',
[6] = 'file',
[10] = 'template',
[14] = 'category',
[828] = 'module',
default = 'page'
}
}


Line 103: Line 112:


local p = {}
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)
function p.matchNamespace(ns)
Line 110: Line 128:
return nil
return nil
end
end
local nskey = nskeys[ns]
local nskey = categoryNamespaces[ns]
if not nskey and ns % 2 == 1 then
if not nskey and ns % 2 == 1 then
nskey = 'talk'
nskey = 'talk'
Cookies help us deliver our services. By using our services, you agree to our use of cookies.