Module talk:Redirect hatnote

Latest comment: 1 year ago by Vipz in topic Integrate {{Redirect-synonym}}

Request a new tracking category

edit

@Mr. Stradivarius: Hi. I noticed module:redirect, which has different functionality from template:redirect, and was wanting to modify the latter to use the former to check for and track "incorrect redirects". So I went to Template:Redirect/sandbox to work on that and found it pointing me here. So, since you're converting it to Lua maybe you can do this. For example, pretend that an editor put a {{redirect}} hatnote on Computer that said Calculator redirects here. That wouldn't be a missing redirect because Calculator exists as a separate article. Or they might put up a hatnote that says Digital calculator redirects here. That's a redirect, but it redirects to a different article. Can you make this module check for those, and have them populate a category like Category:Incorrect redirects. Thanks, Wbm1058 (talk) 19:27, 15 May 2014 (UTC)Reply

@Wbm1058: I've added the code to the module. — Mr. Stradivarius ♪ talk ♪ 21:51, 15 May 2014 (UTC)Reply
Thanks! Wbm1058 (talk) 21:59, 15 May 2014 (UTC)Reply

@Mr. Stradivarius: What is the status of the enhancements to populate Category:Invalid redirects? Does Module:Redirect need changes to support this? Wbm1058 (talk) 21:45, 25 July 2014 (UTC)Reply

@Wbm1058: Module:Redirect hatnote itself hasn't been deployed, which is why nothing is showing up in the category. I won't be around much on WP much this week though, so I won't be able to get round to it straight away. — Mr. Stradivarius on tour ♪ talk ♪ 15:16, 26 July 2014 (UTC)Reply
@Mr. Stradivarius: Thanks much! Category:Invalid redirects now has over 240 pages, and I've already started fixing them. Wbm1058 (talk) 23:06, 5 August 2014 (UTC)Reply
...and it's now been emptied. But it won't stay empty for long, this is one that needs constant patrolling. A shout out of thanks to BD2412 for helping, though their entry to this list is User:RussBot/Invalid redirect hatnotes/001, which I only discovered after starting work on this cleanup task. So now we have part of that bot's functions being done in real-time here. Wbm1058 (talk) 15:55, 26 August 2014 (UTC)Reply
Will this category also catch instances of people adding a hatnote that, for example, says that "Computer" redirects to "Computer"? bd2412 T 01:56, 27 August 2014 (UTC)Reply
I noticed that there were cases that the bot was flagging that were not being categorized as either missing or invalid redirects. Maybe the next bot run will help us spot the cases that are not getting categorized yet. Wbm1058 (talk) 11:56, 28 August 2014 (UTC)Reply
That instance isn't caught currently. Let me make a quick list of all the possibilities I can think of:
  1. The first parameter specifies a page which doesn't exist (covered in Category:Missing redirects)
  2. The first parameter specifies a page which does exist, but isn't a redirect (not covered)
  3. The first parameter specifies the current page (not covered)
  4. The first parameter specifies a redirect that goes somewhere other than the current page (covered in Category:Invalid redirects)
  5. The first parameter specifies an invalid title (not covered)
These would all be fairly easy to add categories for. Maybe put no. 2 in Missing redirects, and nos. 3 and 5 in Invalid redirects? — Mr. Stradivarius ♪ talk ♪ 12:23, 28 August 2014 (UTC)Reply
And another possibility (no. 6) - cross-namespace redirects to mainspace where the "selfref" option isn't set. Not sure if this is very common though, and would probably need a separate category. Thoughts? — Mr. Stradivarius ♪ talk ♪ 12:27, 28 August 2014 (UTC)Reply

Category:Redirects to the main namespace has just 43 members, but I don't know whether there is anything checking for such redirects that are missing {{R to main}} templates. Template:Selfref seems primarily intended for redirects from Main to Wikipedia project space.

