Module:Protection banner: Difference between revisions

try different format for behaviors table
(beautify the categories table)
(try different format for behaviors table)
Line 6:
--------------------------------------------------------------------------------
 
local categoriescfg = {}
 
cfg.reasons = {
blp = {
dispute behavior = 'reasonFirst',
},
dispute = {
blp behavior = 'reasonFirst',
},
office = 'reasonFirst',{
sock behavior = 'reasonFirst',
},
sock = {
behavior = 'reasonFirst'
},
vandalism = 'namespaceFirst',{
behavior = 'namespaceFirst'
},
 
cfg.protectionLevels = {
foo
}
 
cfg.categories = {
-- The key strings follow this format:
-- type, level, ns, reason, expiry
Line 52 ⟶ 76:
}
 
local cfg.categoryNamespaces = {
[2] = 'user',
[3] = 'user',
Line 63 ⟶ 87:
}
 
local cfg.pagetypeNamespaces = {
local behaviors = {
vandalism = 'namespaceFirst',
dispute = 'reasonFirst',
blp = 'reasonFirst',
sock = 'reasonFirst',
office = 'reasonFirst',
 
local pagetypeNamespaces = {
[0] = 'article',
[6] = 'file',
Line 128 ⟶ 144:
return nil
end
local nskey = cfg.categoryNamespaces[ns]
if not nskey and ns % 2 == 1 then
nskey = 'talk'
Line 141 ⟶ 157:
-- reason for protection, and the expiry date.
--]]
cats = cats or cfg.categories
 
--[[
Line 167 ⟶ 183:
behavior = 'reasonFirst'
else
behavior = behaviorscfg.reasons[reason].behavior
end
if behavior == 'namespaceFirst' then