Module:Redirect hatnote
- अंगिका
- العربية
- تۆرکجه
- Basa Bali
- বাংলা
- 閩南語 / Bân-lâm-gí
- भोजपुरी
- Bikol Central
- Bosanski
- Català
- Eesti
- فارسی
- Føroyskt
- Galego
- ГӀалгӀай
- ગુજરાતી
- गोंयची कोंकणी / Gõychi Konknni
- 한국어
- हिन्दी
- Bahasa Hulontalo
- Ilokano
- Bahasa Indonesia
- Íslenska
- ಕನ್ನಡ
- Kernowek
- Ikirundi
- Kurdî
- Ladin
- मैथिली
- Македонски
- മലയാളം
- მარგალური
- 閩東語 / Mìng-dĕ̤ng-ngṳ̄
- Монгол
- မြန်မာဘာသာ
- नेपाली
- 日本語
- ଓଡ଼ିଆ
- Oʻzbekcha / ўзбекча
- ਪੰਜਾਬੀ
- Qaraqalpaqsha
- Русиньскый
- Русский
- Scots
- සිංහල
- Simple English
- سنڌي
- Slovenščina
- کوردی
- Српски / srpski
- Sunda
- Tagalog
- Taclḥit
- Татарча / tatarça
- တႆး
- ไทย
- ತುಳು
- Türkmençe
- اردو
- Tiếng Việt
- Winaray
- 粵語
- 中文
- Betawi
- Jaku Iban
- Kumoring
Appearance
From Wikipedia, the free encyclopedia
Warning This Lua module is used on approximately 60,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them.
Due to a server limit of 500 "expensive parser function" calls (e.g. #ifexist:, PAGESIZE:, and PAGESINCATEGORY:), this module will only work properly if the page using it has not already exceeded the limit. When the limit is exceeded, the page using this template or module is categorised in Category:Pages with too many expensive parser function calls. (further information )
This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing.
Page template-protected This module is currently protected from editing.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
This module depends on the following other modules:
This module produces a hatnote for disambiguating a page that is linked to by a given redirect. It implements the {{redirect }} hatnote template.
Usage from wikitext
This module cannot be used directly from wikitext. Please use the {{redirect }} or {{redirect2 }} templates instead.
Usage from Lua
To use this module from Lua, first load the module.
localmRedirectHatnote=require('Module:Redirect hatnote')
The module can then be used with the following syntax:
mRedirectHatnote._redirect(redirect,data,options,titleObj)
See also
The above documentation is transcluded from Module:Redirect hatnote/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (edit | run) pages.
Subpages of this module.
Editors can experiment in this module's sandbox (edit | diff) and testcases (edit | run) pages.
Subpages of this module.
--[[ -- This module produces a "redirect" hatnote. It looks like this: -- '"X" redirects here. For other uses, see Y.' -- It implements the {{redirect}} template. --]] localmHatnote=require('Module:Hatnote') localmHatList=require('Module:Hatnote list') localmArguments--lazily initialize locallibraryUtil=require('libraryUtil') localcheckType=libraryUtil.checkType localcheckTypeMulti=libraryUtil.checkTypeMulti localp={} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- localfunctiongetTitle(...) --Calls mw.title.new and returns either a title object, or nil on error localsuccess,titleObj=pcall(mw.title.new,...) returnsuccessandtitleObjornil end -------------------------------------------------------------------------------- -- Main functions -------------------------------------------------------------------------------- functionp.redirect(frame) mArguments=require('Module:Arguments') localargs=mArguments.getArgs(frame,{parentOnly=true}) --Get number of redirects localnumRedirects=tonumber(frame.args[1])or1 -- Create the options table. localoptions={} options.selfref=args.selfref returnp._redirect(args,numRedirects,options) end functionp._redirect(args,numRedirects,options,currentTitle,redirectTitle,targetTitle) -- Validate the input. Don't bother checking currentTitle, redirectTitle or -- targetTitle, as they are only used in testing. checkType('_redirect',1,args,'table') checkType('_redirect',2,numRedirects,'number',true) numRedirects=numRedirectsor1 checkType('_redirect',3,options,'table',true) options=optionsor{} currentTitle=currentTitleormw.title.getCurrentTitle() -- Get the table of redirects localredirect={} fori=1,numRedirectsdo -- Return an error if a redirect parameter is missing. ifnotargs[i]then returnmHatnote.makeWikitextError( 'missing redirect parameter', 'Template:Redirect#Errors', args.category ) end redirect[i]=args[i] end -- Generate the text. localformattedRedirect={} fork,vinpairs(redirect)do formattedRedirect[k]=mHatnote.quote(v) end localtext={ mHatList.andList(formattedRedirect)..' '..(#redirect==1and'redirects'or'redirect')..' here.', mHatList._forSee(args,#redirect+1,{title=redirect[1],extratext=args.text}) } text=table.concat(text,' ') -- Functionality for adding categories localcategoryTable={} localfunctionaddCategory(cat) ifcatandcat~=''then -- Add by index to avoid duplicates categoryTable[string.format('[[Category:%s]]',cat)]=true end end --Generate tracking categories localmhOptions={} localredirTitle fork,vinpairs(redirect)do -- We don't need a tracking category if the template invocation has been -- copied directly from the docs, or if we aren't in main- or category-space. ifnotv:find('^REDIRECT%d*$')andv~='TERM'-- andcurrentTitle.namespace==0orcurrentTitle.namespace==14 then redirTitle=redirectTitleorgetTitle(v) ifnotredirTitleornotredirTitle.existsthen addCategory('Missing redirects') elseifnotredirTitle.isRedirectthen ifstring.find(redirTitle:getContent(),'#invoke:RfD')then addCategory('Articles with redirect hatnotes impacted by RfD') else addCategory('Articles with redirect hatnotes needing review') end else localtarget=targetTitleorredirTitle.redirectTarget iftargetandtarget~=currentTitlethen addCategory('Articles with redirect hatnotes needing review') end end end -- Generate the options to pass to [[Module:Hatnote]]. ifcurrentTitle.namespace==0andnotmhOptions.selfref andredirTitleandredirTitle.namespace~=0 then -- We are on a mainspace page, and the hatnote starts with something -- like "Wikipedia:Foo redirects here", so automatically label it as -- a self-reference. mhOptions.selfref=true else mhOptions.selfref=options.selfref end end --concatenate all the categories localcategory='' fork,vinpairs(categoryTable)do category=category..k end returnmHatnote._hatnote(text,mhOptions)..category end returnp