No. 3 is just a special case of no. 2 – a page which does exist, but isn't a redirect. The current page must exist to have a hatnote on it. I would put them all in the invalid category. No. 5 is a special case of no. 1 – an invalid title can't exist by definition. I'm thinking those should be missing – a page that needs to be created like red-links (but can't be). But these would be rare, and could go in either category. I don't think it matters that much which. – Wbm1058 (talk) 18:05, 28 August 2014 (UTC)Reply

@Wbm1058: there's no problem with having redirects from other namespaces to mainspace per se. The problem is that when you have a redirect from another namespace to mainspace, and you highlight that fact with the {{redirect}} template, the text at the start of the hatnote says "Wikipedia:Foo redirects here". If the hatnote div doesn't have the "selfref" class, then this will show up in print versions of articles, etc., which we want to avoid. Now, all the hatnote templates that have been converted to Lua have a |selfref=yes parameter (currently undocumented here, sorry), which adds the selref class to any hatnote that specifies it. So my thought was that we could output a category on pages where this happened so that we could fix them. But on typing this out, I've realised the more obvious solution - we can just add the selfref class in the module for cross-namespace redirects like this without having to worry about outputting categories at all. I'll go and add that code in now.

As for your other error category suggestions, they all sound sensible, and I'll add those to the module as well. — Mr. Stradivarius ♪ talk ♪ 07:39, 5 September 2014 (UTC)Reply

@Mr. Stradivarius: Great. Bream was restored as an article on 16 August 2014. User:RussBot/Invalid redirect hatnotes picked up the fact that Common bream has an invalid hatnote, but that wasn't categorized. – Wbm1058 (talk) 21:25, 24 September 2014 (UTC)Reply
@Wbm1058: I hadn't got around to finishing the test cases and updating the module. I've done it now, and Common bream is now in Category:Invalid redirects. — Mr. Stradivarius ♪ talk ♪ 02:00, 25 September 2014 (UTC)Reply
Thanks! That reported some forty or so more pages with redirect issues, and I've fixed most of them. No issues with the module code, it's working very well. – Wbm1058 (talk) 18:53, 25 September 2014 (UTC)Reply

For the record, following Wikipedia:Categories for discussion/Log/2015 February 21, the tracking category has been moved from "invalid redirects" to Category:Articles with redirect hatnotes needing review. – Fayenatic London 11:30, 2 March 2015 (UTC)Reply

Bug with "other uses"

edit

{{redirect|Paper folding|other uses|Paper folding (disambiguation)|other uses of Origami|Origami (disambiguation)}}

gives:

"Paper folding" redirects here. For other uses, see Paper folding (disambiguation).

Live example:

When the second parameter equals "other uses", the fourth and subsequent parameters are ignored. -- [[User:Edokter]] {{talk}} 12:15, 12 November 2014 (UTC)Reply

@Edokter: I seem to remember I wrote it like that to stop it from outputting things like '"Paper folding" redirects here. For other uses, see Foo. For other uses, see Paper folding (disambiguation).' I was assuming that the natural way to phrase things like this would be '"Paper folding" redirects here. For other uses of Origami, see Origami (disambiguation). For other uses, see Paper folding (disambiguation).' But perhaps the module shouldn't force the order like this? — Mr. Stradivarius ♪ talk ♪ 14:12, 12 November 2014 (UTC)Reply

I'm stumped

edit

Why is Wikipedia:Requested moves in Category:Invalid redirects? I cannot figure out what's causing this categorization. It's been there for nearly a month now, as I recall. – Wbm1058 (talk) 19:42, 28 February 2015 (UTC)Reply

