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

Content deleted Content added
test
save a WIP
Line 20:
local function add(value)
if value then
value = mw.ustring.lower(mw.text.trim(value))
local applicableSection = args[value .. '-section'] or sectionParameter
value = topicAliases[value] or value -- normalize to the canonical name after we find the applicableSection
Line 201:
local function getTopicBlurb(code)
return frame:expandTemplate{
title = "Contentious topics/list/sandbox",
args = { scope = code }
)}
end
local function getSuptopicBlurb(code)
return frame:expandTemplate{
title = "Contentious topics/list",
args = { subtopic = code }
}
end
Line 255 ⟶ 262:
-- if there's only one topic, we make a short blurb
if numberOfTopics == 1 then
local theCTOP
if section then
for topic, part in pairs(partialTopics) do
Line 260 ⟶ 268:
addToMessage( ' Parts of this ' .. articleOrPage
.. (yesno(part, false) and '' or (' about <b>' .. part .. '</b>'))
.. ' relate to <b>')
..theCTOP = getTopicBlurb(topic)
.. '</b>, a contentious topic.')
end
else
addToMessage(' This ' .. articleOrPage .. ' relates to <b>')
..theCTOP = getTopicBlurb(completeTopics[1])
end
.. '</b>, a contentious topic.'
suptopicBlurb = getSuptopicBlurb(theCTOP)
)
if suptopicBlurb ~= '' then
addToMessage(' to <b>' .. suptopicBlurb .. '</b>, part of the contentious topic designation for <b>' .. getTopicBlurb(subtopics[theCTOP]) .. '</b>.')
else
addToMessage(' to <b>' .. getTopicBlurb(theCTOP) .. '</b>, a contentious topic.')
end
else
Line 409 ⟶ 420:
Categories!!!
We set the restriction categories back in the if underRestrictions loop
to avoid looping through the restrictions twice. So we only need to do some cleanup, check for unknown parameters, and handle nocat
Because nocat is only for the ultra-rare case of demonstration,
Line 415 ⟶ 426:
--]]
-- Start checking for unknown parameters
if yesno(args.nocat) then
-- checkingDoing for unknown parametersso with extensible modules is annoying; the[[Module:Check modulefor unknown parameters]] is primarily intended for hardcoded stuff
categories = ''
else
addCategory(categoryDatabase["all"])
end
-- checking for unknown parameters with extensible modules is annoying; the module is primarily intended for hardcoded stuff
-- luckily, it makes use of a table for its main settings, and we can do some clever stuff with that
Line 456 ⟶ 462:
unknownParameterTable['unknown'] = '[[Category:' .. categoryDatabase['unknown'] .. '|_VALUE_' .. currentTitleObject.text .. ']]'
if yesno(args.nocat) then
-- an finally, call the unknownParameterCheck
-- then handle nocat by clearing both category-holding parameters
unknownParameterCheck = checkForUnknownParameters(unknownParameterTable, args)
categories = ''
unknownParameterCheck = ''
else
-- nocat is not specified, so we add the universal category
addCategory(categoryDatabase["all"])
-- an finally,and call the unknownParameterCheck
unknownParameterCheck = checkForUnknownParameters(unknownParameterTable, args)
end
return messageBox .. categories .. unknownParameterCheck