Module talk:Redirect

This is an old revision of this page, as edited by Mr. Stradivarius (talk | contribs) at 06:25, 16 April 2014 (Protected edit request on 15 April 2014: Responded to edit request (EPH)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Latest comment: 11 years ago by Mr. Stradivarius in topic Protected edit request on 15 April 2014

Wikipedia:Articles for creation

Why am I confused?

At WP:VPT §Is it possible to resolve a redirect in template? you wrote:

... [[{{#invoke:redirect|main|WP:AFC}}]] gets you Wikipedia:Articles for creation ...

So I visited Module:Redirect and found this:

---- This module accepts the name of a single page. It determines if the page is a redirect; if so it looks up the page, extracts the target, and returns the target name as text.


So, why, he asks, are there two parameters? In the example you gave both main and WP:AFC. I tried your module with the redirect page from the WT:VPT conversation:

[[{{#invoke:redirect|RNAS_Kirkwall|WP:AFC}}]] → [[Script error: The function "RNAS_Kirkwall" does not exist.]]
[[{{#invoke:redirect|main|RNAS_Kirkwall}}]]Kirkwall Airport

Why are two parameters necessary? And, surely there is a better error message than Script error.

Trappist the monk (talk) 17:12, 18 March 2013 (UTC)Reply

It occurred to me to also wonder if the first parameter could be empty:
[[{{#invoke:redirect||RNAS_Kirkwall}}]] → [[Script error: The function "" does not exist.]]
Apparently not. So what about meaningless text?
[[{{#invoke:redirect|sdjadrsgjlk|RNAS_Kirkwall}}]] → [[Script error: The function "sdjadrsgjlk" does not exist.]]
Again, apparently not. So what about the name of a real article?
[[{{#invoke:redirect|UP Aerospace|RNAS_Kirkwall}}]] → [[Script error: The function "UP Aerospace" does not exist.]]
Nope. Is "main" some sort of secret word?
Trappist the monk (talk) 17:34, 18 March 2013 (UTC)Reply
{{#invoke:}} takes two parameters: the first is the module name (redirect in this case), the second the function to use from that module (main in this case, as specified by the line "function p.main(frame)" in the module). So the third parameter given to #invoke is the first parameter given to the function. In that way modules can make more than one functions available.
To get more information on the script error, you have click it. MrBlueSky (talk) 14:40, 19 March 2013 (UTC)Reply
Thank you. I've learned a bit here.
Trappist the monk (talk) 15:16, 19 March 2013 (UTC)Reply
Thanks for answering that! I've gotten used to using these module talk pages for anything but talking, and this is the first I noticed the conversation... Wnt (talk) 20:44, 19 March 2013 (UTC)Reply

Redirect types and categories

I am working on building a module to hold the matrix of the {{redr}} codes and associated categories, and also to have logic that automatically detects the correct codes for a redirect. See Wikipedia:Lua_requests#Redirect_categorisation and especially the especially User:John Vandenberg/AutoCategoriseRedirect where I am doing some initial prototyping. The easiest to automatically detect are WP:Shortcuts and Category:Cross-namespace redirects, and those are the ones I am most interested in automatically detecting. @Wnt:, if you think any of the functionality I am working on would benefit this module, and the current uses, some code sharing needs to be organised (the code could be put in this module, or in a separate module that this modules uses), as the automatic redirect type detection should use the 'Redirect' module to extract the redirect target. John Vandenberg (chat) 00:41, 22 January 2014 (UTC)Reply

Well, actually at the moment I can't edit the module on account of it being protected (Mr. Stradivarius did say I could get template editor status, but I procrastinated about picking out a more secure password). He actually rewrote a lot of the highest-level code in the module anyway, and should be good to ask. Also, I wonder about -- I don't really know -- how much time it takes to require a routine out of another module. I don't understand how you're going to get your module called from uncategorized redirects, but if you end up tagging a very large number of them, even a tiny delay for opening another module could add up. And, if someone ever goes in and edits the required Module:Redirect, it'll affect all those pages. There's also a little bit of optimization that can be done by combining the two modules: right now, you do an #invoke:Page|namespace and an invoke of this module, each of which make an expensive call to mw.title.new(), and both would have to be adapted if they're to share it. So I'm thinking you might want to just copy the code, as inelegant as that may be. Wnt (talk) 07:53, 22 January 2014 (UTC)Reply
I'll implement the new module slowly using this module, on only a few pages of each type, so that changes dont have a large impact. If there is a performance issue, I'll switch to calling the relevant functions directly. John Vandenberg (chat) 10:32, 26 January 2014 (UTC)Reply

Flag to resolve soft redirects and redirects at RfD

When a redirect is listed at RfD, it looks like User:John Vandenberg/testcases/Redirect/1 (as documented poorly at mw:Help:Redirects), which the mediawiki software determines is not a 'redirect', and this module doesnt parse and extract the redirect target. It would be nice if {{RFDnote}} and other functions could ask for the redirect target using this module, knowing that it is currently not an active redirect. Likewise, it would be nice if this module could extract the target from {{soft redirect}}, {{wiktionary redirect}}, etc. I think one 'soft=yes' flag would be sufficient to support any 'semi'-redirect page. I'm happy to put up a code mod in the sandbox if others think this is appropriate. Otherwise I'll write a SoftRedirect Module ;-) John Vandenberg (chat) 09:51, 26 January 2014 (UTC)Reply

Protected edit request on 15 April 2014

Please make these changes, so that {{#invoke:redirect|main|{{TALKPAGENAME}}}} works right when the page name contains apostrophes or other characters escaped by {{TALKPAGENAME}}. Jackmcbarn (talk) 21:13, 15 April 2014 (UTC)Reply

  DoneMr. Stradivarius ♪ talk ♪ 06:25, 16 April 2014 (UTC)Reply