Module:Redirect hatnote: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
m
Protected "Module:Redirect hatnote": High traffic page ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))
(Rephrased error message to make more sense for version with multiple redirects) |
m (Protected "Module:Redirect hatnote": High traffic page ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))) |
||
(8 intermediate revisions by 4 users not shown) | |||
Line 13:
local p = {}
--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------
local function getTitle(...)
--Calls mw.title.new and returns either a title object, or nil on error
local success, titleObj = pcall(mw.title.new, ...)
else▼
end▼
end
--------------------------------------------------------------------------------
-- Main functions
--------------------------------------------------------------------------------
function p.redirect(frame)
Line 59 ⟶ 64:
local formattedRedirect = {}
for k,v in pairs(redirect) do
formattedRedirect[k] =
end
local text = {
mHatList.andList(formattedRedirect) .. ' ' .. (#redirect == 1 and 'redirects' or 'redirect') .. ' here.',
mHatList._forSee(args, #redirect + 1, {title = redirect[1], extratext = args.text})
}
text = table.concat(text, ' ')
-- Functionality for adding categories
local categoryTable = {}
local function addCategory(cat)
if cat and cat ~= '' then
-- Add by index to avoid duplicates
Line 76 ⟶ 81:
--Generate tracking categories
local mhOptions = {}
local redirTitle
for k,v in pairs(redirect) do
-- We don't need a tracking category if the template invocation has been
Line 82 ⟶ 88:
and currentTitle.namespace == 0 or currentTitle.namespace == 14
then
if not
addCategory('Missing redirects')
elseif not
if string.find(redirTitle:getContent(), '#invoke:RfD') then
addCategory('Articles with redirect hatnotes needing review')▼
addCategory('Articles with redirect hatnotes impacted by RfD')
▲ addCategory('Articles with redirect hatnotes needing review')
else
local
addCategory('Articles with redirect hatnotes needing review')
end
Line 99 ⟶ 107:
-- Generate the options to pass to [[Module:Hatnote]].
if currentTitle.namespace == 0 and not mhOptions.selfref
and
then
-- We are on a mainspace page, and the hatnote starts with something
|