Module:UserLinks/shared: Difference between revisions
Content added Content deleted
(required for Module:UserLinks) |
(set up a local blacklist system so that we don't categorise sandboxes or test case pages) |
||
Line 43: | Line 43: | ||
end |
end |
||
error(message, level) |
error(message, level) |
||
end |
|||
local localBlacklist = { |
|||
'/[sS]andbox$', -- Don't categorise sandboxes |
|||
'/[tT]est ?cases$', -- Don't categorise test case pages |
|||
} |
|||
local function currentTitleMatchesLocalBlacklist() |
|||
-- Return true if the current title matches any of the patterns in the |
|||
-- local blacklist table. Otherwise return false. |
|||
local title = mw.title.getCurrentTitle().prefixedText |
|||
for i, pattern in ipairs(localBlacklist) do |
|||
if title:find(pattern) then |
|||
return true |
|||
end |
|||
end |
|||
return false |
|||
end |
end |
||
Line 62: | Line 79: | ||
-- Categorise all namespaces, but not blacklisted pages. |
-- Categorise all namespaces, but not blacklisted pages. |
||
category = mCategoryHandler.main{all = category} |
category = mCategoryHandler.main{all = category} |
||
end |
|||
if category and currentTitleMatchesLocalBlacklist() then |
|||
category = nil |
|||
end |
end |
||
end |
end |