Jump to content

Template talk:Diff

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
(Redirected from Template talk:Diff/sandbox)

Sandbox and test cases

[edit]

This template now has a sandbox and test cases. If you edit this page, please verify that the test cases still work. See Wikipedia:Template test cases for more information.

Problems with the current version

[edit]

I initialised the sandbox with an old (believed to be working) version of the template. Right now, the code in the sandbox (derived from revision 208569499 of the template) works, and the code in the main template (as of revision 209445661) is wrong in the following ways:

  1. It gets the URLs slightly wrong (e.g. "Main+Page" instead of "Main_Page");
  2. It makes the links look like external links, whereas they should look like internal links.

AlanBarrett 15:00, 1 May 2008 (UTC)[reply]

I'm going to go ahead and Be Bold. The sandbox version seems to work fine, I'm going to move it to the main template page. Feel free to revert if it doesn't work out and if you have time, contact me about it. (its also a much simpler implementation of template syntax)  Atyndall93 | talk  12:35, 4 May 2008 (UTC)[reply]

White space

[edit]

White space on either side of the third '|' pipe symbol causes peculiar output:

{{diff|Main Page|204901573|202506579|Diff between two numbered versions of a page}} without white space either side of the third '|' pipe symbol:
Diff between two numbered versions of a page
{{diff|Main Page|204901573 |202506579|Diff between two numbered versions of a page}} with white space before the third '|' pipe symbol:
Diff between two numbered versions of a page
{{diff|Main Page|204901573| 202506579|Diff between two numbered versions of a page}} with white space after the third '|' pipe symbol:
Diff between two numbered versions of a page
{{diff|Main Page|204901573 | 202506579|Diff between two numbered versions of a page}} with white space both sides of the third '|' pipe symbol:
Diff between two numbered versions of a page

If one clicks on the links, the "peculiar" output links lead to a page that is different from the page linked to by the "correctly" output link.

This issue should either be corrected in the template code or the documentation should be changed to note this anomaly. This editor votes for fixing the template because all other templates appear to accept white space around '|' pipe symbols without producing anomalous output.

Trappist the monk (talk) 17:57, 8 July 2012 (UTC)[reply]

{{oldid}}

[edit]

Hi guys; I added Template:Oldid to cover the situation of linking to an old version; it seemed like I was doing that all the time and could never remember where the blank parameter in {{diff}} went! :-) I reused the code from {{diff}} rather than transcluding it through. --tiny plastic Grey Knight 14:40, 17 July 2008 (UTC)[reply]

Adding new categories

[edit]

Apparently adding new categories to this template's sub-page doesn't work for some reason. I added Category:Diff templates but it won't show up, even after purging both pages, including the category page itself. Why? HeyMid (contributions) 16:03, 26 September 2010 (UTC)[reply]

Sometimes you need to add them to the main template, in the no-include section where {{documentation}} resides, or make sure you hit purge on the documentation page. Unless you mean a different subpage, if so left us know. I hope this helps. --WolfnixTalk16:12, 26 September 2010 (UTC)[reply]
Also, In the docs section make sure it is in the includeonly section. --WolfnixTalk16:14, 26 September 2010 (UTC)[reply]
But why is it like this in this template? I tried adding it to Template:Diff/doc and purged all related pages, but it still won't show up. What makes this template different from others then? HeyMid (contributions) 16:17, 26 September 2010 (UTC)[reply]
Yes, I have already checked that. Also, I have the same problem with Template:Oldid. HeyMid (contributions) 16:22, 26 September 2010 (UTC)[reply]
Shows for me. Amalthea 16:29, 26 September 2010 (UTC)[reply]
Yes, it shows up on the main page, but when you click on the actual category, it doesn't show up there. HeyMid (contributions) 16:34, 26 September 2010 (UTC)[reply]
Oh, in the category? That's a Mediawiki thing, just wait until the job queue gets around to it (or someone (null) edits the page). See Help:Category#Adding a category by using a template. Amalthea 16:40, 26 September 2010 (UTC)[reply]
This seems to only affect sysop-protected templates; the non-protected ones show up immediately. And because of this, I am unable to null edit these pages. HeyMid (contributions) 16:43, 26 September 2010 (UTC)[reply]
No, that impression is incorrect. Amalthea 16:50, 26 September 2010 (UTC)[reply]
My impression is that you null-edited this page. I was forced to do so at Template:Diff2 for making it appear in Category:Internal link templates. Or I need more patience. HeyMid (contributions) 17:01, 26 September 2010 (UTC)[reply]
That impression is correct. ;)
And yes, jobs can take hours or days sometimes to get processed (and sometimes, in the past at least, were dropped entirely). Amalthea 17:09, 26 September 2010 (UTC)[reply]

