Modul:Protection banner: Unterschied zwischen den Versionen

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


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


Zeile 103: Zeile 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)
Zeile 110: Zeile 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'
Anonymer Benutzer