Module:Contentious topics/talk notice/sandbox: Difference between revisions

Content deleted Content added
refactor
refactor
Line 8:
local restrictionsDefinition = mw.loadJsonData("Template:Contentious topics/Restrictions definition.json")
local standardSet = mw.loadJsonData("Template:Contentious topics/Standard set.json")
 
local subtopics = mw.loadJsonData("Template:Contentious topics/Subtopics.json")
local function callFromListcallFromListTemplate(code, arg)
local topicAliases = mw.loadJsonData("Template:Contentious topics/Aliases.json")
return framemw.getCurrentFrame():expandTemplate{
title = "Contentious topics/list/sandbox", -- REMOVE /sandbox when publishing
args = { [arg] = code }
}
end
 
local function collectTopics(args, sectionParameter)
Line 21 ⟶ 26:
if value then
value = mw.ustring.lower(mw.text.trim(value))
value = topicAliases[callFromListTemplate(value], or value'canonical') -- normalize to the canonical name after we find the applicableSection
local applicableSection = args[value .. '-section'] or sectionParameter
value = topicAliases[value] or value -- normalize to the canonical name after we find the applicableSection
 
if value ~= '' and not seen[value] then
if applicableSection then
Line 197 ⟶ 202:
local function addToMessage(s)
messageBody = messageBody .. s
end
-- helper to call the appropriate parameter from [[Template:Contentious topics/list]]
local function callFromList(code, arg)
return frame:expandTemplate{
title = "Contentious topics/list/sandbox", -- REMOVE /sandbox when publishing
args = { [arg] = code }
}
end
local function getTopicBlurb(code)
return callFromListcallFromListTemplate(code, 'scope')
end
local function getSuptopicBlurb(code)
return callFromListcallFromListTemplate(code, 'subtopic')
end
-- returns the code for a superTopic
local function getSupertopic(code)
return callFromListcallFromListTemplate(code, 'supertopic')
end
Line 236 ⟶ 233:
end
-- check for a superTopic (e.g. South Asia is the superTopic of Indian military history)
local superTopic = subtopics[callFromListTemplate(code], 'supertopic')
if subtopics[code]superTopic ~= '' then
-- we have a superTopic, so explain that
addToMessage(', a subtopic of <b>' .. getTopicBlurb(superTopic) .. '</b>\n')
Line 284 ⟶ 281:
local suptopicBlurb = getSuptopicBlurb(theCTOP)
if suptopicBlurb ~= '' then
addToMessage(' to <b>' .. suptopicBlurb .. '</b>, part of the contentious topic designation for <b>' .. getTopicBlurb(subtopics[callFromListTemplate(theCTOP], 'supertopic')) .. '</b>.')
else
addToMessage(' to <b>' .. getTopicBlurb(theCTOP) .. '</b>, a contentious topic.')
Line 298 ⟶ 295:
else
addToMessage('<b>' .. getTopicBlurb(completeTopics[1]) .. '</b>')
local superTopic = subtopics[callFromListTemplate(completeTopics[1]], 'supertopic')
if superTopic then
addToMessage(', part of the contentious topic designation for <b>' .. getTopicBlurb(superTopic) .. '</b>.</p>')
Line 332 ⟶ 329:
addToMessage(', in particular the parts about <b>' .. scope .. '</b>')
end
local superTopic = subtopics[callFromListTemplate(topic], 'supertopic')
if superTopic then
addToMessage('. This is a subtopic of <b>' .. getTopicBlurb(superTopic) .. '</b>.</p>')