Content deleted Content added
HouseBlaster (talk | contribs) Undid revision 1292988765 by HouseBlaster (talk) |
HouseBlaster (talk | contribs) *heart emoji* categories *heart emoji* |
||
Line 6:
local restrictionsDefinition = mw.loadJsonData("Template:Contentious topics/Restrictions definition.json")
local standardSet = mw.loadJsonData("Template:Contentious topics/Standard set.json")
local categoryDatabase = mw.loadJsonData("Template:Contentious topics/Category database.json")
local function collectTopics(args)
local seen = {}
Line 48:
local protectionLevel -- the edit protection level
local messageBody
local categories = '' -- initialize categories
--[[
This area sets active restrictions
Line 134 ⟶ 135:
-- Check whether any of the added restrictions are enabled
underRestrictions = #restrictions > 0 or args.other or args.other1
-- Determines whether we should use the string "article" or "page"
Line 153 ⟶ 154:
local def = restrictionsDefinition[code]
return def and ('* <b>' .. def .. '</b>\n') or ''
end
-- Makes a bullet point for a custom, article-specific restriction
local function makeOtherRestrictionBulletPoint(r)
if r and r ~= '' then
return '* <b>' .. r .. '</b>\n'
end
end
local function addCategory(cat)
if cat then
categories = categories .. '[[Category:' .. cat .. '|' .. currentTitleObject.text .. ']]'
end
end
--[[
Begin building the messageBody
--]]
messageBody = '
.. articleOrPage .. '.</b>'
.. (yesno(args.section) and (' Parts of this ' .. articleOrPage .. ' relate ') or (' This ' .. articleOrPage .. ' relates '))
if multipleTopics then
messageBody = messageBody .. 'to the following contentious topics:
for _, topic in ipairs(topics) do
messageBody = messageBody .. makeTopicBulletPoint(topic)
Line 180 ⟶ 193:
for _, restriction in ipairs(restrictions) do
messageBody = messageBody .. makeRestrictionBulletPoint(restriction)
addCategory(categoryDatabase[restriction])
end
end
messageBody = messageBody .. ' Editors are advised to familiarise themselves with the [[Wikipedia:Contentious topics|contentious topics procedures]] before editing this page.'
if not yesno(args.brief) then
Line 195 ⟶ 209:
end
["type"] = underRestrictions and "delete" or "content",
["small"] = yesno(args.small),
Line 205 ⟶ 219:
["text"] = messageBody
})
-- we set the restriction categories back in the if underRestrictions loop
▲ return messageBox
-- to avoid looping through the restrictions twice
-- because nocat is only for the ultra-rare case of demonstration
-- manually clearing the categories is more efficient
if yesno(args.nocat) then
categories = ''
else
addCategory(categoryDatabase["all"])
end
return messageBox .. categories
end
|