Jump to content

Module talk:Userbox

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Sadko (talk | contribs) at 21:19, 19 May 2020 (Border problem). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
WikiProject iconUserboxes
WikiProject iconModule:Userbox is part of WikiProject Userboxes. This means that the WikiProject has identified it as part of the userboxes system. WikiProject Userboxes itself is an attempt to improve, grow, and standardize Wikipedia's articles and templates related to the userbox system, used on many users' pages. We need all your help, so join in today!

Template-protected edit request on 4 January 2015

Userboxes created with {{Userbox-2}} or {{Userbox-r}} are too wide if the specified border size is greater than 1px. Likewise, they are too narrow if the specified border size is zero. This bug is readily apparent in columns of multiple userboxes, as in the example floating to the right of this thread. It has already been fixed for {{Userbox}} with lines 79 and 82 of the module code:

local borderWidthNum = checkNum(args['border-width'] or args['border-s'], 1)
data.width = addSuffix(240 - 2 * borderWidthNum, 'px')

Could the same code please be coped to the vicinity of lines 125 and 177 for the sake of {{Userbox-2}} and {{Userbox-r}}? – voidxor (talk | contrib) 08:48, 4 January 2015 (UTC)[reply]

Not done: please make your requested changes to the module's sandbox first; see WP:TESTCASES. I had all the border stuff working well when it was a template. I'm not sure when or why it was all converted to lua, but please make the changes in the sandboxes and add any appropriate testcases and I'll be happy to look them over and make the changes. — {{U|Technical 13}} (etc) 12:52, 4 January 2015 (UTC)[reply]
Technical 13, I'm still new to the modules namespace and still learning to use the sandboxes and testcases. I have implemented my changes in the sandbox. The testcases look good. In full disclosure, I had to make a couple fixes or updates to the testcases. Please check those changes as well to ensure that I didn't cheat the testcases in any way. Thanks again! – voidxor (talk | contrib) 07:17, 6 January 2015 (UTC)[reply]
Note: I'm not particularly well versed in Lua either, so I prefer to leave these to other template editors that are. I know though that things like this should always be sandbox tested before being implemented. I'm reopening this request so a Lua knowledgeable template editor might be attracted to look it all over and implement it. Good luck! — {{U|Technical 13}} (etc) 14:05, 6 January 2015 (UTC)[reply]
  • I do have a question though... borderWidthNum = checkNum(args[9] or args['border-s'], 1) -- what's the default if those args aren't set? data.width = addSuffix(240 - 2 * borderWidthNum, 'px') requires the parameter to be set. How gracefully with the code fail if the borderWidthNum >= 120? How graciously will if fail if defined as 0 or < 0? — {{U|Technical 13}} (etc) 14:11, 6 January 2015 (UTC)[reply]
The default is the second parameter, which is 1. The changes look fine to me, so I'll copy them over to live. -- WOSlinker (talk) 18:41, 6 January 2015 (UTC)[reply]

Request

Please integrate the changes in the sandbox into the module. —Keφr 07:55, 6 September 2015 (UTC)[reply]

