Template talk:Redirect template

From WikiProjectMed
Jump to navigation Jump to search
WikiProject iconRedirect Template‑class
WikiProject iconThis page is within the scope of WikiProject Redirect, a collaborative effort to improve the standard of redirects and their categorization on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Note: This banner should be placed on the talk pages of project, template and category pages that exist and operate to maintain redirects.
This banner is not designed to be placed on the talk pages of most redirects and almost never on the talk pages of mainspace redirects. For more information see the template documentation.
TemplateThis template does not require a rating on Wikipedia's content assessment scale.

Template-protected edit request on 21 December 2018

Please sync changes from the sandbox: mostly cleanup/simplification of the code.

I've explained the edits in the edit summaries (starting from this edit); some of the supporting statements are here:

  • This shows that |embed= parameter is not used anywhere with value other than yes.
  • This shows that |category= parameter is totally unused.
  • {{redirect template/core}} has 0 transclusions. And there's no reason why p.core function would be invoked from anywhere else, though a regex search results in a timeout.

The way in which the namespaceCategories table is used hardly looks efficient, though I've not tried to change it; I'll look into it later if time permits. SD0001 (talk) 08:05, 21 December 2018 (UTC)[reply]

 Done — Martin (MSGJ · talk) 09:59, 2 January 2019 (UTC)[reply]
Comment: I have undone this edit since it broke the formatting of Template:Redirect template in certain circumstances when a page contains multiple transclusions of this template. I have left a message on the edit proposer’s talk page regarding my undoing of this edit. Steel1943 (talk) 21:17, 2 January 2019 (UTC)[reply]

Discussion

Moved from User talk:SD0001
 – 10:22, 3 January 2019 (UTC)

I’m hoping I pinged you properly in my undos, but if I did not, I’m letting you know that I have undone your recent changes to Module:Redirect template since a change somewhere in the aforementioned module broke the way Template:Redirect template appears when transcluded multiple times on pages in certain circumstances. Please see Template:Redirect template/testcases#Test The Honeycombs (album) for further information. Steel1943 (talk) 21:13, 2 January 2019 (UTC)[reply]

@Steel1943: Thanks for creating those testcases. Are you sure you didn't accidentally change the substed text? Despite multiple attempts, I was unable to replicate the borked view at Template:Redirect_template/testcases#Test_1. Indeed, that is simply impossible because both {{R with history}} and {{R from album}} are wrapped in different <ul><li> ... </li></ul> containers, so it's not possible that indentation of one would be affected due to the other.
See Template:Redirect_template/testcases#Redirect_template/sandbox. The "from album" is indented correctly as I said, though there's still a problem that there are 2 bullets on the sub-bullet of R with history. This can be fixed by replacing *** in the template code. This, I think, should be done on all rcat templates that use sub-bullets, because it makes semantic sense, as well as facilitates the improvements that I made in the module - which is to replace * with <ul class="rcat rcat-name"><li>...</li></ul>, which makes the markup structured, allowing for bots and scripts to identify the rcat templates from the HTML markup of the page. This would be used in improving the functionality within Twinkle to add and remove rcat templates. (I have already implemented this for articles). SD0001 (talk) 04:24, 3 January 2019 (UTC)[reply]
  • @SD0001: In all honesty, I have no guarantee that the syntax I put on the test cases are the same as what was actually there. Since substituting the template returns the module only displaying "This is a redirect.", I had to manipulate what I saw the best I could. However, I did also notice the oddity with the double ** bullets: If you believe that you have found the fix with the indention of subsequent transclusions of {{Redirect template}} after versions with lines containing asterisks (**), and the only additional fix necessary is to change ** to * in the second line ... of all templates that have multiple lines ({{R with history}} is obviously only one of many such templates), sounds like a plan. (Pinging Paine Ellsworth in the event they by some chance have a list of Rcat templates with multiple lines that utilize double bullets in the second line, or if they can provide any further input.) Steel1943 (talk) 04:33, 3 January 2019 (UTC)[reply]
  • Those were temporary "fixes" on my part until I could figure out what was going wrong. Now that you and Steel have helped me figure that out, let me also add that the changes you made had other adverse effects, which I noticed at {{R from drafts}}, an rcat-in-progress. While your changes were in effect, a colon and non-breaking space had to be added after the entry in the |name= parameter. That has also since been fixed; however, it begs the questions, "Are these changes really necessary?" and if they are, then "Why can't they be implemented in ways that don't break so many rcats in more ways than one?" Paine Ellsworth, ed.  put'r there  12:02, 3 January 2019 (UTC)[reply]
