Module:Contentious topics/aware
Appearance
![]() | This Lua module is used in MediaWiki:Abusefilter-warning-CT. Changes to it can cause immediate changes to the Wikipedia user interface. To avoid major disruption, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on the talk page before implementing them. |
See doc at Template:Contentious topics/aware/doc
local p = {}
function p.detect(frame)
local title
if not frame.args.testTitle then
title = mw.title.makeTitle(0, frame.args.testTitle)
else
title = mw.title.getCurrentTitle()
end
local content = title:getContent()
if not content then return end
local codes = string.match(content, "{{%s-Ds/aware%s-|([^}]-)}}")
if not codes then return end
local text = p._listToText(frame, mw.text.split(codes, "|"))
return frame:preprocess(
"<span style = 'font-size:120%; font-weight: bold'>It is not necessary to notify this user of sanctions for the following topic area(s): "
..text..
". The user has indicated that they are already aware of these sanctions using the template <nowiki>{{Ds/aware}}</nowiki> on their talk page.</span>"
)
end
function p.listToText(frame)
return p._listToText(frame, frame:getParent().args)
end
function p._listToText(frame, t)
local text
local new = {}
local t = require('Module:TableTools').compressSparseArray(t)
for i,v in ipairs(t) do
table.insert(new, frame:expandTemplate{title = 'Ds/topics', args = {["sanctions scope"] = v}})
end
if #t > 1 then
text = "topic areas: "
else
text = "topic area: "
end
return text..mw.text.listToText(new, '* ')
end
return p