Given that the category doesn't appear on Wikipedia:Requested moves itself, and that Wikipedia:Requested moves persisted in Category:Invalid redirects after I gave both pages a null edit, this looks like a MediaWiki bug rather than a module bug. Try filing a report in Phabricator to get one of the devs to look at it. Also, pinging Anomie as I remember he was interested in investigating a similar bug before. — Mr. Stradivarius ♪ talk ♪ 01:42, 1 March 2015 (UTC)Reply
The page that's in the category is this one, one of the pages created due to phab:T87645. The simplest thing to do for that particular case might be to use the API action=delete with pageid rather than title to just delete it. Anomie 21:21, 1 March 2015 (UTC)Reply
I'm glad someone had picked this up. I've processed the renaming of the category to Category:Articles with redirect hatnotes needing review but that RM page is still in the old one. I'll leave it to you to follow it up, as you seem to have more technical knowledge than me. – Fayenatic London 11:32, 2 March 2015 (UTC)Reply
I've just deleted the phantom page. Thanks to Anomie for pointing out what to do. :) — Mr. Stradivarius ♪ talk ♪ 13:08, 2 March 2015 (UTC)Reply

Multiple redirects

edit

To implement more of the redirect hatnotes with this module, I've started work on some tweaks in the sandbox that change the module a bit. To summarize:

  • An invocation argument is added to the p.redirect function, specifying a number of redirects to look for (defaulting to 1)
  • The redirect variable is assumed throughout to be a table of strings instead of a string.

I'm not quite done; some of the code hasn't been tweaked yet, i.e. the tracking category and options sections towards the end. Also, I'm a total newbie to Lua, so there's a decent chance I've inserted bugs somewhere. Anyway, I've got to go do other things for a bit, so I figure this is the natural time to ask for input on the tweaks I've started on. Questions, comments, ideas? Have I broken everything forever? :) {{Nihiltres |talk |edits}} 19:57, 24 March 2016 (UTC)Reply

I think it's probably ready to deploy, but I'd appreciate it if someone can take a look over the changes first and give a thumbs up. {{Nihiltres |talk |edits}} 22:51, 27 March 2016 (UTC)Reply

Desirable defaulting behaviour?

edit

I've written some code, now available as an alpha module at Module:Hatnote list, intended to centralize the mechanism for generating the lists of "For X, see [[Y]]" statements that are used in templates like {{about}}, {{redirect}}, and their variants. I based it on {{about}}'s behaviour, assuming that they were the same, but … when examining the results as applied to {{redirect}}, using Module:Redirect hatnote/sandbox and Template:Redirect/testcases, I noticed this discrepancy:

Compare the behaviour found in {{about}}:

The behaviour is definitely intended, based on the isFirst parameter of formatUseTable() (see in particular lines 102–110) that sets the behaviour differently for the first item in the use table, such that:

It seems odd. I'd prefer to simplify things by getting rid of the isFirst behaviour; it seems awkward and it means you can't conveniently end a template with |other uses}}, or even with ||REDIRECT (disambiguation)}}, to produce a terminal "For other uses, see [[REDIRECT (disambiguation)]]":

  • {{redirect|REDIRECT|USE1|PAGE1|other uses}}
  • {{redirect|REDIRECT|USE1|PAGE1||REDIRECT (disambiguation)}}
  • {{redirect/sandbox|REDIRECT|USE1|PAGE1|other uses}}
  • {{redirect/sandbox|REDIRECT|USE1|PAGE1||REDIRECT (disambiguation)}}

Of course, I could be completely wrong, hence bringing this up for discussion rather than changing this unilaterally—so, is there a good reason it does and should default that way? Are there a significant number of pages making use of the behaviour? {{Nihiltres |talk |edits}} 03:52, 11 April 2016 (UTC)Reply

