Jump to content

Module:Contentious topics/aware

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Galobtter (talk | contribs) at 12:15, 2 July 2019 (fix). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

function p.detect(frame)
	title =  frame.args.testTitle or mw.title.getCurrentTitle()
	local content = title:getContent()
	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:150%; 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 new = {}
	for i,v in ipairs(require("Module:TableTools").compressSparseArray(t)) do
		table.insert(new, frame:expandTemplate{title = 'Ds/topics', args = {["sanctions scope"] = v}})
	end
	return mw.text.listToText(new, '; ', '; and ')
end

return p