Edit request: remove extra ampersand

[edit]

See my edit to Template:diff/sandbox. Please remove the ampersand from the first "&diff", following "fullurl:" (but not the other "&diff" following "index.php"). Just fixes a minor eyesore in the URL:

http://en.wikipedia.org/w/index.php?title=Main_Page&&diff=prev&oldid=204901573: Before
http://en.wikipedia.org/w/index.php?title=Main_Page&diff=prev&oldid=204901573: After

Vadmium (talk) 10:59, 24 February 2011 (UTC)[reply]

Good job.  Done — Martin (MSGJ · talk) 11:35, 24 February 2011 (UTC)[reply]

Why the title parameter?

[edit]

Is there any good reason why this template wants the page title as its first parameter? The "title=" part in a diff link or a link to an old version is simply ignored. You can even compare two specific versions of two completely different pages with a diff link. Is there any reason not to propose in the documentation that the first parameter be left empty for simplicity? Hans Adler 08:48, 24 April 2011 (UTC)[reply]

I've wondered that too, it seams the Wiki servers don't look at the title, just the diff numbers. 117Avenue (talk) 20:37, 24 April 2011 (UTC)[reply]
The title appears on top of the diff screen. Edokter (talk) — 00:13, 25 April 2011 (UTC)[reply]
No it doesn't. 117Avenue (talk) 01:29, 25 April 2011 (UTC)[reply]
The Main Page being the only exception (as javascript hides it). Edokter (talk) — 12:10, 25 April 2011 (UTC)[reply]
Nope, still only seeing the title parameter in the url. 117Avenue (talk) 17:44, 25 April 2011 (UTC)[reply]
Indeed the title is no longer required, but some scripts still depend on it being present (but most have since been updated as well). The documentation needs to be updated to reflect that the title is no longer mandatory. Edokter (talk) — 01:15, 26 April 2011 (UTC)[reply]
Hi, Edokter. Is the documentation regarding this ever going to be updated? Ping me back. Cheers! {{u|Checkingfax}} {Talk} 04:36, 4 January 2016 (UTC)[reply]
You can do it yourself; the /doc page is not protected. -- [[User:Edokter]] {{talk}} 11:49, 4 January 2016 (UTC)[reply]

Edit request: remove the other extra ampersand

[edit]

