Module:UserLinks/shared: Difference between revisions

set up a local blacklist system so that we don't categorise sandboxes or test case pages
(required for Module:UserLinks)
 
(set up a local blacklist system so that we don't categorise sandboxes or test case pages)
Line 43:
end
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
 
Line 62 ⟶ 79:
-- Categorise all namespaces, but not blacklisted pages.
category = mCategoryHandler.main{all = category}
end
if category and currentTitleMatchesLocalBlacklist() then
category = nil
end
end
Anonymous user