To editors Steel1943, SD0001 and MSGJ: forgot to ping ya'll. Paine Ellsworth, ed.  put'r there  12:17, 3 January 2019 (UTC)[reply]
@Paine Ellsworth: thanks for pointing that out. Fixed in the sandbox. That was an oversight on my part. Sorry. Note that I made a series of edits to the module (which were implemented in the edit request). They are all mostly unrelated, and are simply code cleanup. Only one of those edits is required for the adding the said Twinkle feature. SD0001 (talk) 13:34, 3 January 2019 (UTC)[reply]
To editor SD0001: thank you very much for that, which is illustrated at Template:R from drafts/sandbox. Now, is there a way to massage the Lua code so as not to require cleanup of all the rcats that, like R from drafts, have double-bulleted notes? And forgive me for also wondering how extensive was your testing? Could there be other issues similar to the colon-space problem that might still need fixes? Again, please let me apologize, because I used to make a lot of improvements to {{Redirect template}} and had to stop when it was converted to Lua, since I am not well-versed in Lua. So I do respect your abilities, and I might be a little overly concerned that testing isn't exhaustive. Paine Ellsworth, ed.  put'r there  20:37, 3 January 2019 (UTC)[reply]
Yes! I just figured out a way, which wouldn't require edits to the templates. Regarding testing, I can't see any problems. But for something that has 4 million transclusions, I can hardly be sure. If at all there are any issues, I'm confident they'll be minor and fixable. I encourage you to learn Lua, it's an annoying language at first, but it can be used to develop powerful and efficient templates, and needless to say with code that's much more readable. SD0001 (talk) 07:19, 4 January 2019 (UTC)[reply]

Template-protected edit request on 4 January 2019

With the last few edits in the sandbox, I am certain that I have a bug-free version. Please incorporate. Changes have been extensively tested using the newly-created Template:Redirect template/testcases, armed with this wonderful script that I was recently informed about. SD0001 (talk) 19:53, 4 January 2019 (UTC)[reply]

 Done – and that does look like one awesome script! Paine Ellsworth, ed.  put'r there  01:50, 5 January 2019 (UTC)[reply]

Visual bug with R avoided double redirect

There is some small visual bug with {{R avoided double redirect}} that I couldn't find it's origin. The bug scenario is this, when using {{R avoided double redirect}} after another redirect template on the same line, the redirect template isn't bulleted correctly. Using Arrow 2.5 as an example: This is ok:

{{Redirect category shell|1=
{{R to section}}
{{R avoided double redirect|1=Arrow: Season 2.5}}
}}

While this has the bug.

{{Redirect category shell|1=
{{R to section}}{{R avoided double redirect|1=Arrow: Season 2.5}}
}}

In this module, here is the relevant code that handles the text:

