Module:Contentious topics/aware: Difference between revisions
Appearance
Content deleted Content added
This is a copy of Module:Ds/aware (Special:Permalink/981001363); see the history of that page for attribution and license |
update |
||
Line 11: | Line 11: | ||
end |
end |
||
local content = title:getContent() or '' |
local content = title:getContent() or '' |
||
local codes = string.match(content, "{{%s- |
local codes = string.match(content, "{{%s-[cC]ontentious [tT]opics/[aA]ware%s-|([^}]-)}}") |
||
if not codes then return end |
if not codes then return end |
||
local text = p._listToText(frame, mw.text.split(codes, "|")) |
local text = p._listToText(frame, mw.text.split(codes, "|")) |
||
Line 17: | Line 17: | ||
"<div style = 'font-weight: bold'>It is not necessary to notify this user of sanctions for the following topic area(s):" |
"<div style = 'font-weight: bold'>It is not necessary to notify this user of sanctions for the following topic area(s):" |
||
..text.. |
..text.. |
||
"\n The user has indicated that they are already aware of these sanctions using the template <nowiki>{{ |
"\n The user has indicated that they are already aware of these sanctions using the template <nowiki>{{Contentious topics/aware}}</nowiki> on their talk page.</div>" |
||
) |
) |
||
end |
end |
||
Line 29: | Line 29: | ||
local t = require('Module:TableTools').compressSparseArray(t) |
local t = require('Module:TableTools').compressSparseArray(t) |
||
for i,v in ipairs(t) do |
for i,v in ipairs(t) do |
||
table.insert(new, frame:expandTemplate{title = ' |
table.insert(new, frame:expandTemplate{title = 'Contentious_topics/list', args = {["sanctions scope"] = v}}) |
||
end |
end |
||
return '\n*'..table.concat(new, '\n*') |
return '\n*'..table.concat(new, '\n*') |
Revision as of 14:23, 25 December 2022
![]() | 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 = {}
local getArgs = require('Module:Arguments').getArgs
function p.detect(frame)
local title
local args = getArgs(frame)
if args.testTitle then
title = mw.title.new(args.testTitle)
else
title = mw.title.getCurrentTitle()
end
local content = title:getContent() or ''
local codes = string.match(content, "{{%s-[cC]ontentious [tT]opics/[aA]ware%s-|([^}]-)}}")
if not codes then return end
local text = p._listToText(frame, mw.text.split(codes, "|"))
return frame:preprocess(
"<div style = 'font-weight: bold'>It is not necessary to notify this user of sanctions for the following topic area(s):"
..text..
"\n The user has indicated that they are already aware of these sanctions using the template <nowiki>{{Contentious topics/aware}}</nowiki> on their talk page.</div>"
)
end
function p.listToText(frame)
return p._listToText(frame, getArgs(frame))
end
function p._listToText(frame, t)
local new = {}
local t = require('Module:TableTools').compressSparseArray(t)
for i,v in ipairs(t) do
table.insert(new, frame:expandTemplate{title = 'Contentious_topics/list', args = {["sanctions scope"] = v}})
end
return '\n*'..table.concat(new, '\n*')
end
return p