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))
(Updated from sandbox to fix argument initialization bug)
m (Protected "Module:Redirect hatnote": High traffic page ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
 
(6 intermediate revisions by 3 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, ...)
ifreturn success thenand titleObj or nil
return titleObj
else
return nil
end
end
 
--------------------------------------------------------------------------------
-- Main functions
--------------------------------------------------------------------------------
 
function p.redirect(frame)
Line 59 ⟶ 64:
local formattedRedirect = {}
for k,v in pairs(redirect) do
formattedRedirect[k] = '"' mHatnote.. quote(v .. '"')
end
local text = {
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
redirectTitleredirTitle = redirectTitle or getTitle(v)
if not redirectTitleredirTitle or not redirectTitleredirTitle.exists then
addCategory('Missing redirects')
elseif not redirectTitleredirTitle.isRedirect then
if string.find(redirTitle:getContent(), '#invoke:RfD') then
addCategory('Articles with redirect hatnotes needing review')
addCategory('Articles with redirect hatnotes impacted by RfD')
else
addCategory('Articles with redirect hatnotes needing review')
end
else
local mRedirecttarget = require('Module:Redirect')targetTitle or redirTitle.redirectTarget
local target = mRedirect.getTarget(redirectTitle)
target = targetTitle or target and getTitle(target)
if target and target ~= currentTitle then
addCategory('Articles with redirect hatnotes needing review')
Line 99 ⟶ 107:
-- Generate the options to pass to [[Module:Hatnote]].
if currentTitle.namespace == 0 and not mhOptions.selfref
and redirectTitleredirTitle and redirectTitleredirTitle.namespace ~= 0
then
-- We are on a mainspace page, and the hatnote starts with something
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu