Module:Contentious topics/talk notice: Difference between revisions

Content deleted Content added
test
save a WIP
Line 25:
 
-- Additional topics via numbered forms
-- Asking people to choose the top ten CTOP designations is reasonable
for i = 2, 10 do
add(args[i])
Line 40 ⟶ 39:
local multipleTopics = #topics > 1
local restrictions = {}
local restrictionFlags = {} -- Track which restrictions are set
local currentTitleObject = mw.title.getCurrentTitle()
local subjectTitleObject = currentTitleObject.subjectPageTitle
local messageBody
 
--== GenerateHelper theto add a restriction if it's active restrictions==--and hasn't been added yet
-- helper function which add restrictions if active
local function addRestriction(restriction)
if yesno(args[restriction]) and not restrictionFlags[restriction] then
restrictionFlags[restriction] = true
table.insert(restrictions, restriction)
end
end
 
-- addExplicitly the always availabledeclared restrictions, if applicable
addRestriction("0RR")
addRestriction("0RR-nocat")
Line 60:
addRestriction("consensus-required")
 
-- thenTopic-based check each topic...restrictions
for _, topic in ipairs(topics) do
local currentTopicWideRestrictionstopicWide = restrictionsDatabase["topic-wide"][topic]
if topicWide then
--... add anything applicable to the entire topic...
for _, rrestriction in ipairs(restrictionstopicWide) do
if currentTopicWideRestrictions then
addRestriction(restriction)
TableTools.merge(currentTopicWideRestrictions, restrictions)
end
end
 
--...and add anything available to that topic in particular
local availableTopicRestrictionsadditional = restrictionsDatabase["additional-available"][topic]
if availableTopicRestrictionsadditional then
for ___, availableRestrictionrestriction in ipairs(availableTopicRestrictionsadditional) do
addRestriction(availableRestrictionrestriction)
end
end
end
 
-- Finally, we automatically detect thePage protection level ofrestriction the(if subjectit's pagedefined)
local protectionLevelprotectionLevels = subjectTitleObject[".protectionLevels"] and subjectTitleObject[".protectionLevels"]["edit"] or {}
for _, prot in ipairs(protectionLevels) do
if protectionLevel then
if restrictionsDefinition[rprot] then
table.insert(restrictions, protectionLevel)
addRestriction(prot)
{end
end
 
--== EndCheck generationwhether any of activethe added restrictions ==--are actually defined
local underRestrictions = hasRealRestrictionsfalse
for _, r in ipairs(restrictions) do
if restrictionsDefinition[r] then
hasRealRestrictionsunderRestrictions = true
break
}end
end
 
local articleOrPage = currentTitleObject:inNamespaces(1) and "article" or "page"
--== Start building the banner==--
--=Helper functions and variables=--
 
-- given a CTOP code, outputs a bullet point explaining the scope of the contentious topic designation
local function makeTopicBulletPoint(code)
return '* <b>' .. frame:expandTemplate{ title = "Contentious topics/list", args = { scope=code } } .. '</b>\n'
end
 
-- given a restriction code, write a bullet point
local function makeRestrictionBulletPoint(code)
local def = restrictionsDefinition[code]
return def and ('* <b>' .. def .. '</b>\n') or ''
end
 
-- is this page under any restrictions?
local hasRealRestrictions = false
for _, r in ipairs(restrictions) do
if restrictionsDefinition[r] then
hasRealRestrictions = true
break
end
end
 
local underRestrictions = hasRealRestrictions
 
-- gets either "article" or "page", as the case may be
local articleOrPage = currentTitleObject:inNamespaces(1) and "article" or "page"
 
--=End helper functions and variables=--
 
messageBody = '<p>The [[Wikipedia:Contentious topics|contentious topics]] procedure applies to this '
.. articleOrPage .. '.'
.. '.'
.. (yesno(args.section) and (' Parts of this ' .. articleOrPage .. ' relate ') or (' This ' .. articleOrPage .. ' relates '))
 
Line 122 ⟶ 112:
messageBody = messageBody .. 'to the following contentious topics:</p>\n'
for _, topic in ipairs(topics) do
messageBody = messageBody .. makeTopicBulletPoint(topic, frame)
end
else
messageBody = messageBody .. 'to <b>'
.. frame:expandTemplate{ title = "Contentious topics/list", args = { scope=topics[1] } }
.. '</b>, a contentious topic.</p>'
end
 
if underRestrictions then
-- we have some active restrictions
messageBody = '<strong style="text-transform: uppercase;">Warning: active arbitration remedies</strong>'
.. messageBody
.. '<p style="text-decoration:underline;">The following restrictions apply to all editors editing in the topic area:</p>\n'
for _, restriction in ipairs(restrictions) do
messageBody = messageBody .. makeRestrictionBulletPoint(restriction)
Line 146 ⟶ 135:
.. 'If no comment is present, please ask an administrator for assistance. If in doubt it is better to assume that the content is covered.</p>' or '')
 
local messageBox = require('Module:Message box').main( "tmbox", ,{
["type"] = underRestrictions and "delete" or "content",
{
["typesmall"] = underRestrictions and "delete" or "content"yesno(args.small),
["smallimage"] = yesno(args.small),"[[File:Commons-emblem-"
[.. (underRestrictions and "imagehand"] =or "[[File:Commons-emblem-issue")
.. (underRestrictions and "hand" or "issue.svg|")
.. (yesno(args.small) and "30" ..or ".svg|40")
.. (yesno(args.small) and "30" or "40px]]"),
["text"] = .. "px]]",messageBody
})
["text"] = messageBody
}
)
 
return messageBox
 
end