Module:Protection banner: Difference between revisions
Content added Content deleted
Enwikipedia>Mr. Stradivarius (beautify the categories table) |
Enwikipedia>Mr. Stradivarius (try different format for behaviors table) |
||
Line 6: | Line 6: | ||
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
||
local |
local cfg = {} |
||
cfg.reasons = { |
|||
blp = { |
|||
⚫ | |||
}, |
|||
dispute = { |
|||
⚫ | |||
}, |
|||
⚫ | |||
⚫ | |||
}, |
|||
sock = { |
|||
behavior = 'reasonFirst' |
|||
}, |
|||
⚫ | |||
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: | ||
} |
} |
||
cfg.categoryNamespaces = { |
|||
[2] = 'user', |
[2] = 'user', |
||
[3] = 'user', |
[3] = 'user', |
||
Line 63: | Line 87: | ||
} |
} |
||
⚫ | |||
local behaviors = { |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
[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 = |
behavior = cfg.reasons[reason].behavior |
||
end |
end |
||
if behavior == 'namespaceFirst' then |
if behavior == 'namespaceFirst' then |