Jump to content

Module:Protection banner: Difference between revisions

try different format for behaviors table
(beautify the categories table)
(try different format for behaviors table)
Line 6: Line 6:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


local categories = {
local cfg = {}
 
cfg.reasons = {
blp = {
behavior = 'reasonFirst'
},
dispute = {
behavior = 'reasonFirst'
},
office = {
behavior = 'reasonFirst'
},
sock = {
behavior = 'reasonFirst'
},
vandalism = {
behavior = 'namespaceFirst'
},
}
 
cfg.protectionLevels = {
foo
}
 
cfg.categories = {
-- The key strings follow this format:
-- The key strings follow this format:
-- type, level, ns, reason, expiry
-- type, level, ns, reason, expiry
Line 52: Line 76:
}
}


local categoryNamespaces = {
cfg.categoryNamespaces = {
[2] = 'user',
[2] = 'user',
[3] = 'user',
[3] = 'user',
Line 63: Line 87:
}
}


local behaviors = {
cfg.pagetypeNamespaces = {
vandalism = 'namespaceFirst',
dispute = 'reasonFirst',
blp = 'reasonFirst',
sock = 'reasonFirst',
office = 'reasonFirst',
}
 
local pagetypeNamespaces = {
[0] = 'article',
[0] = 'article',
[6] = 'file',
[6] = 'file',
Line 128: Line 144:
return nil
return nil
end
end
local nskey = categoryNamespaces[ns]
local nskey = cfg.categoryNamespaces[ns]
if not nskey and ns % 2 == 1 then
if not nskey and ns % 2 == 1 then
nskey = 'talk'
nskey = 'talk'
Line 141: Line 157:
-- reason for protection, and the expiry date.
-- reason for protection, and the expiry date.
--]]
--]]
cats = cats or categories
cats = cats or cfg.categories


--[[
--[[
Line 167: Line 183:
behavior = 'reasonFirst'
behavior = 'reasonFirst'
else
else
behavior = behaviors[reason]
behavior = cfg.reasons[reason].behavior
end
end
if behavior == 'namespaceFirst' then
if behavior == 'namespaceFirst' then
Cookies help us deliver our services. By using our services, you agree to our use of cookies.