local content = string.format('\n<div class="rcat %s">\n*%sThis is a redirect%s%s.%s%s</div>',
		args.class or '',
		args.name and getPrettyName(args) or '',
		args.from and (' from ' .. args.from) or '',
		args.to and (' to ' .. args.to) or '',
		args.info and beCompatibleWithBug12974 or '',
		args.info or ''

This module uses string.format to create the string. The second "%s" is probably what is causing the issue. {{R avoided double redirect}} is different than the other redirect templates, as it uses a module, Module:R avoided double redirect, to handle the logic, but it still passes the information like the other redirect templates to {{Redirect template}} with:

  return frame:expandTemplate({title="Redirect template",
                               args={from=from,info=info,["main category"]=cat,
                                     name=(embed=="yes" and "From an avoided double redirect" or nil)}})

The arg.name that is passed to this module, comes from the arg.name here. I couldn't find where this module uses |embed=, so it might be connected to this. --Gonnym (talk) 17:52, 14 December 2019 (UTC)[reply]

@Gonnym: Module:Redirect template adds a newline at the beginning to ensure the correct rendering of bullets. The trouble is that in {{R avoided double redirect}}, the call to Module:R avoided double redirect appears as an argument to a parser function. MediaWiki parser strips whitespace characters at the beginning and end of all parser function arguments, as a result the newline added by Module:Redirect template is lost. There is no simple way to fix this, trying to add some invisible char before the #invoke causes 2 newlines to render, which is worse.
But there is one way to fix it -- do we really need this parser function call? {{#ifeq:{{FULLPAGENAME}}|Wikipedia:Template messages/Redirect pages|| ... }} First of all, Wikipedia:Template messages/Redirect pages is now a redirect pointing to Wikipedia:Template index/Redirect pages. So the code doesn't actually do what it's supposed to do. Secondly, that index page is already messy and appears in several maintenance categories. It doesn't seem important to me to have this special condition for that page. I'd suggest removing it. SD0001 (talk) 13:36, 26 February 2020 (UTC)[reply]
@SD0001:, if that's the issue there is a simple fix to it with {{If}}, which I've used in Template:R avoided double redirect/sandbox. Regarding the incorrect page name, that should really just be a parameter called |doc=. --Gonnym (talk) 08:06, 27 February 2020 (UTC)[reply]
That does it! Didn't know of that one. SD0001 (talk) 10:04, 6 March 2020 (UTC)[reply]
To editor SD0001: there is good reason to keep and maintain the exclusion code in the rcat {{R avoided double redirect}}. Since this is the only rcat that invokes a module, it is the only rcat that needs this exclusion code. We want it to appear with the other rcats in the index; however, we don't want the module invoked on the index page, and that is why the exclusion code is used in that rcat. As for the embedding, I vaguely remember a time when embedding was important, but that was long ago, and I no longer know why the embedding was needed. If things work without it, then it probably means that software development has advanced beyond the need for it. PI Ellsworth  ed. put'r there 00:58, 7 March 2020 (UTC)[reply]
@Paine Ellsworth: I seem to remember embed parameter became useless following the deprecation of {{This is a redirect}}, the older version of {{Redirect category shell}}. SD0001 (talk) 07:41, 7 March 2020 (UTC)[reply]
Good to know, SD0001! I seem to remember a lot of back-to-back software upgrades by the devs around that time. PI Ellsworth  ed. put'r there 13:58, 7 March 2020 (UTC)[reply]

"Template:R rcat" listed at Redirects for discussion

A discussion is taking place to address the redirect Template:R rcat. The discussion will occur at Wikipedia:Redirects for discussion/Log/2021 February 14#Template:R rcat until a consensus is reached, and readers of this page are welcome to contribute to the discussion. 𝟙𝟤𝟯𝟺𝐪𝑤𝒆𝓇𝟷𝟮𝟥𝟜𝓺𝔴𝕖𝖗𝟰 (𝗍𝗮𝘭𝙠) 16:17, 14 February 2021 (UTC)[reply]

Template-protected edit request on 12 December 2021

Sync with Module:Redirect template/sandbox. This adds an optional |sortkey= parameter (which would be useful for rcat templates like {{R country data}} where the sortkey is something that is generally well known. –MJLTalk 19:05, 12 December 2021 (UTC)[reply]

 Done @MJL: see 1060814851Uzume (talk) 20:59, 17 December 2021 (UTC)[reply]