VOOZH about

URL: https://minecraft.wiki/w/Module:Avoided_double_redirect

⇱ Module:Avoided double redirect – Minecraft Wiki


Module:Avoided double redirect

From Minecraft Wiki
Jump to navigation Jump to search
Documentation[view] [edit] [history] [purge]Jump to code ↴

Used in {{Avoided double redirect}}

[view] [edit] [history] [purge]The above documentation is transcluded from Module:Avoided double redirect/doc.
localp={}
localfunctionnoredir(page)
locallink=page:fullUrl("redirect=no")
return"<span class=\"plainlinks\">["..link.." "..page.fullText.."]</span>"
end
functionp.main(frame)
localargs=require("Module:Arguments").getArgs(frame,{removeBlanks=false})
-- Demo parameters, for demonstrating behavior with certain redirect 
-- targets and avoiding categorization (do not use in articles)
localnoError=args.noerror
localdemo=args.demoornoErrororargs.thistargetorargs.othertarget
localfunctionformatError(err)
return"<span class=\"error\">Error in [[Module:Avoided double redirect]]: "..err.."</span>"
..(demoand""or"[[Category:Avoided double redirects to be updated]]")
end
localthisPage=mw.title.getCurrentTitle()
localotherPage=mw.title.new(args[1]or"")
ifnototherPagethen
returnformatError("No other page was specified.");
end
ifmw.title.equals(thisPage,otherPage)then
returnformatError("The current page was passed as the parameter.");
end
-- Get mw.title objects for redirect targets.
localthisTarget,otherTarget
ifdemoandargs.thistargetthen
thisTarget=mw.title.new(args.thistarget)
else
thisTarget=thisPage.redirectTarget
end
ifdemoandargs.othertargetthen
otherTarget=mw.title.new(args.othertarget)
else
otherTarget=otherPage.redirectTarget
end
-- For double redirects
localthisDoubleTarget=thisTargetandthisTarget.redirectTarget
localotherDoubleTarget=otherTargetandotherTarget.redirectTarget
localfunctionformatOutput(update,info)
localfrom,cat
ifotherTargetthen
from="*From an alternative title for '''"..noredir(otherPage).."''', another redirect to the same title. "
else
from="*From an alternative title for '''[[:"..otherPage.fullText.."]]''', a former redirect to the same title. "
end
cat=demoand""orupdateand"[[Category:Avoided double redirects to be updated]]"or"[[Category:Avoided double redirects]]"
ifupdatethen
returnfrom.."\n**"..info..cat
else
returnfrom..info..cat
end
end
ifnoErrorthen
-- Ignore all possible errors, for sample usage
else
ifnotthisTargetthen
returnformatError("This page is not a redirect.",demo)
end
ifmw.title.equals(thisPage,thisTarget)then
returnformatOutput(true,"<span class=\"error\">This is a broken redirect (it redirects to itself).</span>")
end
ifnotthisTarget.existsthen
returnformatOutput(true,"<span class=\"error\">This is a broken redirect (its target does not exist).</span>")
end
ifnototherPage.existsthen
returnformatOutput(true,"<span class=\"error\">[[:"..otherPage.fullText.."]] does not exist.</span>")
end
ifotherTargetandmw.title.equals(otherPage,otherTarget)then
returnformatOutput(true,"<span class=\"error\">[[:"..otherPage.fullText.."]] is a broken redirect (it redirects to itself).</span>")
end
ifotherTargetandnototherTarget.existsthen
returnformatOutput(true,"<span class=\"error\">[[:"..otherPage.fullText.."]] is a broken redirect (it redirects to a page that does not exist).</span>")
end
ifmw.title.equals(thisTarget,otherPage)then
ifnototherTargetthen
returnformatOutput(true,"<span class=\"error\">[[:"..otherPage.fullText.."]] is not a redirect, and this already points to it.</span> Most likely this template should be removed.")
end
ifmw.title.equals(otherTarget,thisPage)then
returnformatOutput(true,"<span class=\"error\">This is a circular redirect.</span> Please change the target of both this redirect and "..noredir(otherPage).." to the correct article.")
end
returnformatOutput(true,"<span class=\"error\">This page redirects to "..noredir(otherPage)..", which redirects to [[:"..otherTarget.fullText.."]].</span> Please change this redirect's target to [[:"..otherTarget.fullText.."]] or otherwise resolve the situation.")
end
ifnototherTargetthen
returnformatOutput(true,"<span class=\"error\">[[:"..otherPage.fullText.."]] is not a redirect.</span> Most likely this redirect should be updated to point to [[:"..otherPage.fullText.."]] now that it is no longer a redirect, and this template removed.\n** If that is not the correct target for this redirect, update or remove this template and/or the redirect itself and/or the other page as appropriate.")
end
ifthisDoubleTargetthen
ifotherDoubleTargetthen
ifmw.title.equals(thisDoubleTarget,otherDoubleTarget)then
returnformatOutput(true,"<span class=\"error\">Both this page and "..noredir(otherPage).." are double redirects.</span> Please change the redirect target of both to "
..(thisDoubleTarget.isRedirectand"the correct article."or"[["..thisDoubleTarget.fullText.."]] (or some other correct article)."))
end
returnformatOutput(true,"<span class=\"error\">Both this page and "..noredir(otherPage).." are double redirects.</span> Please fix them.")
end
returnformatOutput(true,"<span class=\"error\">This is a double redirect.</span> Please fix it, possibly by changing it to [[:"..otherTarget.fullText.."]].")
end
ifnotmw.title.equals(thisTarget,otherTarget)then
returnformatOutput(true,"<span class=\"error\">This page and "..noredir(otherPage).." redirect to different articles.</span> Most likely you should change this redirect's target to [[:"..otherTarget.fullText.."]] to match.\n** If that is not the correct target for this redirect, update or remove this template and/or the redirect itself and/or the other page as appropriate.")
end
ifthisTarget.fragment~=otherTarget.fragmentthen
-- Should this case report for update?
returnformatOutput(false,"Because [[WP:Double redirects|double redirects]] are disallowed,"
.." both pages currently point to [["..otherTarget.prefixedText.."]] (but with different anchors).\n"
.."**If "..noredir(otherPage).." is expanded into a separate article or it is retargeted, "
.." this redirect will be recategorized to be updated."
)
end
end
returnformatOutput(false,"Because [[WP:Double redirects|double redirects]] are disallowed,"
.." both pages currently point to [["..otherTarget.fullText.."]].\n"
.."**If "..noredir(otherPage).." is expanded into a separate article or it is retargeted, "
.." this redirect will be recategorized to be updated."
)
end
returnp
Retrieved from "https://minecraft.wiki/w/Module:Avoided_double_redirect?oldid=1796722"

Navigation menu