Jump to content

Template talk:Last N contributions

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Feedback

[edit]

Responding to your feedback request. As a principle, you shouldn't mix positional and non-positional parameters in a template, even more so when those parameters are optional. You wrote 3= revision timestamp format, but if I use the named parameter for |2= then I get a completely different result:

|1= can stay with a positional parameter if you really want as that is a non-optional parameter, but the rest really can't. Gonnym (talk) 07:05, 23 October 2021 (UTC)[reply]

Also, and this is just my opinion in template design, you have way too many alternative names for parameters. This is really unnecessarily as editors can learn what the correct parameter name is, just as they learn what the alternative are. Additionally it makes the code more complicated and reading it unnecessarily harder. Gonnym (talk) 07:09, 23 October 2021 (UTC)[reply]
I just edit-conflicted with you and lost my entire analysis, but it's basically "I trimmed the param alternatives and simplified the code".
I also don't think we should have a "raw" variant, as if someone wants the pure raw code they likely already have that link open in a tab or window and can copy/paste it. Primefac (talk) 07:25, 23 October 2021 (UTC)[reply]
Another thought I had is that while adding named parameters makes things easier to remember, it really bloats out the call (see {{Last N contributions|Jimbo Wales|10|20030725|Talk}} vs {{Last N contributions|Jimbo Wales|num=10|ts=20030725|ns=Talk}}. I culled the named params on that ground but if there's a consensus here to only do named (with that first positional) then that's fine - the template is still new enough that it's not a huge issue to change. Primefac (talk) 07:37, 23 October 2021 (UTC)[reply]
Sorry about that EC. Do you use the new reply tool? If I'm not mistaken it should help with them. Regarding the parameters, if they are optional you have no choice but to have named parameters (unless you call them directly by their number like 3= but I doubt everyone would do that). Gonnym (talk) 08:29, 23 October 2021 (UTC)[reply]
I was creating the page so the reply tool wouldn't have done any good; I copy/pasted the wrong bit of text when it gave me the edit conflict and then lost what I had typed. No biggie.
Very good point with the parameters, as the current testcases definitely show it's a bit of a faff to line up the positional parameters. I'll re-align everything to use named params (as I was looking at the "bloated" code above, it's only about eight extra chars since everything is two-letter abbrevs). Primefac (talk) 08:41, 23 October 2021 (UTC)[reply]

Actually, I did find a good justification for multiple aliases in another situation, and a good solution for it. To avoid confusing users, especially new ones, I can see how it would be beneficial for the doc page to just mention one, good, (hopefully transparent) name for each parameter; this will be the guidance that will hopefully get all users, and especially the new ones, accustomed to the name we want to push for. In the code, though, we can include undocumented params; this is for people like me, who invoke some infobox, and take about three or four tries with |state=collapsed, |state=collapse, |collapse=yes, until I finally get it with |collapsed=yes. (Disclosure: I have no freaking idea which of these is right to this day; it should do what I want, regardless.) Anyway. Like I said before, I go for user-friendliness before code-friendliness; sometimes the user whose time you save, may be yourself! We should sweep up all the "good, but wrong guesses" in the code, with aliases. Mathglot (talk) 09:21, 23 October 2021 (UTC)[reply]

See my reply in the subsection regarding specific params (which is kind of side-tracking the "raw" discussion, hence why I want to drag it back up here).
I do agree that the /doc should list the most-likely-to-be-used parameter and really not much else, but I think that whichever "wrong but we'll make it work" parameters you add will only serve to confuse the user. While I have totally been in that "what the heck is this parameter again?" situation on multiple occasions, we shouldn't give "wrong but good enough" alternate parameters; we should teach the users which are the correct parameters to use. Most of the time alternate parameters appear because either they trigger different things (often in infoboxes for plural/singular headers) or they are the result of a template merge (wherein it is easier to have the two params rather than update every usage). When we are creating a brand-new template, there is no confusion, there are no duplicates, so we can define our parameters to be ONLY the ones we want. For example, timestamp is |ts=, end of story, nothing else will do. We shouldn't accommodate mistakes that people aren't going to make because they don't know they can make them. Primefac (talk) 09:35, 23 October 2021 (UTC)[reply]
I'll answer in general and not for this specific template. Having multiple parameters makes not only reading the code harder, but maintaining harder. Making maintaining the code harder, in turn, makes fixing bugs and adding new features take longer and be harder. That in turn makes user requested fixes and additions take longer to implement or not happen at all. Which then begs the question, is short-term user-friendliness better than long-term user-friendliness? The specific example you gave belongs to Template:Navbox. Just from a glance it looks like it has more than 40 parameters. Creating many alternatives (x3 from the example above) will make the module which is 430 lines more complicated. And 430 is not even the biggest module we have. Gonnym (talk) 09:31, 23 October 2021 (UTC)[reply]

Raw url?

[edit]

Just to split off since it's a bit of a separate issue from "setting up this template" - should it give a "raw" output of the bare url? As I said in the section above, I feel like if someone is going to or wanting to provide the raw URL (as a raw url and not piped) they'll already have the page up in a different tab or window and can just copy/paste it. Are there situations where a raw URL is desirable where a person wouldn't be in one of the mentioned situations? Primefac (talk) 08:43, 23 October 2021 (UTC)[reply]

(edit conflict) Thanks for all the feedback. My preference is always with the user, never the coder even at the expense of more complex code (of which this is hardly the worst offender), and I agree that named params are easier, so I don't mind if we switch to that. Also, a lot of users are queasy about empty positional params like in the current second example:
{{Last N contributions|Jimbo Wales|1}}
so anything that alleviates that, is a good thing in my book.
I find aliases to be highly user-friendly, and I simply don't see {{{abc|{{{def|{{{ghi|}}}}}}}}} as anything but completely transparent. There are plenty of things I find difficult in template coding, but this isn't one of them. The usefulness of aliases rises, partly because different templates maddeningly use different terms for the same parameter function. I've seen plenty of templates use |linktext=, which is far from my favorite name for this, and I only included it here to avoid frustrating users who are used to that term. Anchor is the official term in hypertext circles, but for whatever reason, that hasn't become common in Wikipedia templates; still, it has a level of official imprimatur, and anybody that knows web technology will know and instantly recognize anchor without any need for explanation, so that's a big plus. On the other hand, I've never heard of |disp=; what templates use that? If there are some, let's keep it. Afaic, we could just code that one {{{linktext|{{{anchor|{{{disp|}}}}}}}}}; afaic aliases are cheap and easy and it doesn't hurt anyone to include them.
I guess I don't feel strongly about 'raw'; I thought there might be some cases where it would be useful; if not, we can remove it. Mathglot (talk) 08:54, 23 October 2021 (UTC)[reply]
|disp= generally means "display", probably most commonly used in {{Convert}}, though I do note there are probably ten times as many templates that use |display= (I just thought brevity was better). The main issue I have with |anchor=, and the reason I changed it to disp, is that ANCHOR means something completely different on Wikipedia (which also likely explains why it's not widely used). I'm also not super-thrilled with |linktext=.
If Gonnym doesn't see any use for the raw in their next reply (if they make one) I'll trim it out. Primefac (talk) 09:28, 23 October 2021 (UTC)[reply]
Okay, you more or less persuaded me about disp (and I agree about brevity). True about {{anchor}}, also. Oh, and btw: thanks for adding urlencode; clearly better than the {{replace}}; I guess I forgot (or never knew?) that userids could have metacharacters that needed escaping. (But anyone who does that should get a trout instead of a cookie in their welcome message.) Mathglot (talk) 09:37, 23 October 2021 (UTC)[reply]

Just some commendations

[edit]

I know the first two sections above are largely "here are problems and issues", but I do want to thank Mathglot for making this template; I can already see a half-dozen places where this will be useful, and it will be a game-changer for bot requests as it will make linking to contribs so much easier! New templates always have some tweaking to do, but I just wanted to put something positive here to combat any potential negative energy floating about. Primefac (talk) 08:49, 23 October 2021 (UTC)[reply]

Piggy-backing on the (ec) above, I saw this. No worries about energy; I got my feathers ruffled a bit by the aliases thing, but there are clear improvements here, obviously; ditto Gonnym, for the positional/named mix-thing; oops! I basically created it out of necessity; I was *so* tired having to manually construct them, such as the one at the UTP you adjusted after the param name changes. My hope was that it would be useful beyond my little corner, and to hear that it would be useful to others is good enough, and things like "game-changer" are beyond my dreams... So thanks for that! Mathglot (talk) 08:57, 23 October 2021 (UTC)[reply]
I agree with Primefac about the negative vibes, I always treat code simply as code and forget to say the positives as well! Great job! Gonnym (talk) 09:19, 23 October 2021 (UTC)[reply]
Aw, shucks... Mathglot (talk) 09:22, 23 October 2021 (UTC)[reply]

When the dust settles

[edit]

Are there other things to think about, after it stabilizes? I had thought while developing it, whether there would be a reason to safesubst it, and I couldn't think of one for direct employment, but maybe some other template that invokes it might be substed, so this one should be protected? Wasn't sure, but also not pressing probably. Anything else? Mathglot (talk) 09:49, 23 October 2021 (UTC)[reply]

I see no reason for it to be subst. Primefac (talk) 14:03, 23 October 2021 (UTC)[reply]

Positional vs named

[edit]

Andrybak, can you comment on your edit? We had just about settled on named params, or so I thought. It's still early, but at some point we should figure out how to define the params. Thanks, Mathglot (talk) 17:45, 23 October 2021 (UTC)[reply]

Mathglot, I did not read any discussion here and just made the existing testcases (Special:Permalink/1051397613) work. Feel free to revert my edits. —⁠andrybak (talk) 18:38, 23 October 2021 (UTC)[reply]
@Andrybak:, I'm actually fine with your edit (I even prefer it) but there had been prior discussion that seemed to be tending in the other direction, so I was trying to solicit your opinion. As far as the testcases, this is a brand new template, and I was building the testcases (probably too soon) while the definition of the params was still in flux. So I think it's okay if the testcases fail for a little while, while the discussion is still happening. Given all that, do you have a case to make one way or the other about how the params should be defined? The way you have it now on the doc page in the parameter section looks nice and clean to me, and if others don't object, I'm happy to keep the params defined this way. I still like aliases, but that doesn't appear to be consensus. Mathglot (talk) 18:48, 23 October 2021 (UTC)[reply]
In fact, if Primefac strips out the 'raw' param as mentioned here (and I now agree with that), I vote for that version as the definitive param list. Thoughts everyone? Mathglot (talk) 19:05, 23 October 2021 (UTC)[reply]
I've dropped |raw= from the template and testcases. Mathglot (talk) 07:16, 24 October 2021 (UTC)[reply]

Good suggestions at Bots NB

[edit]

There's a discussion with good feedback and suggestions at the Wikipedia:Bots/Noticeboard. Mathglot (talk) 06:23, 25 October 2021 (UTC)[reply]

Timestamp = 'now'

[edit]

Should we allow the special token now as a legal value for |ts=, such that |ts=now would {{subst:TIMESTAMP}} into the value? Mathglot (talk) 06:29, 25 October 2021 (UTC)[reply]

Recent changes for substing

[edit]

User:Qwerfjkl, thanks for the ping on my Talk page, regarding your version to support subst'ing, currently in the sandbox. I think we should think about what it means to "subst" this template; i.e, under what circumstances would we want to do this, and what it would mean. Other than freezing the timestamp at the time the template was placed, I can't think of another reason to do it. Is that what you are going for?

If that is the case, one possibility would be to follow the suggestion in the section above, and couple that with some code blocking subst'ing of the template. Or, is there some other use case for subst'ing that I'm missing?

If there is something else, then depending how you handle the timestamp, another issue would be the word last: if you subst in a given timestamp, then the word 'last' could be misleading, and should be replaced with this/these or some other solution that avoids WP:RELTIME problems.

Finally, you'd have to finish adding the subst protection code, still incomplete in your latest sandbox version; your subst'ed sandbox test case on the testcases page shows some of the parser function code still in there post-subst. Adding Primefac, who may have some good ideas about this. Mathglot (talk) 22:14, 28 December 2021 (UTC)[reply]

@Mathglot: your subst'ed sandbox test case on the testcases page shows some of the parser function code still in there post-subst, I'm not sure what you're referring to. (The sandbox code is definitely not complete, though.) ― Qwerfjkltalk 22:30, 28 December 2021 (UTC)[reply]
If you edit the test case section you added, you will see parser code still there on the page in the subst’ed sandbox test case, including code such as {{#if:Jimbo Wales|...}} still in there. Mathglot (talk) 23:08, 28 December 2021 (UTC)[reply]
@Mathglot: I'm still not sure what you're referring to:
Normal template substituted:
{{#if:Jimbo Wales|<span class="plainlinks">[{{fullurl:Special:Contributions|offset=&limit=50&target={{urlencode:Jimbo Wales|WIKI}}&namespace={{Ifnumber|0|all|{{NAMESPACENUMBER:all:Main Page}}}}}} {{if empty||{{#if: | these | last}} 50 contributions}}]</span>}}
Sandbox template substituted:
{{Last N contributions/sandbox|user=Jimbo Wales|num=50|ts=20211228144205 |ns=|disp=}}  ― Qwerfjkltalk 10:33, 29 December 2021 (UTC)[reply]
My mistake; I was looking at the subst of the live version, not the sandbox version, so sorry for the confusion. That probably obscured the fact that your current sandbox version is not performing substitution of the template. The whole point of template substitution is that
it tells the software to permanently replace the template with the text of the template (i.e., the text that is on the template's article page when the template is added to the page). ... The next editor sees not the template call, but instead the text of the template when you saved; it does not change even if the original template is edited.
This is not the case in the current sandbox version, which does not replace the template call with the text of the template, but leaves the template call in place, albeit with expanded default parameters. Supposing someone were to edit the template to remove all the code and just replace it with "FOO", then your previously substed sandbox test case will start to display "FOO", instead of what it would have rendered at 14:39, 28 December, when that test case was added, as shown in the subsequent, 14:42 version, post-subst. In a successful subst, nothing an editor does to a template after you saved a page containing a substed version of it, will have any effect on the rendering of the page that originally contained a substed invocation of an earlier version. Your version has not been substituted, and the rendered testcases page will change every time an editor changes the template.
All that being said, I do hope you set aside further revisions of the substitution code for now, until we can get a handle on the functionality questions above, chief of which is, "should this template ever be substituted?" Imho, I think the answer to that is "no", but I'm open to hearing about use cases that would require it. Can you think of any? Mathglot (talk) 20:06, 29 December 2021 (UTC)[reply]
@Mathglot: I used a method similar to Module:Unsubst (it may possible to do this through that module - I haven't checked). I was unsure if you can 'substitute' the {{CURRENTTIMESTAMP}} without using the unsubst trick. ― Qwerfjkltalk 20:20, 29 December 2021 (UTC)[reply]
You can: {{subst:CURRENTTIMESTAMP}} = 20211229203745. By the time you read this, the saved UTC time will have moved on, but the value saved here will never change. This is essentially the core of the proposal in the section above, which is one of the reasons I think this template should not be substed. Mathglot (talk) 20:37, 29 December 2021 (UTC)[reply]
@Mathglot: I know you can subst {{CURRENTTIMESTAMP}}, but how do you transclude the template and substitute the timestamp i.e. produce the timestamp when it was placed? ― Qwerfjkltalk 20:51, 29 December 2021 (UTC)[reply]
That is what {{subst:CURRENTTIMESTAMP}} does; it produces the timestamp when it was placed (more exactly, the time it was saved), but perhaps I'm not quite understanding the question because you know that already, so I guess I'm not being very helpful at this point. It looks like I've gone about as far as I can go with this for now, and anyway, it seems like this sort of question would get better results and more participation at WT:WikiProject Templates, WP:VPT, or possibly WP:Help desk. Please ping me if you decide to raise the issue elsewhere, so I can follow along. The one aspect that should stay here, is the functional questions previously raised, and hopefully other interested editors will comment. Thanks, Mathglot (talk) 21:24, 29 December 2021 (UTC)[reply]
If, as you suggest in the section above, you implemented as |ts=now feature, how would the template change the parameter to |ts=20241127044941 (which seems to be what you're suggesting)? ― Qwerfjkltalk 22:03, 29 December 2021 (UTC)[reply]
To explain this more clearly, the code would be something like:
{{#ifeq:{{{ts|}}}|now|{{CURRENTTIMESTAMP}}|. . .}}
However, this just shows the current timestamp, as of when the page is viewed (and purged). How would this show the timestamp when the template is placed, so that if it is placed at 20211229220803, it will show |ts=20211229220803, and a day later, ts will still equal 20211229220803 - it won't update, but will be substituted, even if the template is transcluded. I apologise if I wasn't clear about this earlier. ― Qwerfjkltalk 22:11, 29 December 2021 (UTC)[reply]
Can't look at this just now, but just reflecting how I've dealt with such things in the past, sometimes the easiest solution to a problem of this nature is the low-tech solution of "solving it" in the documentation. By this I mean, just adding some explanation and an example to the /doc page, showing |ts={{subst:TIMESTAMP}}, which will do what we want in this situation, without any change to the template code. A doc page example built around this could be,
{{lnc|Jimbo Wales|ts={{subst:TIMESTAMP}} }}
So maybe a purely doc-page solution is the easiest way out of this problem, and also obviates the need for subst protection in the code. If you feel like working on something wrt the code of this template, please see the next section. Mathglot (talk) 20:11, 30 December 2021 (UTC)[reply]
I've updated the #Details and #Examples sections accordingly. Mathglot (talk) 23:59, 30 December 2021 (UTC)[reply]

Add CIDR range

[edit]

I have it in mind to update this to handle a CIDR range. For example, this link shows the last 100 Template contributions for the range "2001:569:BF37:5300:9972:3E91:940D:58D9/32" (T-contribs) but you can't use that as 'username' in the current version of the template.

I'm still mulling over the input format. We could define param |cidr= (maybe with alias: |range= ), or we could match pattern /\d\d$ at the end of the username, or even allow either one (the latter is my preference). I don't know when I'll get around to this, and if someone else wants to jump in, please do. Mathglot (talk) 10:13, 29 December 2021 (UTC)[reply]

How does {{lnc|2001:569:BF37:5300:9972:3E91:940D:58D9/32}}the last 50 contributions not work? ― Qwerfjkltalk 20:19, 30 December 2021 (UTC)[reply]
Hm, seems to work now, but not when I tried it. Wonder if I did something wrong, then? Sometimes when I copy/paste, I pick up some utf-8 or other non-visible character, which then screws up the output. If it does work, then all we have to do is document it; hooray, no template change needed, again! Mathglot (talk) 00:02, 31 December 2021 (UTC)[reply]
 Done. Thanks for your comment; doc updated accordingly. Mathglot (talk) 00:08, 31 December 2021 (UTC)[reply]

Other uses

[edit]

Found another useful area for it: SPI investigations. I don't create them very often, but I just did now, and found it helpful for the "evidence" phase of the report. Mathglot (talk) 07:16, 13 July 2023 (UTC)[reply]

New param 'new'

[edit]

New named parameter |new= has been added to the template. Adding |new=1 has the same effect as checking the box labeled Only show edits that are page creations. Mathglot (talk) 01:44, 1 July 2024 (UTC)[reply]

Bug in handling of numeric values in unnamed params

[edit]

Currently, an unnamed, numeric param (like |num= or |ts=) with leading or trailing blanks currently causes broken output. (This is actually a built-in feature of template handling, in how it handles blanks, H:PARAMETER|stripping them, or not]], in different circumstances.) In any case, this should be fixed by adding {{trim}}s in the appropriate places. For the time being, I've temporarily added something to the § Parameters and § Examples sections about this, but this should be fixed, and the doc caveats removed again. Mathglot (talk) 01:54, 1 July 2024 (UTC)[reply]