Module:Protection banner: Difference between revisions
Content added Content deleted
Enwikipedia>Mr. Stradivarius (fix "Wikipedia protected categories" key) |
Enwikipedia>Mr. Stradivarius (try a different category matching algorithm completely) |
||
Line 136: | Line 136: | ||
-- Define the key table and the order to test it in |
-- Define the key table and the order to test it in |
||
local keyTable = {protType, protLevel, namespace, reason, expiry} |
local keyTable = {protType, protLevel, namespace, reason, expiry} |
||
local |
local attemptOrder = { |
||
{true, true, true, true, true}, |
|||
if reason == 'vandalism' then |
|||
{true, true, true, true, false}, |
|||
{true, true, true, false, true}, |
|||
⚫ | |||
{true, true, false, true, true}, |
|||
{true, true, true, false, false}, |
|||
⚫ | |||
{true, true, false, true, false}, |
|||
{true, true, false, false, true}, |
|||
{true, true, false, false, false}, |
|||
{true, false, false, false, false}, |
|||
{false, false, false, false, false} |
|||
} |
|||
-- Try successively generic matches until we run out of key combinations |
-- Try successively generic matches until we run out of key combinations |
||
⚫ | |||
local function attemptMatch() |
|||
local key = |
local key = {} |
||
for j = 1, 5 do |
|||
return cats[key] |
|||
⚫ | |||
end |
|||
key[j] = keyTable[j] |
|||
local attempt = attemptMatch() |
|||
⚫ | |||
⚫ | |||
key[j] = 'all' |
|||
return attempt |
|||
end |
|||
⚫ | |||
⚫ | |||
key = table.concat(key, '-') |
|||
keyTable[keyTableKey] = 'all' |
|||
attempt = |
local attempt = cats[key] |
||
if attempt then |
if attempt then |
||
return attempt |
return attempt |