Module:Hatnote: Difference between revisions

update the makeWikitextError function - don't use Module:Category handler, and use an addTrackingCategory parameter instead of a demo parameter, to make it easy for daughter modules to add a category=no parameter
(don't categorise talk namespaces)
(update the makeWikitextError function - don't use Module:Category handler, and use an addTrackingCategory parameter instead of a demo parameter, to make it easy for daughter modules to add a category=no parameter)
Line 11:
local mArguments -- lazily initialise [[Module:Arguments]]
local yesno -- lazily initialise [[Module:Yesno]]
local mCategoryHandler -- lazily initialise [[Module:Category handler]]
 
local p = {}
Line 76 ⟶ 75:
end
 
function p.makeWikitextError(msg, demoaddTrackingCategory)
-- Formats an error message to be returned to wikitext. If demo is not nil
-- addTrackingCategory is not false after being returned from
-- or false, no error category is added.
-- [[Module:Yesno]], and if we are not on a talk page, a tracking category
-- is added.
checkType('makeWikitextError', 1, msg, 'string')
yesno = require('Module:Yesno')
local title = mw.title.getCurrentTitle()
mCategoryHandler = require('Module:Category handler')
local category
local errorCategory = 'Hatnote templates with errors'
if not title.isTalkPage and yesno(addTrackingCategory) ~= false then
local errorCategoryLink = string.format(
local errorCategory category = 'Hatnote templates with errors'
'[[%s:%s]]',
local errorCategoryLink category = string.format(
mw.site.namespaces[14].name,
'[[%s:%s]]',
errorCategory
mw.site.namespaces[14].name,
)
category
-- Feed the category link through [[Module:Category handler]] so we can
)
-- use its blacklist.
else
errorCategoryLink = mCategoryHandler.main{
category = ''
talk = '', -- Don't categorise talk namespaces.
end
other = errorCategoryLink,
nocat = demo
}
errorCategoryLink = errorCategoryLink or ''
return string.format(
'<strong class="error">Error: %s.</strong>%s',
msg,
category
errorCategoryLink
)
end