Just wondering about the colour checks, supposing I have the following userbox:
{{Userbox/sandbox
|id = [[File:Imbox_content.png]]
|id-c = black
|info = This is a test 
}}
Then it would be added to Category:Potentially illegible userboxes but it does not contain any clashing text and background colours. Could the checks be changed so that if id, id1 or id2 only contain Files or Images and no other text then the check is not done? -- WOSlinker (talk) 08:49, 6 September 2015 (UTC)[reply]
I've added Kephir's requested changes (before I saw WOSlinker's comment), but what WOSlinker says makes sense, so feel free to update the module again or reactivate the protected edit request as necessary. — Mr. Stradivarius ♪ talk ♪ 08:57, 6 September 2015 (UTC)[reply]
I refined the test to address the above. —Keφr 10:31, 6 September 2015 (UTC)[reply]
I've applied those changes. -- WOSlinker (talk) 13:26, 6 September 2015 (UTC)[reply]
Just wondering if it's really worth categorising talk pages? -- WOSlinker (talk) 19:11, 6 September 2015 (UTC)[reply]
@Kephir and WOSlinker: I've done some refactoring of the code in the sandbox so that the category code is separated out from the rendering code, and to remove the dependency on Module:Category handler. Any objections to me updating the module with it? I've also changed the module to only activate Category:Potentially illegible userboxes on user subpages, in the template namespace, and in the Wikipedia namespace. (Are there any other namespaces in which userbox templates reside?) — Mr. Stradivarius ♪ talk ♪ 07:05, 9 September 2015 (UTC)[reply]
Userboxes in User:UBX/ subpages are no longer been added to any categories with the sandbox version. -- WOSlinker (talk) 08:20, 9 September 2015 (UTC)[reply]
@WOSlinker: Which page(s) are you seeing this at? I just tested a couple of subpages of User:UBX at random and they seem to be working ok, plus I added some test cases for user subpage categories. If there's a problem with User:UBX pages then I'm not seeing it. — Mr. Stradivarius ♪ talk ♪ 08:37, 9 September 2015 (UTC)[reply]
Ah, perhaps you're looking at the code if title.namespace == 2 and title.rootText ~= 'UBX' then? That is intentional, as Module:Category handler blacklists User:UBX subpages via Module:Category handler/blacklist. You should find that the behaviour is the same as the current Module:Userbox for User:UBX subpages. The original rationale for the blacklisting code is here. — Mr. Stradivarius ♪ talk ♪ 08:47, 9 September 2015 (UTC)[reply]
I was just wondering if the UBX pages should be categorised the same as templates: elseif title.namespace == 10 or (title.namespace == 2 and title.rootText ~= 'UBX') then ? -- WOSlinker (talk) 09:31, 9 September 2015 (UTC)[reply]

Layout table edit request on 11 July 2016

Request
Copy Old revision of Module:Userbox/sandbox to Module:Userbox
Changes
Marks up the <table> as a layout table instead of a data table, by adding role="presentation" and replacing <th> with <td> (see MOS:LTAB).
Bolds the former <th>s to keep them visually the same.
There should be no visual changes (see Template:Userbox/testcases).
Users of assistive technologies will get simpler, less confusing output. For me, "Table with two columns and one rows, TS This user likes Taylor Swift, table end" becomes just "TS This user likes Taylor Swift".

Matt Fitzpatrick (talk) 05:44, 11 July 2016 (UTC)[reply]

Done — Martin (MSGJ · talk) 08:06, 11 July 2016 (UTC)[reply]

Optimize for mobile page

As Chinese Wikipedian, the .content table class may cause unexpected result on mobile page when you look at the user page, in this case every user box would display an unused whitespace at the top. You need make the following modify to fix:

local tableroot = root:tag('table')
tableroot
	:css('border-collapse', 'collapse')
	:css('width', data.width)
	:css('margin-bottom', '0')
	:css('margin-top', '0') -- add this
	:css('background', data.backgroundColor)

--Great Brightstar (talk) 09:52, 16 July 2016 (UTC)[reply]

Done This is my first edit to a template-protected page after becoming a template editor. GeoffreyT2000 (talk) 02:44, 17 July 2016 (UTC)[reply]

Template-protected edit request on 6 September 2016

Please change line 331 from this:

		root:wikitext('[[Category:Potentially illegible userboxes]]')

To this:

		root:wikitext('<noinclude>[[Category:Potentially illegible userboxes]]</noinclude>')

Currently this puts any pages transcluding potentially illegible userboxes in the category as well, making the backlog seem bigger than it is and making it hard to go through it. nyuszika7h (talk) 10:29, 6 September 2016 (UTC)[reply]

Would that code not suppress the category on the userpage itself? — Martin (MSGJ · talk) 10:55, 6 September 2016 (UTC)[reply]
Not done: please make your requested changes to the module's sandbox first; see WP:TESTCASES. Izno (talk) 11:32, 6 September 2016 (UTC)[reply]
@MSGJ: If a user page calls {{userbox}} itself with non-compliant colors, it would be categorized, otherwise only the userbox templates, which is the intended effect, as the problem in the latter case needs to be fixed in the templates, not the user pages. @Izno: Done. – nyuszika7h (talk) 11:53, 6 September 2016 (UTC)[reply]
Okay,  Implemented — Martin (MSGJ · talk) 14:02, 6 September 2016 (UTC)[reply]
Please revert the change for now, as it's broken, categorizes regardless and causes "<noinclude></noinclude>" to show up on illegible userboxes. I should have tested it, but I didn't think of using {{Userbox/sandbox}} to use the sandbox version of the module (though I've done so with another template before). I'm trying there now, but no success so far, so for now the change should be just reverted. nyuszika7h (talk) 13:13, 10 September 2016 (UTC)[reply]
Done — Andy W. (talk ·ctb) 13:55, 10 September 2016 (UTC)[reply]

Template-protected edit request on 21 August 2018

Currently, module Userbox supports up to three user categories. I suggest to upgrade the Userbox module to support up to five user categories. There are already userboxes, which pass five parameters, e.g. Template:User London. —⁠andrybak (talk) 21:51, 21 August 2018 (UTC)[reply]

 Not done: it's not clear what changes you want to be made. Please mention the specific changes in a "change X to Y" format and provide a reliable source if appropriate. — JJMC89(T·C) 03:08, 22 August 2018 (UTC)[reply]
Change following three lines:
	cats[#cats + 1] = args.usercategory
	cats[#cats + 1] = args.usercategory2
	cats[#cats + 1] = args.usercategory3
to
	cats[#cats + 1] = args.usercategory
	cats[#cats + 1] = args.usercategory2
	cats[#cats + 1] = args.usercategory3
	cats[#cats + 1] = args.usercategory4
	cats[#cats + 1] = args.usercategory5
—⁠andrybak (talk) 10:23, 22 August 2018 (UTC)[reply]
 Donexaosflux Talk 12:57, 22 August 2018 (UTC)[reply]

Template-protected edit request on 20 October 2018

Replace all instances of 240 with (args['wide'] and 482 or (args['small'] and 119 or 240)) or just replace the live version with the sandbox version. These edits allow for the use of |wide= which makes the userbox double the width of a normal userbox and |small= which make the userbox half the width of a normal userbox.

Testcases
Code Sandbox Live
{{#invoke:Userbox(/sandbox)|userbox|info=text|id=USER}}
USERThis user is a user who has user-boxes on their user-page and on their user-talk.
USERThis user is a user who has user-boxes on their user-page and on their user-talk.
{{#invoke:Userbox(/sandbox)|userbox|info=text}}
This user is a user who has user-boxes on their user-page and on their user-talk.
This user is a user who has user-boxes on their user-page and on their user-talk.
{{#invoke:Userbox(/sandbox)|userbox|info=text|id=id}}
idThis user is a user who has user-boxes on their user-page and on their user-talk.
idThis user is a user who has user-boxes on their user-page and on their user-talk.
{{#invoke:Userbox(/sandbox)|userbox-r|info=text|id=id}}
This user is a user who has user-boxes on their user-page and on their user-talk.id
This user is a user who has user-boxes on their user-page and on their user-talk.id
{{#invoke:Userbox(/sandbox)|userbox-2|info=text|id=id}}
id1This user is a user who has user-boxes on their user-page and on their user-talk.id2
id1This user is a user who has user-boxes on their user-page and on their user-talk.id2
Examples
Code Sandbox
{{#invoke:Userbox/sandbox|userbox|info=text|wide=yes|id=id}}
idThis user is a user who has user-boxes on their user-page and on their user-talk.
{{#invoke:Userbox/sandbox|userbox|info=text|wide=yes}}
This user is a user who has user-boxes on their user-page and on their user-talk.
{{#invoke:Userbox/sandbox|userbox-2|info=text|wide=yes}}
id1This user is a user who has user-boxes on their user-page and on their user-talk.id2
{{#invoke:Userbox/sandbox|userbox-r|info=text|wide=yes}}
This user is a user who has user-boxes on their user-page and on their user-talk.id
{{#invoke:Userbox/sandbox|userbox|info=text|small=yes|id=id}}
idThis is a user-page.
{{#invoke:Userbox/sandbox|userbox|info=text|small=yes}}
This is a user-page.
{{#invoke:Userbox/sandbox|userbox-2|info=text|small=yes}}
id1This is a user-page.id2
{{#invoke:Userbox/sandbox|userbox-r|info=text|small=yes}}
This is a user-page.id
Example of usage
Userbox
Userbox
Userbox
idUserbox
idUserbox
Userbox
idUserbox
id1Userboxid2
id1Userboxid2
Userboxid
id1Userboxid2
idUserbox
Userboxid
id1Userboxid2
id1Us
er
id2
Userboxid
Userbox
idUserbox

– BrandonXLF (t@lk) 18:40, 20 October 2018 (UTC)[reply]

no Declined not a helpful edit. Simply adds more complexity to an already complicated template. If you want to make a custom userbox for your userpage, then use your userspace. --Zackmann (Talk to me/What I been doing) 22:11, 22 October 2018 (UTC)[reply]
This isn't possible for a custom userbox, only a few more bytes of data, I don't see the issue. It meant to replace Template:Userbox-w and allow for a Template:Userbox-s. – BrandonXLF (t@lk) 00:22, 23 October 2018 (UTC)[reply]
 Not done: I'm neutral on the change (only a slight complication, but also doesn't appear to be used much/have a lot of utility) but since Zackman has opposed the change please gain a consensus before requesting a template-protected edit. Galobtter (pingó mió) 11:01, 24 October 2018 (UTC)[reply]
@Zackmann08 and Galobtter:, this change is useful because it would add more options to Template:Userbox-w (with 88 transclusions) sure it's not a lot but it's not a lot of code either. It also provides unification between user boxes of different sizes. I'm not sure it adds that much complexity (Zackmann08) and as making a custom user box would break the fact that this module is meant to unify user boxes. – BrandonXLF (t@lk) 12:47, 24 October 2018 (UTC)[reply]
 Not done: please establish a consensus for this alteration before using the {{edit template-protected}} template. I see no effort to gather consensus since this request was last declined for a lack of consensus. Cabayi (talk) 13:00, 28 October 2018 (UTC)[reply]
I've tagged this talk page with {{WikiProject Userboxes}} to help guide you to a venue for that discussion. Cabayi (talk) 13:05, 28 October 2018 (UTC)[reply]

Relevant discussion

There is a discussion related to this module here. – BrandonXLF (t@lk) 15:35, 28 October 2018 (UTC)[reply]

Categorize only user namespace

I noticed that the template pages transcluding Template:Userbox themselves are being placed into the user categories as opposed to user pages transcluding the templates only. (For example, Template:User de-1 is wrongly placed into Category:User de-1.) I propose that {{User other}} be used to limit the categorization to user pages only, but, not being proficient in lua, I'm not sure whether it should be implemented here in the module or at Template:Userbox. Could someone provide assistance? --Bsherr (talk) 21:01, 29 October 2018 (UTC)[reply]

It's deliberate that it includes the template in the category. For the odd occasions where it's not wanted, it can be removed by wrapping the category inside includeonly tags on that template, for example | usercategory=<includeonly>User de-1</includeonly>. It should however be setting the category sort so that it is shown at the start of the list rather than mixed in the middle. The documentation for Template:User de-1, which is at Template:User x/doc was setting a different sort value. I've update that code to set the correct sort, so now when you look at Category:User de-1, you'll see the template at the start of the list. -- WOSlinker (talk) 22:47, 29 October 2018 (UTC)[reply]

Font size

I'm not 100% sure I'm reading the code of the module correctly, but it seems like it hardcodes the font sizes for the userboxes. As part of our accessibility guidelines, WP:FONTSIZE specifies that hould be done as a percentage of the original font size and not as an absolute size. This improves accessibility and cross-platform usability. Moreover, the font size should never go below 85% of the page's default font size, and (again, correct me if I'm wrong--I'm not very familiar with Lua), but I think I see at least one place that hardcodes for an 8 pt font size, which is well below 85% of Vector's default of 11.9 pt. Can someone more experienced with Lua than I am chime in here and we can brainstorm some fixes? Cheers!! cymru.lass (talkcontribs) 02:50, 17 December 2018 (UTC)[reply]

Only add "Category:Userboxes with insufficient color contrast" to userboxes in template namespace?

Category:Userboxes with insufficient color contrast currently includes every page that transcludes a problematic userbox, instead of only the userboxes themselves (see edit request above). This reduces the category's usability to find the actual userboxes. Would a suitable solution be to only add the category for pages in the Template: namespace (which would leave out userboxes in the User: namespace, but should remove most the false positives)? –Sonicwave talk 23:09, 23 August 2019 (UTC)[reply]

An issue with this approach is that a lot of userboxes are in User namespace, like {{User:UBX/Blacksmithing}}. We could, for example, not categorize top-level user pages, like User:Example. But this would mean that subpages with userboxes (like User:Example/Userboxes) will still be categorized. I don't know how prevalent is placement of userboxes in subpages. I would guess that excluding top level user pages should take care of most of problematic categorization. —⁠andrybak (talk) 23:17, 23 August 2019 (UTC)[reply]
One might consider categorizing user pages and templates into separate categories, and top-level and subpages of user space into separate categories. --Izno (talk) 13:14, 24 August 2019 (UTC)[reply]

Template-protected edit request on 20 February 2020

I am using the compact version of Template:Userbox-2, which looks like this:

{{userbox-2|side-box 1 color|main box color|ID/icon 1|message|ID/icon 2|border color|side-box 2 color}}

When using this template in the compact state, {{{6}}} (or border color) does nothing. It clearly says in the documentation that it is supposed to change the border color. Additionally, if {{{1}}} (or side-box 1 color) is defined, setting the |border-c= parameter does nothing.

To combat this, I propose the following edit:

128.	data.borderColor = args[1] or args['border-c'] or args['id1-c'] or '#999999'

to

128.	data.borderColor = args['border-c'] or args[6] or args['id1-c'] or args[1] or '#999999'

I'm not 100% familiar with Lua, but I can see this working. --Diriector_DocTalk
Contribs
━━━┥ 06:49, 20 February 2020 (UTC)[reply]

 Done I've also changed a few other params to prefer the named params to the numbered params.

Border problem

Help needed: I can't get my userbox to show the image (35px) without the blue borders. Sadkσ (talk is cheap) 23:03, 18 May 2020 (UTC)[reply]

This user loves rasperries.
Sadko, the color around the image is the background color of the id box. It's controlled through parameter |id-c=. The color of the border around the whole userbox is controlled through |border-c=. Here I've chosen colors magenta and purple with |border-s=3 for demonstration purposes. —⁠andrybak (talk) 23:54, 18 May 2020 (UTC)[reply]
This user loves rasperries.
I understand, but is it possible to have the image stretched accross the little square (35px), without the blue border? ty, Sadkσ (talk is cheap) 00:16, 19 May 2020 (UTC)[reply]
Sadko, do you want to increase the image size to fill the id box, or something else? You could try tweaking image size. Demo below with height set to 45 pixels. —⁠andrybak (talk) 01:33, 19 May 2020 (UTC)[reply]
This user loves rasperries.
Sorry if I did not sound clear enough. My idea is for the image to fill only the are of the squares on the side (image+blue borders), so that there is no blue border left around the image and not make the added image more wide, as a large number of our userboxes are 35px. Sadkσ (talk is cheap) 21:19, 19 May 2020 (UTC)[reply]