Another cosmetic fix similar to the one above, please see my edit to the sandbox. This removes the extra ampersand in the event that a page name is passed without a diff (i.e., it's being used like {{oldid}}). RobinHood70 talk 22:26, 26 July 2011 (UTC)[reply]

Done Dabomb87 (talk) 15:25, 30 July 2011 (UTC)[reply]

Poor documentation

[edit]

The page doesn't say what to do with the template. Apparently those characters do something somewhere if you do something, but the page doesn't say where to use them or what might happen if you do. Poor documentation. --Ring Cinema (talk) 14:29, 26 August 2012 (UTC)[reply]

Feature request: diffonly

[edit]

Could someone who's better at template logic than me please add |diffonly= as an option to this template? Many thanks. — Scott talk 12:22, 10 October 2013 (UTC)[reply]

What would be the purpose and function? How would this parameter be used?
Trappist the monk (talk) 12:59, 10 October 2013 (UTC)[reply]
Shows the diff only. See parameter documentation at Help:Diff#Linking to a diff. — Scott talk 16:48, 10 October 2013 (UTC)[reply]
Like this in the sandbox?
{{diff/sandbox|Main Page|204901573|202506579|Diffonly diff}}Diffonly diff|diffonly= not present
{{diff/sandbox|Main Page|204901573|202506579|Diffonly diff |diffonly=}}Diffonly diff |diffonly= present but empty
{{diff/sandbox|Main Page|204901573|202506579|Diffonly diff |diffonly=sam}}Diffonly diff |diffonly= present and assigned anything but yes
{{diff/sandbox|Main Page|204901573|202506579|Diffonly diff |diffonly=yes}}Diffonly diff |diffonly=yes
Trappist the monk (talk) 17:22, 10 October 2013 (UTC)[reply]
Yes, that's great. — Scott talk 18:19, 10 October 2013 (UTC)[reply]
Done.
Trappist the monk (talk) 20:00, 10 October 2013 (UTC)[reply]
Wonderful! Thanks very much. — Scott talk 21:58, 10 October 2013 (UTC)[reply]

readability

[edit]

I found I had a very hard time in reading the examples in the Code column, trying to keep straight which parts were variable and which were constant. I have

  • italicized the variables[1]
  • bolded "Diff"[1,2]
  • bolded and underlined the constant parameters
  • bolded and underlined the double pipes where there is an empty parameter.

1. as is already done in § Usage

2. though this only shows up in Template talk:Diff, not in Template talk:Diff/doc

If you would like to discuss this with me, please {{ping}} me. --Thnidu (talk) 01:56, 15 December 2014 (UTC)[reply]

No way to suppress displaying "&=[oldid]"

[edit]

No matter how I set the parameters, I can't get rid of &oldid=[oldid number] .

{{diff|Southern_American_English |prev |443805461| Revision as of 03:54, 9 August 2011}}
{{diff|Southern_American_English |prev |443805461| foobar}}
{{diff|Southern_American_English |prev |443805461| foobar| diffonly=yes}}

produces


The example on the doc page works (and of course initial capital or small letter in the template name doesn't matter):

  • {{Diff|Wikipedia:Pagediff |204934693 |204901573| Diff between two numbered versions of a Pagediff page in Wikipedia namespace}}

produces

but

  • {{Diff|Southern American English |443485171 |443805461| foobar}}

yields

instead of the link labeled just "foobar".


It's not a question of whether the first id parameter is more recent than the second one, as in the example (204934693 > 204901573), or older, as in mine (443485171 < 443805461). If I swap mine into newer-older order, it still happens:

  • {{Diff|Southern American English |443805461 |443485171 |foobar}}

produces


Is the template supposed to work differently in Wikipedia namespace? It shouldn't, and the doc sure doesn't mention it. Can someone please fix this?? --Thnidu (talk) 16:27, 11 June 2015 (UTC)[reply]

White space is important. The template is creating an external wikilink. That space after 'prev' ends the external link and begins the linked text:
{{diff|Southern_American_English |prev |443805461| Revision as of 03:54, 9 August 2011}}
<span class="plainlinks">[//en.wikipedia.org/w/index.php?title=Southern_American_English&diff=prev&oldid=443805461 Revision as of 03:54, 9 August 2011]</span>
Here are your examples without white space:
{{diff|Southern_American_English|prev|443805461|Revision as of 03:54, 9 August 2011}}
Revision as of 03:54, 9 August 2011
{{diff|Southern_American_English|prev|443805461|foobar}}
foobar
{{diff|Southern_American_English|prev|443805461|foobar|diffonly=yes}}
foobar
Trappist the monk (talk) 16:42, 11 June 2015 (UTC)[reply]
@Thnidu and Trappist the monk: I've updated the template to no longer be sensitive to leading and trailing whitespace in the parameters. --Krinkle (talk) 17:02, 11 June 2015 (UTC)[reply]
Ah! Thank you! --Thnidu (talk) 18:00, 11 June 2015 (UTC)[reply]
especially since I find long solid strings of code extremely hard to read - and on a smart phone! - so I tend to insert spaces before the pipes. --Thnidu (talk) 18:17, 11 June 2015 (UTC)[reply]
@Krinkle and Trappist the monk: I was still finding the examples hard to use as models, so I added pseudocode to the table. --Thnidu (talk) 05:05, 12 June 2015 (UTC)[reply]

Template-protected edit request on 4 January 2016

[edit]

Edit the template so page version values can be put in either the 1st or 2nd parameter position and the template will automatically ensure that the largest page version value is used as the latest page version when creating the rendered Diff page. Ping me back. Cheers! {{u|Checkingfax}} {Talk} 02:32, 4 January 2016 (UTC)[reply]

{{u|Checkingfax}} {Talk} 02:32, 4 January 2016 (UTC)[reply]

Please make your edits in the Template:Diff/sandbox, verify the Template:Diff/testcases, then reactivate your edit request when ready. — xaosflux Talk 02:45, 4 January 2016 (UTC)[reply]

added title= ?

[edit]

@Edokter: You've modified the code, but you haven't documented what's new. Please do so! I can't tell from the code how it's to be used, and I shouldn't have to; that's what user documentation is for. --Thnidu (talk) 19:58, 10 April 2016 (UTC)[reply]

In essence, nothing has changed. You normally use unnamed parameters, but I added 'title' as an option to be used as a named paramenter (because that what's usually in an URL). -- [[User:Edokter]] {{talk}} 20:20, 10 April 2016 (UTC)[reply]
@Edokter: You've answered my question but you haven't solved the problem. The documentation now mentions the title parameter in a half-dozen places or so, but it's nowhere in the examples. For instance,
Code Output
{{Diff|title=Main Page|204901573|202506579|Diff between two numbered versions of a page}}
{{Diff|page|diff|oldid|label}}
Diff between two numbered versions of a page
  • The title= parameter (parameter number 1) should be a name of a page, for instance Main Page.
  • The diff= parameter (parameter number 2) should be the larger revision number.
  • The oldid= parameter (parameter number 3) should be the smaller revision number.
The example should show the title parameter in use, but it doesn't. It's not hard for me to figure out, but I've been a Wikipedian for ten years. Please edit it in appropriately everywhere you mention it. Besides the quotation above, it's needed in
Usage
{{Diff|page|diff|oldid|label|diffonly=yes}}
  • title – The title of the page (optional in most cases).
Diff between two numbered versions of a page
  • Code:
{{Diff|Main Page|204901573|202506579|Diff between two numbered versions of a page}}
{{Diff|page|diff|oldid|label}}
  • Output:
  • The title= parameter (parameter number 1) should be a name of a page, for instance Main Page.
  • The diff= parameter (parameter number 2) should be the larger revision number.
  • The oldid= parameter (parameter number 3) should be the smaller revision number.
Diff between two numbered versions of a page in Wikipedia namespace
  • Code:
{{Diff|Wikipedia:Pagediff|204934693|204901573|Diff between two numbered versions of a page in Wikipedia namespace}}
{{Diff|page|diff|oldid|label}}
  • Output:
  • The title= parameter (parameter number 1) should be a name of a page, for instance Wikipedia:Pagediff.
  • The diff= parameter (parameter number 2) should be the page revision to appear on the right (proposed change).
  • The oldid= parameter (parameter number 3) should be the page revision to appear on the left (original).
Comparison display without page display of two numbered versions of a page
  • Code:
{{Diff|Main Page|204901573|202506579|Comparison display without page display of two numbered versions of a page |diffonly=yes}}
{{Diff|page|diff|oldid|label|diffonly=yes}}
  • Output:
Comparison display without page display of two numbered versions of a page
  • The title= parameter (parameter number 1) should be a name of a page, for instance Main Page.
  • The diff= parameter (parameter number 2) should be the larger revision number.
  • The oldid= parameter (parameter number 3) should be the smaller revision number.
  • The diffonly= parameter, which must include the parameter name, can only be set to yes
TemplateData
In the first row of the table.
Please {{Ping}} me to discuss. --Thnidu (talk) 19:22, 23 April 2016 (UTC)[reply]
@Thnidu: That is because it continues to work as an unnamed parameter. No need to use it explicitly. -- [[User:Edokter]] {{talk}} 19:33, 23 April 2016 (UTC)[reply]
@Edokter: By that argument there's no need to mention it at all. But since the page does mention it now, the documentation must tell the user how to use it. --Thnidu (talk) 20:37, 23 April 2016 (UTC)[reply]
"page=" was also never mentioned in the examples. The only change is that the primary parameter name is now "title". -- [[User:Edokter]] {{talk}} 21:50, 23 April 2016 (UTC)[reply]

White space added in rendered page

[edit]

In a conversation on my talk page, I wrote {{diff|next|780676372|added the better link last week}}, and discovered that it rendered an extraneous space between the link and the comma:

the better link last week ,

The diff template seems to be spitting out an extraneous whitespace character. Can this be remedied? Thanks! —jameslucas ▄▄▄ ▄ ▄▄▄ ▄▄▄ ▄ 15:42, 23 May 2017 (UTC)[reply]

@JamesLucas: You're using the template in the wrong way. You should put
{{diff|Megan McKenna|next|780676372|added the better link last week}},
which yields
added the better link last week,
or alternatively
{{diff2|780676644|added the better link last week}},
which yields
added the better link last week,
Nardog (talk) 17:47, 24 August 2017 (UTC)[reply]

@Nardog:Your feedback helped me make a few mental leaps, and after some experimentation and consideration, I would actually suggest that the best end-use solution for this issue is adding a double pipe to explicitly leave the (supposedly optional) title parameter blank: For example, the code I'd write intuitively—{{diff|797054933|729192714|This instance is corrupted in multiple ways}}.—renders:

instance is corrupted in multiple ways ,

whereas the version hacked with an extra verical bar—{{diff||797054933|729192714|This instance renders and links correctly}}.—renders:

This instance renders and links correctly.

Obviously having a solution is great, and at the very least we can improve the half-assed documentation that says that title is "optional in most cases" but doesn't mention the double piping workaround. Beyond this, though, I feel like this is still too hacky a solution for a template that editors of all levels of experience should be using regularly. I have tried to get my head around Edokter's reasons for the existence of title parameter (as he was discussing back in 2011 and 2016; see above), but it's never made any sense to me. I guess my ultimate question is: is there a way we can modify the template to make the intuitive use of {{diff}} work rather than merely improve the documentation? Thanks —jameslucas ▄▄▄ ▄ ▄▄▄ ▄▄▄ ▄ 19:10, 24 August 2017 (UTC)[reply]

Template-protected edit request on 23 August 2017

[edit]

This template is adding extra whitespace at the end, which is problematic if the template is followed by a comma or fullstop. I noted this problem 3 months ago but didn't manage to get anyone's attention. I haven't determined the solution, but I'd appreciate a fix if it's possible! —jameslucas ▄▄▄ ▄ ▄▄▄ ▄▄▄ ▄ 21:01, 23 August 2017 (UTC)[reply]

 Not done There's nothing wrong with the template. See above. Nardog (talk) 17:47, 24 August 2017 (UTC)[reply]

Substitution

[edit]

Can I ask why this template isn't substituted? It seems like a utility template like {{unsigned}} or {{done}} that doesn't need to change over time. If there is no real reason it isn't substituted, then I propose that it be substituted. Thanks, --DannyS712 (talk) 17:58, 25 March 2019 (UTC)[reply]

It would probably be better to subst with Special:Diff. I believe this template could be changed to use that easily. 50.53.21.2 (talk) 19:08, 22 August 2019 (UTC)[reply]

Possible bug added to testcases

[edit]

I have added a possibly buggy case that I found in the wild. It looks like this:

{{diff|1048880005|1048788787|undo the robot's fix}}
Live template: the robot's fix
Sandbox template: the robot's fix

The first word ("undo") is stripped. It appears that the cause may be the omission of the title parameter, which the documentation says is optional, but then the other options are each "promoted" by one level, in a way that fails poorly and does not generate an error message. I am not a fan of templates with multiple unnamed parameters, for reasons like this, unless they have significant error-checking. – Jonesey95 (talk) 15:33, 8 October 2021 (UTC)[reply]