Module:Hatnote: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(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: | Line 11: | ||
local mArguments -- lazily initialise [[Module:Arguments]] |
local mArguments -- lazily initialise [[Module:Arguments]] |
||
local yesno -- lazily initialise [[Module:Yesno]] |
local yesno -- lazily initialise [[Module:Yesno]] |
||
local mCategoryHandler -- lazily initialise [[Module:Category handler]] |
|||
local p = {} |
local p = {} |
||
Line 76: | Line 75: | ||
end |
end |
||
function p.makeWikitextError(msg, |
function p.makeWikitextError(msg, addTrackingCategory) |
||
-- Formats an error message to be returned to wikitext. If |
-- Formats an error message to be returned to wikitext. If |
||
-- 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') |
checkType('makeWikitextError', 1, msg, 'string') |
||
yesno = require('Module:Yesno') |
yesno = require('Module:Yesno') |
||
local title = mw.title.getCurrentTitle() |
|||
mCategoryHandler = require('Module:Category handler') |
|||
local category |
|||
⚫ | |||
if not title.isTalkPage and yesno(addTrackingCategory) ~= false then |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
errorCategory |
|||
⚫ | |||
) |
|||
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( |
return string.format( |
||
'<strong class="error">Error: %s.</strong>%s', |
'<strong class="error">Error: %s.</strong>%s', |
||
msg, |
msg, |
||
category |
|||
errorCategoryLink |
|||
) |
) |
||
end |
end |