Content deleted Content added
HouseBlaster (talk | contribs) save a WIP |
sync – trying to debug Special:Permalink/1286083691 Tag: Reverted |
||
Line 8:
local categoryDatabase = mw.loadJsonData("Template:Contentious topics/Category database.json")
local function collectTopics(args
local seen = {}
local
local function add(value)
if value then
value = mw.text.trim(value)
if value ~= '' and not seen[value] then
end
end
Line 39 ⟶ 33:
add(args['topic' .. i])
end
return
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame)
local sectionParameter = yesno(args.section) or yesno(args.relatedcontent) -- whether we are a section▼
▲ local completeTopics, partialTopics = collectTopics(args, sectionParameter)
local restrictions = {} -- A list of which restrictions are enabled for easier iteration
local restrictionFlags = {} -- Track which restrictions are enabled, as a set
local currentTitleObject = mw.title.getCurrentTitle()
local subjectTitleObject = currentTitleObject.subjectPageTitle
local underRestrictions -- a boolean for whether there are any active restrictions
local articleOrPage -- the string "article" (if a mainspace page) or "page" (if not)
local protectionLevel -- the edit protection level
local messageBody -- the text within the message box
local messageBox -- the message box itself
local categories = '' -- initialize categories
local manualRestrictions = false -- have we set any restrictions via |parameters?
▲
--[[
Line 92 ⟶ 84:
-- Topic-based restrictions
for _, topic in ipairs
if topicWide then
for _, restriction in ipairs(topicWide) do
Line 99 ⟶ 91:
end
end
local additional = restrictionsDatabase["additional-available"][topic]
if additional then
Line 108 ⟶ 98:
end
end
end
Line 159 ⟶ 143:
-- Check whether any of the added restrictions are enabled
underRestrictions = #restrictions > 0 or args.other
-- Determines whether we should use the string "article" or "page"
local articleOrPage = currentTitleObject:inNamespaces(1) and "article" or "page"
▲ --[[ Makes a bullet point for a given contentious topic
▲ local function makeTopicBulletPoint(code, )
topicBlurb = frame:expandTemplate{ title = "Contentious topics/list", args = { scope=code } }
if topicBlurb == '' then
addCategory(categoryDatabase['bad-topic'])
return ''
return '* <b>' .. topicBlurb .. '</b>\n'
end
end
--]]▼
-- Makes a restriction bullet point
Line 196 ⟶ 165:
--[[
Place into an error
--]]
▲ if numberOfTopics == 0 then
addCategory(categoryDatabase['no-topic'])
end
Line 207 ⟶ 175:
--]]
messageBody = '<b>The [[Wikipedia:Contentious topics|contentious topics]] procedure applies to this '
.. articleOrPage .. '.</b>' ▲ -- .. (section and (' Parts of this ' .. articleOrPage .. ' relate ') or (' This ' .. articleOrPage .. ' relates '))
--[[▼
▲ if numberOfTopics > 1 then
messageBody = messageBody .. 'to the following contentious topics:\n'
for _, topic in ipairs(topics) do
Line 249 ⟶ 191:
messageBody = messageBody .. 'to <b>'
.. topicBlurb
.. '</b>, a contentious topic.</p>'
else
addCategory(categoryDatabase['bad-topic'])
end
end
--]]▼
if underRestrictions then
messageBody = '<p style="margin-top:0"><strong style="text-transform: uppercase;">Warning: active arbitration remedies</strong></p>'
Line 273 ⟶ 214:
if not yesno(args.brief) then
messageBody = messageBody .. ' Editors who repeatedly or seriously fail to adhere to the [[WP:Five pillars|purpose of Wikipedia]], any expected [[WP:Etiquette|standards of behaviour]], '
.. 'or any [[WP:List of policies|normal editorial process]] may be blocked or restricted by an administrator.'
end
if section then
messageBody = messageBody .. '<p>If it is unclear which parts of the page are related to this contentious topic, the content in question should be marked within the wiki text by an invisible comment.'
.. '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>'
end
▲ --[[
if underRestrictions then
if args['placed-date'] then
Line 291 ⟶ 230:
end
end
]]--
Now build some further information collapse boxes
We get the content of each collapse box from Wikipedia:Contentious topics/[Topic]/Further information
▲ --]]
-- Now build the messageBox
Line 313 ⟶ 258:
-- Hard code for [[WP:BER]]
if TableTools.inArray(
addCategory("Wikipedia pages subject to the extended confirmed restriction related to the Arab-Israeli conflict")
end
|