Module:Sanctions
Appearance
![]() | This module depends on the following other modules: |
This module provides utility for the community sanctions system. It should be called using one of its wrapper templates (eg {{Gs/talk notice}}).
To add, remove or modify sanctions, you only need to edit Module:Sanctions/data with your changes. Be careful when saving changes; syntax errors on /data will cause every transclusion of any GS template to show an ugly red error message.
local p = {}
local getArgs = require('Module:Arguments').getArgs
local function tableContains(needle, haystack)
for _, v in pairs(haystack) do
if v == needle then
return true
end
end
return false
end
local function syntaxHelp()
return [[<span class="error">{{para|topic}} not specified. Available options:</span><div style="border-left: 5px dashed black; border-right: 5px dashed black; border-bottom: 5px dashed black; padding-left: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em;">
{{Ds/topics/table}}
{{Gs/topics/table}}
</div>]]
end
function p.build(frame, args)
topic = args[1] or args['topic']
if not topic then
return frame:preprocess(syntaxHelp())
end
local dsTopics = {
"9/11", "a-a", "a-i", "ab", "acu", "aerc", "ap", "at", "mos", "b", "blp",
"cam", "cc", "cid", "e-e", "ecig", "fg", "gc", "gg", "ggtf", "gap", "gmo",
"ipa", "lr", "lw", "med", "muh-im", "old", "pa", "pr", "ps", "r-i", "saq",
"sen", "sci", "tm", "tpm", "tt", "we"
}
local gsTopics = {
"covid", "cry", "irp", "mj", "pw", "sasg", "syr", "uku"
}
if tableContains(topic, dsTopics) then
return frame:expandTemplate {
title = 'Ds/alert/sandbox',
args = { topic }
}
elseif tableContains(topic, gsTopics) then
return frame:expandTemplate {
title = 'Gs/alert/sandbox',
args = { topic }
}
else
-- error
return frame:preprocess(syntaxHelp())
end
end
function p.main(frame)
local args = getArgs(frame, {
wrappers = {
'Template:Alert',
'Template:Alert/sandbox'
}
})
return p.build(frame, args)
end
return p