I think you're right to use {{about}} as the gold-standard for hatnote syntax and behavior. I believe that any inconsistencies likely arose from the original templates being coded at different times by different people, though I haven't analyzed the history in depth, and the original port to Lua modules simply maintained the existing inconsistencies. I'm not quite following what you're saying, putting the differences in terms of module logic, but as I'm well aware of a significant difference, I'll explain that below, and you can confirm whether we're on the same page.
I often encounter simple {{redirect}} hatnotes such as this:
{{redirect|Module talk:Redirect hatnote/doc|hats|Hat}}, which displays this:
Sometimes the hatnote states the obvious, such as when the title of the article "redirects" to the title of the article. I simplify those by replacing {{redirect}} with {{for}}:
{{for|hats|Hat}}, which displays this:
...which is equivalent to: {{about||hats|Hat}}
But when there is a second "For X, see [[Y]]" statement:
{{redirect|Module talk:Redirect hatnote/doc|hats|Hat|notes|Note}}, which displays this:
{{for|hats|Hat|notes|Note}} displays this:
so I need to change it to {{about}} to get the desired behavior:
{{about||hats|Hat|notes|Note}} displays this:
To get the "for" behavior in "about"
{{about||hats|Hat|and|notes|and|Note}} doesn't work. It only shows the first two:
Oh, now I see that {{for}} and {{about}} don't use Lua. But somehow this difference came to my mind. It's the inconsistency I encounter most often.
Of course, {{for| is more readable and intuitive than {{about||wbm1058 (talk) 13:42, 11 April 2016 (UTC)Reply




So, getting back to the inconsistency that you pointed out:
{{redirect|Module talk:Redirect hatnote/doc|Hats|hat|Notes}}
{{about||Hats|hat|Notes}}
Right, this is not good, but here I think the {{redirect}} behavior is preferred. I'm not even seeing this permutation of {{about}} is the documentation, so I'm not sure its use was anticipated or intended. It makes more sense to use
{{about||Hats|hat|other uses}}
if one wants to link to Redirect hatnote (disambiguation). – wbm1058 (talk) 14:37, 11 April 2016 (UTC)Reply
Getting {{for}} and {{about}} to use Lua is one of my goals, and it'll actually address one of the issues you noted:
  • {{about||USE1|PAGE1|and|PAGE2|and|PAGE3}}
  • {{about/sandbox||USE1|PAGE1|and|PAGE2|and|PAGE3}}

</noinclude>

More broadly, it'll be worth hashing out at some point the kinds of lists that hatnotes use. As I see it, there are three types: the and-list (a list of one or more pages, joined by "and" as needed), the or-list (a list of one or more pages joined by "or" as needed) and the for-see list (a list of "For X, see Y"'s, where "X" is a topic/use and "Y" is itself an and-list of target pages.) {{For}} is confusing precisely because it looks like a for-see list but behaves as an and-list. The purpose of eliminating the isFirst behaviour in {{redirect}} is to make all for-see lists act more or less the same. :)
Anyway … I think we should try adding a tracking category to check the prevalence of this usage. I'm betting that few cases use it. This use patterns itself neatly to cases where there are an odd number of arguments past the redirect arguments, so we should be able to add a quick snippet to track the behaviour:
if (#args - numRedirects) % 2 == 1 then addCategory('Hatnote templates using unusual parameters') end
We might want to use a more specific category (there's other stuff in the "unusual parameters" category already), but that would give us a good sense of existing usage. That seem like a good idea? {{Nihiltres |talk |edits}} 21:37, 11 April 2016 (UTC)Reply
Wow, another tracking cat I hadn't heard of before. Category:Hatnote templates using unusual parameters has been around since it was added to {{About}} on 26 February 2011. I'd just use that one rather than create another; we already have more tracking categories than anyone can keep track of. – wbm1058 (talk) 00:33, 12 April 2016 (UTC)Reply
Beanie (seamed cap) has been in that category since 1 April 2012. It's the only mainspace page in the cat. – wbm1058 (talk) 00:59, 12 April 2016 (UTC)Reply
This simple grammar fix cleared the category. I would have to fire up more brain cells to figure out how the {{about}} template processed that! wbm1058 (talk) 01:17, 12 April 2016 (UTC)Reply
I see, it was using Template:Str left to look for strings beginning with "is". – wbm1058 (talk) 01:32, 12 April 2016 (UTC)Reply
Yeah, strings starting with "is" and specifying argument 3 without arguments 1 or 2 (i.e. getting {{about}} to emulate {{other uses}}); mostly awkward but easily fixed stuff like this. I cleared out most of the category (~50 pages) so it'd be easier to see what was coming from our testing here. I'll add in this test when I get a chance (tomorrow?); longer-term, there'll be lots more work to make sure that hatnotes do good testing and have those tests and their tracking well-documented. I was surprised to find that category, too. {{Nihiltres |talk |edits}} 03:06, 12 April 2016 (UTC)Reply

I've implemented the tracking; now we wait a while for it to populate. Not as clever as I initially snippeted, but since things are spread across different functions—I'd forgotten that—I hacked it into the conditional that implements the isFirst behaviour, which is probably more reliable anyway. {{Nihiltres |talk |edits}} 18:46, 12 April 2016 (UTC)Reply

So far, just three in article-space:

I fixed all of them; none were legitimate uses of unusual syntax. wbm1058 (talk) 13:32, 13 April 2016 (UTC)Reply

Except, arguably, this usage is not bad. wbm1058 (talk) 13:36, 13 April 2016 (UTC)Reply
I also fixed a broken case at Whitewash. I would avoid that arguable "Soca" usage: we're already given the context since the hatnote starts with the context of "SOCA" as a redirect, so the whole hatnote's in that context, making the "For Soca" at the end redundant. For cases where neither redirect text nor the article title provide sufficient context, I'd suggest {{other uses of}}'s phrasing as preferable.
Anyway, at this point my argument for removing the isFirst behaviour basically becomes "it's a special-case behaviour that isn't actually used anywhere." We're better off if the behaviour's entirely consistent with {{about}}. {{Nihiltres |talk |edits}} 15:51, 13 April 2016 (UTC)Reply
You seem to be on the right track. I think you can implement your plan. wbm1058 (talk) 02:02, 14 April 2016 (UTC)Reply
  Done. There are two remaining, related issues to watch:
  • The isFirst variable isn't totally gone, because it also covers some early-termination logic
  • If defaulting is used multiple times, it'll default the same way each time (i.e. multiple links to "REDIRECT (disambiguation)"). This is probably ignorable, since it really shouldn't be used in practice, but it's definitely something to cover when reviewing early-termination logic later.
Anyway, that's one strange behaviour down. I'll start another talk section for the next strange behaviour, which is already tagged for tracking. {{Nihiltres |talk |edits}} 14:43, 14 April 2016 (UTC)Reply

Strange behaviour 2: "1" → "other uses" under certain conditions

edit

On to the next strange behaviour that I'd like to eliminate! This one's interesting and totally undocumented:

  • {{redirect|REDIRECT|USE1|PAGE1|1|PAGE2}}
  • {{redirect|REDIRECT|1|PAGE1}}

If a "use" field (past the first) is equal to "1", then it's automatically converted to "other uses". This is strange and undocumented enough that I've boldly changed it so that it's actually converted to "other uses[[Category:Hatnote templates using unusual parameters]]", because it's not only unexpected and useless behaviour, but also blocks review of parameter-skipping behaviours since it's tied into part of that bit itself.

I'm betting it's totally unused and totally uncontroversial to remove, but we'll want to wait at least until the category's had a chance to point out any extant uses before nuking it. {{Nihiltres |talk |edits}} 15:02, 14 April 2016 (UTC)Reply

  Removed. I'll probably focus on finishing the deletion of {{about3}} before moving on to more behaviours here. {{Nihiltres |talk |edits}} 18:22, 16 April 2016 (UTC)Reply

Strange behaviour 3: Early termination of list if first use is "other uses"

edit

Well, {{about3}} and {{about4}} are both deleted, so it's back to the "strange behaviours" elimination project…

The next strange behaviour is that if the first "use" parameter is "other uses" (exactly), the list is terminated early. This behaviour is exclusive to {{redirect}} and doesn't appear in {{about}}. An example pulled from the notes currently clogging my sandbox:

  • First use item "other uses" of two for-see statements:
    • {{redirect|REDIRECT|other uses|PAGE1|USE2|PAGE2}}
    • {{redirect/sandbox|REDIRECT|other uses|PAGE1|USE2|PAGE2}}
    • {{about|ABOUT|other uses|PAGE1|USE2|PAGE2}}
    • {{about/sandbox|ABOUT|other uses|PAGE1|USE2|PAGE2}}

</noinclude>

  • Second use item "other uses" of three for-see statements:
    • {{redirect|REDIRECT|USE1|PAGE1|other uses|PAGE2|USE3|PAGE3}}
    • {{redirect/sandbox|REDIRECT|USE1|PAGE1|other uses|PAGE2|USE3|PAGE3}}
    • {{about|ABOUT|USE1|PAGE1|other uses|PAGE2|USE3|PAGE3}}
    • {{about/sandbox|ABOUT|USE1|PAGE1|other uses|PAGE2|USE3|PAGE3}}

</noinclude>

This is implemented on lines 132–136 of the module:

if data[1] and data[1].use and data[1].use ~= 'other uses' then
	for i = 2, #data do
		text[#text + 1] = formatUseTable(data[i] or {}, false, redirect)
	end
end

I don't see why this behaviour would be desirable. It doesn't match {{about}}, it's fairly likely to be confusing (parameters simply not showing up), and it doesn't effectively enforce good style in any sense because it's trivially defeated both by non-tech-savvy users (with nonstandard phrases like "other meanings") and by tech-savvy ones:

  • {{redirect|REDIRECT|<nowiki>other uses</nowiki>|PAGE1|USE2|PAGE2}}

Am I missing any reason that this behaviour would be desirable? If so, please explain! :)

The next step in this case, as with the previous ones, is that I'll proceed to tweaking the code to tag cases using this behaviour with a category; assuming that few or no cases use the behaviour in a sensible way, I'll proceed to fix any cases and remove the behaviour, which is really simple as it'll just be a removal of a single condition (data[1].use ~= 'other uses') from the if statement on line 132. {{Nihiltres |talk |edits}} 04:20, 19 April 2016 (UTC)Reply

Keep going, you're doing great. Category:Hatnote templates using unusual parameters is ready to be temporarily repopulated. wbm1058 (talk) 13:32, 19 April 2016 (UTC)Reply
All right, categorization is churning. Initially made a small mistake and included cases where there wasn't anything to terminate early (i.e. {{redirect|REDIRECT|other uses|PAGE1}}), but fixed that quickly. Initial skim suggests most cases are unintended or parameterization mistakes, but we'll see. Fixes will probably consist of moving the "|other uses|REDIRECT (disambiguation)" parameters to the end of the template in most cases. As a side-note: I think this is probably the last "strange behaviour" completely isolated to Module:Redirect hatnote; the next bit will probably involve asking around what certain defaulting/terminating behaviours ought to be across templates with for-see lists, probably as an RfC at Wikipedia talk:Hatnote. {{Nihiltres |talk |edits}} 16:10, 19 April 2016 (UTC)Reply
Over 3 dozen snagged, I fixed some of them and saw that you did too. wbm1058 (talk) 21:11, 19 April 2016 (UTC)Reply
Yeah; seems to have involved mistakes in most cases. Most were fixed by reordering, and a few by converting to use of the and keyword, e.g. Screaming. I'll give it a little bit, in case any cases haven't been populated to the category, before clearing out the behaviour. {{Nihiltres |talk |edits}} 23:00, 19 April 2016 (UTC)Reply
  Removed. Now to go over defaulting/terminating stuff more generally… {{Nihiltres |talk |edits}} 14:34, 21 April 2016 (UTC)Reply

Standardizing for-see lists

edit

I've started a discussion at Wikipedia talk:Hatnote#Standardizing for-see lists about standardizing and centralizing the code that generates lists of "For X, see Y" items in hatnotes. The discussion may affect this page, but is located there as it's relevant to others as well. Please comment there if interested. {{Nihiltres |talk |edits}} 17:26, 27 April 2016 (UTC)Reply

Template:Redirect4

edit

Template:Redirect4 doesn't use this module yet. I just found an undetected redirect hatnote needing review. It would be nice if that was enhanced to use the module. wbm1058 (talk) 23:25, 3 May 2016 (UTC)Reply

I've avoided converting this one just yet since it includes a pages list interpreted as one parameter of wikitext, rather than as a multi-parameter list of pagenames and and keywords. This module doesn't support that behaviour. I'm working on tweaking the underlying functionality so that both {{redirect}} and {{about}} use the same Module:Hatnote list-based list-generation code, so I've held off on introducing new features until that's centralized. {{Nihiltres |talk |edits}} 00:16, 4 May 2016 (UTC)Reply

"you may be looking for"

edit

We have gazillions of hatnotes in the form {{redirect|Municipal Waste|text=You may be looking for [[Municipal solid waste]]}}, or often just manually coded entirely with :... We need a parameter to generate this wording, e.g. |lookingfor=[[Municipal solid waste]] preferably smart enough to detect if the value supplied resolves to a single page so that |lookingfor=Municipal solid waste works. Would also be nice if this worked with all the applicable templates, like {{About}}.  — SMcCandlish ¢ 😼  23:14, 30 July 2018 (UTC)Reply

Review for sandboxed changes

edit

I've put an update to this module in its sandbox. There are two main changes I've made:

  1. If the redirect title is found to not be a redirect, the new code tries to filter out cases where the page source contains "#invoke:RfD", categorizing them separately (in a yet-to-be created category) so that RfD'd redirects don't pollute the category for redirect hatnotes needing review. The filter itself is a bit obviously fragile, so if there's a better method to check for RfD status we should swap that out, but it should be good enough for now.
  2. Instead of using Module:Redirect, the new code accesses the modern redirectTitle field from mwTitle, which returns either the target title of the redirect, or false. Removing use of a separate module in favour of built-in Scribunto functionality is probably preferable, and it simplifies the code a touch.

I've added a testcase for RfD'd pages to the testcases, and tweaked a false-positive test so that it works with the new code, but the testcases could probably use some more work. I'd appreciate any review that people might offer, or critique of the approach. {{Nihiltres |talk |edits}} 20:36, 16 April 2021 (UTC)Reply

Nihiltres, thanks for making the changes. Have you noticed that Alex Trebek is in the wrong cat. A null edit had no affect, and I don't see anything obviously different from the other six articles that are in the new cat. MB 03:12, 5 May 2021 (UTC)Reply
MB, I've updated Module:Redirect hatnote; Alex Trebek is being categorized through Module:Redirect-distinguish, which I'm working on currently. It'll be fixed in minutes. :) {{Nihiltres |talk |edits}} 03:24, 5 May 2021 (UTC)Reply
OK, I've updated Module:Redirect hatnote and Module:Redirect-distinguish, a little boldly because no one commented, but that's sometimes how these things go. There might be other hatnote modules/templates to fix, but that's a good start and handles everything that was in Category:Articles with redirect hatnotes needing review. {{Nihiltres |talk |edits}} 03:29, 5 May 2021 (UTC)Reply
I should have noticed it was due to using Redirect-distinguish instead of Redirect. Now, did you notice that something else you did in Redirect-distinguish caused it to find around 40 new missing redirects (Category:Missing redirects). I fixed all the articles, so this was a good (intentional or unintentional) change. However, the category contains things not in article space. Can you exclude those consistent with other tracking categories. Thanks. MB 18:09, 5 May 2021 (UTC)Reply
  Done Before the previous edit, there must've been a logic error somewhere; I did note when making the update that I'd made the logic somewhat cleaner. {{Nihiltres |talk |edits}} 04:15, 7 May 2021 (UTC)Reply

Showing only when appropriate.

edit

@Nihiltres: Hello, I see that you are active in the development of this module, could you take a look at Template_talk:Redirect#Suggestion:_display_certain_hatnotes_only_if_the_user_has_been_redirected_from_certain_targets

I'm investigating the issue and have managed to replicate it on a private instance of mediawiki, have you ever tried to fix this issue?

I tried to apply a fix just by editing the lua code but there doesn't seem to be any useful function in the Scribunto API, could you confirm this?

A possible fix might include adding a Scribunto function that, based on the mw-redirectedfrom class, can determine whether the user has reached the article through a redirect, and what the original term was.

--TZubiri (talk) 23:45, 2 July 2021 (UTC)Reply

  • This isn't quite possible with the software as it is; the page is rendered to HTML before anyone would be redirected or not, so the template can't control its display or not directly.

    If the redirect message included an embedded stylesheet with some ugly rule like .redirect-message-hatnote {display: block !important;}, then we could perhaps hide the class of message by default and show it again when a redirect message is present … but it would require editing the interface, i.e. MediaWiki:Redirectedfrom, and I'm not sure that that message supports embedding an inline stylesheet that way.

    It's certainly not totally impossible, but it's impractical, and I think there might be pushback from the community elsewhere in that redirect messages can be useful for clarification even when a reader hasn't been directly redirected, so I'd want a serious discussion of the merits of the approach before pushing forward on interface-message-based hacks. {{Nihiltres |talk |edits}} 17:44, 6 July 2021 (UTC)Reply

Thank you for the response. Don't worry about the community pushback, there's wide consensus for this change, take a look at User:Popcornfud/The_problem_with_disambiguation_hatnotes. Also take a look at Internet access for a clear example.

Ah I understand, the HTML is generated server side by LUA from the wiki code, and we cannot generate HTML based on HTML. I also realized that the data we need is in the (requested) URL as well, I'll keep thinking of possible solutions.

--TZubiri (talk) 06:02, 9 July 2021 (UTC)Reply

TZubiri no, don't presume that there is wide community support for this based on one user space essay. olderwiser 10:51, 9 July 2021 (UTC)Reply

Not doing that, it's representative of the discussions i have read, check my contribution history to see the talk pages i have engaged TZubiri (talk) 18:05, 9 July 2021 (UTC)Reply

@TZubiri: Make a proposal, solicit feedback widely, establish direct support for it, and then we can move forward. Without community feedback, I would oppose the measure. {{Nihiltres |talk |edits}} 21:34, 12 July 2021 (UTC)Reply
@Nihiltres: I'm focusing on the technical aspects right now. If a referendum were necessary, I would rather defer it until the technical details are ironed out, since the proposal and approval processes would depend on technical aspects. For example changes to MediaWiki likely have a strict review process to implement the change.
Any more discussion than what was already had (which is plenty), would be a great way to talk about a problem instead of solving it.
I have managed to run a local WikiMedia instance and will be trying out solutions. --TZubiri (talk) 20:45, 13 July 2021 (UTC)Reply

Note, none of the functions in [1] allow for a technical solution. An option to determine whether the page was retrieved through a redirect target might be possible by extending mw.title, by returning the name of the page as it was searched, and then comparing it to the cannonical article title. Then again, this might not be the best solution, I will debug my private wikipedia instance to determine what the best solution is. --TZubiri (talk) 20:56, 13 July 2021 (UTC)Reply

Integrate {{Redirect-synonym}}

edit

That one at the moment requires manual linking and should be made to invoke this module instead. –Vipz (talk) 08:18, 14 April 2023 (UTC)Reply