Jump to content

Wikipedia talk:Lua: Difference between revisions

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
Content deleted Content added
Reverting edit(s) by 188.236.205.94 (talk) to rev. 1264061641 by ClueBot III: Vandalism (UV 0.1.6)
 
Line 6: Line 6:
|search=yes
|search=yes
|bot=ClueBot III
|bot=ClueBot III
|1={{flatlist}}
|1=
<div class="hlist center">
Current archives:
Current archives:
{{User:ClueBot III/ArchiveThis
{{User:ClueBot III/ArchiveThis
Line 27: Line 26:
* [[Wikipedia talk:Lua/Requests/Archive 1|Requests discussion]]
* [[Wikipedia talk:Lua/Requests/Archive 1|Requests discussion]]
* [[Wikipedia talk:Lua/To do/Archive 1|To do discussion]]
* [[Wikipedia talk:Lua/To do/Archive 1|To do discussion]]
{{endflatlist}}
</div>
}}
}}


== Module:Repr ==
== Colours for dark mode ==


A module sets colours for table headings by using colour names such as 'white', 'black' or hex values for text, background and cell border. This is fine for normal skins but how should it be coded to say "use the inverse colour in dark mode"? Dark mode is picking up the names and using those as absolute, where I think what I want it to say is "unless colour is specified use skin defaults for text and background" (the default for border is 'none' so that's not a problem). [[User:Nthep|Nthep]] ([[User talk:Nthep|talk]]) 15:47, 28 October 2024 (UTC)
Hi all, I've just finished writing [[Module:Repr]], a module for generating string representations of Lua object. The <code>repr</code> function works a lot like [[mw:LUAREF#mw.dumpObject|mw.dumpObject]], except that you can customise the whitespace and indentation, and the output is meant to be mostly valid Lua if you copied and pasted it back into a module. It takes its inspiration from Python's [https://docs.python.org/3/library/functions.html#repr repr] function, and is based on https://github.com/Ozzypig/repr (with heavy modification and test cases). Also there is an <code>invocationRepr</code> function for generating string representations of function invocations. If you think the module would be helpful for you, please give it a try, and let me know what you think. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr.&nbsp;Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪&nbsp;talk&nbsp;♪]]</sup> 10:50, 27 February 2021 (UTC)
:Isn't styling something that could be / should be done with template styles css?
:Is this not [[Module:Dump]]? --[[User:Izno|Izno]] ([[User talk:Izno|talk]]) 20:04, 27 February 2021 (UTC)
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 16:17, 28 October 2024 (UTC)
::It's similar to [[Module:Dump]]'s _dump function, but with some extra features: the option to choose whether or not to pretty-print tables, some extra formatting options, and the ability to generate string representations of function invocations. And it doesn't come with the "variable = " part at the start. On the other hand, it is not meant for being output on wiki pages directly, so it doesn't contain features for formatting the result in a {{tag|pre}} block etc. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr.&nbsp;Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪&nbsp;talk&nbsp;♪]]</sup> 00:47, 28 February 2021 (UTC)
::if i understood template styles, quite possibly. [[User:Nthep|Nthep]] ([[User talk:Nthep|talk]]) 16:29, 28 October 2024 (UTC)
:This probably should have been asked on [[WP:VPT]] since it has nothing to do with modules.
:[[mw:Recommendations for night mode compatibility on Wikimedia wikis]] are the official recommendations from WMF about how to deal with dark mode consideration. The relevant section is [[mw:Recommendations_for_night_mode_compatibility_on_Wikimedia_wikis#Avoid_static_values_for_inline_background_and_text_colors|this one]].
:You can probably be assisted further by providing a specific template/module of interest where you are trying to be dark-mode conscious. [[User:Izno|Izno]] ([[User talk:Izno|talk]]) 17:59, 28 October 2024 (UTC)
::And I gather this is about [[Module:Rugby league match squad]]. While you can do something of the "if this isn't defined, use the basic colors", you still need to cover your bases when it is defined. Basically you have these options in that case:
::# Remove custom color support with its obvious downside. Branding is not that important, and that's almost exclusively the reason that a module like this uses color.
::# Apply [https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/hue-rotate hue-rotate] using a TemplateStyles sheet. This will result in the branding color being incorrect but the table will be dark rather than light.
::# Forcibly override any colors inserted using TemplateStyles and <code>!important</code> while in dark mode. Anything using !important is usually considered to be [[technical debt]], but at least your table is dark.
::# Live with light mode colors for both light and dark. Which preserves the branding information but makes someone using dark mode have to put goggles on. :)
::That's it. That's the story. You won't get everything you want all in one nice package. :( [[User:Izno|Izno]] ([[User talk:Izno|talk]]) 18:08, 28 October 2024 (UTC)
:::@[[User:Izno|Izno]] thanks. I'd go for #1 but as I seem to be in a minority about colours among rugby editors, I can see it being reverted. I'll see what I can work out about template styles (have to say that what there is on the subject here and on media wiki isn't very helpful) and look at #3. [[User:Nthep|Nthep]] ([[User talk:Nthep|talk]]) 09:03, 29 October 2024 (UTC)
:::@[[User:Izno|Izno]] Thanks again. I managed to adapt [[ Module:Rugby league match squad/sandbox]] and it's calling template to use TemplateStyles ({{tl|Rugby league match squad/sandbox/styles.css}} which seems to work ok on my sandbox [https://en.m.wikipedia.org/enwiki/w/index.php?title=User:Nthep/sandbox3].
:::I'm conscious that the module isn't the greatest piece of coding and is at serious risk of becoming an unitelligible mish-mash of code and styling. I see that TemplateStyles can be called from a module using <code>frame:extensionTag</code> ([[mw:Help:TemplateStyles#How_can_Lua_modules_interact_with_styles?]]) and my thought is could all the styling could all be pulled out into TemplateStyles using <code>function p.templateStyle( frame, src )</code>? [[User:Nthep|Nthep]] ([[User talk:Nthep|talk]]) 21:23, 5 November 2024 (UTC)
::::You can do something like this at the very end of <code>main()</code>:
:::::<syntaxhighlight lang="lua">return table.concat ({
frame:extensionTag ('templatestyles', '', {src='Rugby league match squad/sandbox/styles.css'}),
return_t
});</syntaxhighlight>
::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 22:25, 5 November 2024 (UTC)
::::Yes, I would recommend placing the styles all in the sheet, at least those which can be. The above is the function call version, barring that I moved the TemplateStyles page just now. The object call version of it looks like <syntaxhighlight lang=lua>frame:extensionTag { name = 'templatestyles', args = {src='Module:Rugby league match squad/sandbox/styles.css'}}</syntaxhighlight> (which I prefer since it names the arguments to <code>extensionTag</code>). I normally just concatenate it like your general string, but of course you may need tostring the return item depending on what you're concatenating e.g. <syntaxhighlight lang=lua>local templatestyles = above_bit return templatestyles .. return_t</syntaxhighlight> [[User:Izno|Izno]] ([[User talk:Izno|talk]]) 22:45, 5 November 2024 (UTC)
:::::Thank you both for the replies, I will have a mess around and see where I get to. Doubtless I will be back with more questions. [[User:Nthep|Nthep]] ([[User talk:Nthep|talk]]) 10:52, 6 November 2024 (UTC)


== Request ==
== property used more than once on a Wikidata item ==


Please help me in creating a page Module:Sandbox/பொதுஉதவி.
I have a module [[Module:Wdtablerow/listed buildings]] which pulls data from WD including property P87 (lines 89-100). Now I've discovered that at least one of the Wikidata items e.g. {{q|Q26262664}} I am pulling this property from has two instances of P87. The module only pulls the first use of P87. How do I call all the uses of P87? [[User:Nthep|Nthep]] ([[User talk:Nthep|talk]]) 14:19, 28 February 2021 (UTC)
[[User:பொதுஉதவி|பொதுஉதவி]] ([[User talk:பொதுஉதவி|talk]]) 05:48, 1 November 2024 (UTC)
:I presume that you mean P84? Because you are using [[Module:Wd]] to interface to Wikidata, isn't your question best asked at [[Module talk:Wd]]?
:[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:53, 28 February 2021 (UTC)
:I've gone ahead and made the page at [[Module:Sandbox/பொதுஉதவி]]. I assume the title blacklist was the only issue? [[User:Aidan9382|Aidan9382]] <sub>([[User talk:Aidan9382|talk]])</sub> 08:33, 1 November 2024 (UTC)
::I did and I will. [[User:Nthep|Nthep]] ([[User talk:Nthep|talk]]) 16:10, 28 February 2021 (UTC)


== Using #invoke in mainspace, as an alternative to templates ==
== Module:Infobox ==


I've come across [[List of common misconceptions]], which uses <code><nowiki>{{#invoke:cite web|}}</nowiki></code> instead of using {{tl|cite web}} (and other CS1 templates) directly. Is this a good idea, or discouraged? --<span style="text-shadow:grey 0.15em 0.15em 0.1em">[[User:Yodin|Yodin]]</span><span style="text-shadow:grey 0.25em 0.25em 0.12em"><sup>[[User talk:Yodin|T]]</sup></span> 18:15, 17 November 2024 (UTC)
I recently updated bs.wiki's version of [[:bs:Modul:Infobox|Module:Infobox]] to [[Module:Infobox]] with some argument mapping, and I noticed some strange behavior when embedding infoboxes. See [[:bs:Korisnik:Srđan/ugraditest|Korisnik:Srđan/ugraditest]] and [[User:Srđan/test1]]. There seem to be two extra empty HTML rows between the fields "Instrumenti" and "Rođenje" (analogous to "Instruments" and "Born") whereas on en.wiki it looks like something (perhaps [[Module:Infobox#L-15|lines 15]]–[[Module:Infobox#L-62|62]]?) is applying &nbsp;{{code|<nowiki>style="display:none"</nowiki>}}&nbsp; to one of them, but I can't for the life of me figure out why it isn't doing that on bs.wiki. Could someone take a look, please? – [[User:Srđan|Srđan]] ([[User talk:Srđan|talk]]) 17:35, 7 March 2021 (UTC)
: It's a necessary evil when working with huge articles that would otherwise exceed the [[WP:PEIS|post-expand include size]]. Otherwise it's discouraged. [[User:Pppery|* Pppery *]] [[User talk:Pppery|<sub style="color:#800000">it has begun...</sub>]] 18:18, 17 November 2024 (UTC)
== Infobox styling ==
Infobox of mni.wikipedia is align on left as in [[:mni:ꯏꯝꯐꯥꯜ|ꯏꯝꯐꯥꯜ]] can anyone help to align it(infobox) on right side of a page as in other wikis.[[User:Luwanglinux|<span style="color:red">ꯂꯨꯋꯥꯡ</span><span style="color: blue"></span>]] ([[User talk:Luwanglinux|<span style="color: green">ꯆꯥ</span>]]) 16:12, 15 March 2021 (UTC)
:{{ping|Luwanglinux}} Your Common.css does not have any content. --[[User:Izno|Izno]] ([[User talk:Izno|talk]]) 16:31, 15 March 2021 (UTC)
:
:{{ec}}
:Not likely a Lua problem. I think that at en.wiki, [[MediaWiki:Common.css#L-334|this bit of css]] (particularly [[MediaWiki:Common.css#L-343|line 343]]) is what renders infoboxes at the right side of the displayed page. There is an equivalent page at mni.wiki but it is empty: [[:mni:MediaWiki:Common.css]].
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 16:33, 15 March 2021 (UTC)
::Can you pliz help with this interface problem[[User:Luwanglinux|<span style="color:red">ꯂꯨꯋꯥꯡ</span><span style="color: blue"></span>]] ([[User talk:Luwanglinux|<span style="color: green">ꯆꯥ</span>]]) 16:41, 15 March 2021 (UTC)
:::I don't have the necessary permission to edit interface pages at mni.wiki so you will have to find someone who does. The simple test is to copy or import [[:en:MediaWiki:Common.css]] to [[:mni:MediaWiki:Common.css]].
:::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 16:48, 15 March 2021 (UTC)
== Template error ==
Hi guys here I am again seeking for a solution ..there seems to be a bug in speciesbox or taxobox in mni.wikipedia,showing annoying ";" template which can't be created either like this [[:mni:ꯀꯕꯣꯀꯩ]] and this [[:mni:ꯅꯣꯡꯁꯥ]][[User:Luwanglinux|<span style="color:red">ꯂꯨꯋꯥꯡ</span><span style="color: blue"></span>]] ([[User talk:Luwanglinux|<span style="color: green">ꯆꯥ</span>]]) 13:37, 25 March 2021 (UTC)


== Output unreadable with "2-ary truth table" template ==
:You will probably want to ask at that module talk page, since I know those modules are generally well-watched. [[User:Izno|Izno]] ([[User talk:Izno|talk]]) 18:41, 25 March 2021 (UTC)
:Izno's advice is good. Meanwhile, the mess at the top of the infobox includes "solid red; error:colour" and the article is in categories [[:mni:Category:Taxoboxes with the error color]] and [[:mni:Category:Taxobox articles possibly missing a taxonbar]] which needs investigation. I put a simplified infobox in [[User:Johnuniq/sandbox]] ([[Special:PermanentLink/1014246397|permalink]]). It shows what should be at the top of the infobox. Very weirdly, it uses a template called <code>;</code> which cannot be viewed but which can be edited (see links in sandbox). When I tried that trick to edit the semicolon template at mni, I seemed to get the main page. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 00:25, 26 March 2021 (UTC)
::[[Template:;]] is really weird! I'm tempted to nominate it for deletion just to prevent future headaches, but based on the history it probably has been functional at some point. I'm currently running a quarry to see how many transclusions it has, since what links here is broken, but the template links table is notoriously slow. --[[User:Trialpears|Trialpears]] ([[User talk:Trialpears|talk]]) 01:29, 26 March 2021 (UTC)
::: I was able to [[Special:WhatLinksHere]] to work by visiting https://en.wikipedia.org/enwiki/w/index.php?title=Special%3AWhatLinksHere&target=Template%3A%3B&namespace=. Unfortunately, it has 434,035 transclusions. For context, the page is inaccessible due to [[phab:T238285]] [[User:Pppery|* Pppery *]] [[User talk:Pppery|<sub style="color:#800000">it has begun...</sub>]] 01:32, 26 March 2021 (UTC)
::::Looks like deletion isn't the answer then. Perhaps moving it to [[Template:Semicolon]] would be a good solution to mitigate the problem until it's properly solved. --[[User:Trialpears|Trialpears]] ([[User talk:Trialpears|talk]]) 01:43, 26 March 2021 (UTC)
:::::As noted, edirect {{no redirect|Template:Semicolon}} exists and works as a method to display Template:;. Apparently it's a method to avoid a semicolon at the beginning of a line which would be markup. But how many times is a semicolon at the beginning of a line wanted!? It appears to be due to the very mysterious {{tl|Taxobox}}. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 02:20, 26 March 2021 (UTC)
I'm too irritated by the limitations of "what links here" to track down how {{tlf|;}} is used but I'll record an item I found. [[Template:Wd/doc]] displays <code>;_</code> with an abbreviation thingamy that shows "semicolon space" (it looks like that page uses an underscore to show a visible space); wikitext: <code>&#123;{dfn|;_|title=semicolon space}}</code>. I tried previewing a plain semicolon and it breaks so {{tlf|;}} or equivalent is needed there. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 02:34, 26 March 2021 (UTC)
::The template can be viewed [https://en.wikipedia.org/enwiki/w/index.php?title=Template:; here]. [https://en.wikipedia.org/enwiki/w/index.php?search=linksto%3A%22Template%3A%3B%22&title=Special%3ASearch&profile=advanced&fulltext=1&ns0=1&ns1=1&ns2=1&ns3=1&ns4=1&ns5=1&ns6=1&ns7=1&ns8=1&ns9=1&ns10=1&ns11=1&ns12=1&ns13=1&ns14=1&ns15=1&ns100=1&ns101=1&ns108=1&ns109=1&ns118=1&ns119=1&ns446=1&ns447=1&ns710=1&ns711=1&ns828=1&ns829=1&ns2300=1&ns2301=1&ns2302=1&ns2303=1 Cirrus search] suggests only 16 direct uses, including transclusions, but it may be wrong. [https://petscan.wmflabs.org/?&since_rev0=&language=en&project=wikipedia&cb_labels_no_l=1&edits%5Bbots%5D=both&active_tab=tab_templates_n_links&interface_language=en&cb_labels_yes_l=1&search_max_results=500&edits%5Banons%5D=both&edits%5Bflagged%5D=both&ns%5B0%5D=1&cb_labels_any_l=1&templates_any=;&pagepile= Petscan] thinks there are 417397 transclusions, including indirect ones. Perhaps {{tl|;}} is used once in a widely-used template, which would explain why it is protected. [[User:Certes|Certes]] ([[User talk:Certes|talk]]) 10:47, 26 March 2021 (UTC)
:::My [https://en.wikipedia.org/enwiki/w/index.php?search=insource%3A%2F%5C%7B%5C%7B%5C%3B%5C%7D%5C%7D%2F&title=Special%3ASearch&profile=advanced&fulltext=1&advancedSearch-current=%7B%7D&ns0=1&ns1=1&ns2=1&ns3=1&ns4=1&ns5=1&ns6=1&ns7=1&ns8=1&ns9=1&ns10=1&ns11=1&ns12=1&ns13=1&ns14=1&ns15=1&ns100=1&ns101=1&ns108=1&ns109=1&ns118=1&ns119=1&ns446=1&ns447=1&ns710=1&ns711=1&ns828=1&ns829=1&ns2300=1&ns2301=1&ns2302=1&ns2303=1 count] gives 13,244 direct uses which is slightly more. I'm very tempted just to move it as the current title is very broken and I can't imagine people thinking it isn't an improvement. --[[User:Trialpears|Trialpears]] ([[User talk:Trialpears|talk]]) 13:04, 26 March 2021 (UTC)
::::I suspect 99% of uses could be subst'd. The [[Template:;/doc|documentation]] says it's used to avoid confusion with a &lt;dt> tag, by which I think they mean the wikitext for a [[H:DL|description list]], but that's only a problem at the start of a line. Of course, many templates containing {{((}}<span class="plainlinks">[https://en.wikipedia.org/enwiki/w/index.php?title=Template:; ;]</span>{{))}} might be used at the start of a line, either now or in future. [[User:Certes|Certes]] ([[User talk:Certes|talk]]) 13:13, 26 March 2021 (UTC)
::::[https://en.wikipedia.org/enwiki/w/index.php?search=hastemplate%3A%22%3B%22+insource%3A%2F%5C%7B%5C%7B+*%3B+*%5C%7D%5C%7D%2F&title=Special%3ASearch&profile=advanced&fulltext=1&advancedSearch-current=%7B%7D&ns0=1&ns1=1&ns2=1&ns3=1&ns4=1&ns5=1&ns6=1&ns7=1&ns8=1&ns9=1&ns10=1&ns11=1&ns12=1&ns13=1&ns14=1&ns15=1&ns100=1&ns101=1&ns108=1&ns109=1&ns118=1&ns119=1&ns446=1&ns447=1&ns710=1&ns711=1&ns828=1&ns829=1&ns2300=1&ns2301=1&ns2302=1&ns2303=1 13k indeed]. We should probably subst its use in any templates. Probably in most talk pages it's a typo for {{tl|;)}}.
::::The particular template is similar to another one I shipped to TFD recently which I would guess has since been kept. It had similar "accessibility" issues (in the non-technical sense). [[User:Izno|Izno]] ([[User talk:Izno|talk]]) 20:45, 26 March 2021 (UTC)
:::::[https://en.wikipedia.org/enwiki/w/index.php?search=hastemplate%3A%22%3B%22&title=Special%3ASearch&profile=advanced&fulltext=1&advancedSearch-current=%7B%7D&ns10=1&ns828=1 89 possible uses in template/module space]. [[User:Izno|Izno]] ([[User talk:Izno|talk]]) 20:47, 26 March 2021 (UTC)


[[File:"2-ary truth table" template produces hard to read text.png|thumb|The template uses Lua whose output is unreadable with Wikipedia's "Vector (2022)" dark mode skin.]]
== Date formatting outside citations ==


As you can see, [[Template:2-ary_truth_table]] uses Lua whose output is unreadable with Wikipedia's "Vector (2022)" dark mode skin. [[User:Chai T. Rex|Chai T. Rex]] ([[User talk:Chai T. Rex|talk]]) 07:39, 26 November 2024 (UTC)
Following up from [[Wikipedia:Village_pump_(technical)/Archive_187#Date_formatting_outside_citations|this VPT thread]], I've come across several instances where dates have been used in templates (like {{tl|Spoken Wikipedia}}) and I've wanted to format those dates appropriately according to whether an article is tagged with {{tl|use mdy dates}} or {{tl|use dmy dates}}. To do this, {{u|The Earwig}} mentioned that some of the code in the CS1 module would have to be moved. Would anyone who's familiar with module coding be willing to help? <span style="color:#AAA"><small>&#123;{u&#124;</small><span style="border-radius:9em;padding:0 5px;background:#088">[[User:Sdkb|<span style="color:#FFF">'''Sdkb'''</span>]]</span><small>}&#125;</small></span> <sup>[[User talk:Sdkb|'''talk''']]</sup> 05:39, 31 March 2021 (UTC)
:That would require great care to avoid stupendously high overhead when previewing or publishing an edit. I would need to remind myself to be sure but ISTR that the CS1 module loads the wikitext of the current page then parses the wikitext to decide whether to use dmy or mdy dates. If (that's ''if'') that is a good idea, it should be done once only per page, not once for every template where someone thinks it would be nice to have auto-formatting dates. My hunch is that this should be done with some software enhancement. I have occasionally wondered whether Scribunto (Lua) could allow a per-page global table that could be written and read using mw calls. That is the sort of thing that would make the idea of automatic dmy/mdy format choice feasible. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 06:53, 31 March 2021 (UTC)
::Hmm, good to know. I'm not quite sure what makes it possible to do for references but so expensive to do outside of them; I guess there's something? <span style="color:#AAA"><small>&#123;{u&#124;</small><span style="border-radius:9em;padding:0 5px;background:#088">[[User:Sdkb|<span style="color:#FFF">'''Sdkb'''</span>]]</span><small>}&#125;</small></span> <sup>[[User talk:Sdkb|'''talk''']]</sup> 10:04, 31 March 2021 (UTC)
:::I'm saying that if a reference reads and parses the whole page to get the date format, that information should be available to other modules/templates so they do not have to also read and parse the whole page. There is a way that could be arranged that would involve writing a single module to read and parse the whole page and return a table of what it finds, including the date format. The reference module would then need to use that central module by using mw.loadData which loads the table once per page no matter how many time the central module is loaded. Then another template could (via a module) also mw.loadData the table. Only the first load would involve reading and parsing the whole page. That is how references work now, but the information is part of the reference system and (I imagine, I haven't looked) is not readily available for another template. I think the first step might be a central discussion about the desirability of the scheme if it is technically feasible. For example, your link to the VPT thread did not show much enthusiasm and a comment said "automatic date formatting was abolished". [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 02:50, 1 April 2021 (UTC)
::::{{u|Johnuniq}}, ah, got it, thanks for the explanation. {{u|Redrose64}}, do you have a link to that discussion by any chance? And is what you're referring to the same thing I'm talking about here, or was it the kind of thing where users could set date format preferences? <span style="color:#AAA"><small>&#123;{u&#124;</small><span style="border-radius:9em;padding:0 5px;background:#088">[[User:Sdkb|<span style="color:#FFF">'''Sdkb'''</span>]]</span><small>}&#125;</small></span> <sup>[[User talk:Sdkb|'''talk''']]</sup> 03:04, 1 April 2021 (UTC)
:::::this is a clever idea, but i do not think it's a good one. currently, the doc page mentions mw.ext.cattools (which is not yet available on wikimedia wikis), which supposedly will allow asking if current page belongs to some category. it should be straightforward to teach these templates (e.g., {{tl|use mdy dates}}) some known category, that any module will be able to test for. it is not a good practice to read content pages from scribuntu.
:::::(offtopic disclosure: i do it myself, not for content pages but for template pages, because "templatedata" team and "scribuntu" team do not speak with each other. reading templatedata is something that modules want to do often, but unfortunately mw.templatedata scribuntu extension was not yet written. see [[phab:T107119]]).
:::::peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 00:46, 8 April 2021 (UTC)


:@[[User:Chai T. Rex|Chai T. Rex]] It already has a [[Wikipedia:TemplateStyles]] stylesheet, [[:Template:2-ary truth table/style.css]], so it's a question of editing that to include some dark mode options. Is it just the text colour in the third column that's the issue? [[User:Nthep|Nthep]] ([[User talk:Nthep|talk]]) 13:38, 26 November 2024 (UTC)
== Get User info through Lua ==
::Yes, the third column is unreadable. [[User:Chai T. Rex|Chai T. Rex]] ([[User talk:Chai T. Rex|talk]]) 21:06, 26 November 2024 (UTC)
:::If there is no further help here, ask at [[WP:VPT]] what is needed in that css page. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 01:32, 27 November 2024 (UTC)
:Fixed. [[User:Izno|Izno]] ([[User talk:Izno|talk]]) 02:23, 27 November 2024 (UTC)


== Non-Latin assistance needed ==
I'm trying to make a template that takes a username, checks how many edits it has made, and outputs it. I couldn't do that using normal templates and I am wondering whether there's a way of doing this through Lua.
--[[User:Aknell4|Aknell4]] ([[User talk:Aknell4|talk]]) 19:18, 11 April 2021 (UTC)
: In theory you could parse the wikitext of [[Wikipedia:List of Wikipedians by number of edits]] (which could be done either in Lua directly or in Wikitext using [[Module:Page]] and [[Module:String]]), but otherwise this isn't possible with Lua either. [[User:Pppery|* Pppery *]] [[User talk:Pppery|<sub style="color:#800000">it has begun...</sub>]] 21:42, 11 April 2021 (UTC)


Eyes at {{slink|Module_talk:Political_party#For_languages_not_using_latin}} would be appreciated, I am not sure how best to proceed. [[User:Primefac|Primefac]] ([[User talk:Primefac|talk]]) 14:55, 8 December 2024 (UTC)
== Fetching info for a diff ID ==

I'm trying to get the author username and date from a diff ID number for use in a template. Is there some Lua module or API that could achieve this? If not, is there some way I could fetch a revision of a page and do some string parsing on it to extract this information? [[User:SreySros|<span style="color:#2B6EC4">Sr</span><span style="color:#EA3699">ey</span> <span style="color:#EA3699">Sr</span><span style="color:#2B6EC4">os</span>]]<sup>[[User talk:SreySros|talk]]</sup> 01:56, 5 May 2021 (UTC)
:I'm pretty sure Lua cannot do this but the API can. The API would require JavaScript which is not callable from a template. In other words, I don't think you can get a template to do this. If no further comments occur here, you might try [[WP:VPT]]. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 03:58, 5 May 2021 (UTC)

== table.sort ==

I just received a note on my talk page that the players in [[Template:Atlanta Dream current roster]] were not entirely sorted by number, with 40 before 25 and 32. at first, I thought that ipairs() wasn't processing the table in order, so I tried [//en.wikipedia.org/enwiki/w/index.php?title=Module%3ASports_roster%2FWNBA&type=revision&diff=1024182782&oldid=958786652 this] which had no impact. after that, I made [https://en.wikipedia.org/enwiki/w/index.php?title=Module:Sports_roster&diff=prev&oldid=1024183863 this change] which calls the table.sort() twice instead of once and the problem was fixed. is there something wrong with my sort function or is this a known bug? thank you. [[User:Frietjes|Frietjes]] ([[User talk:Frietjes|talk]]) 16:25, 20 May 2021 (UTC)
:{{re|Frietjes}} The problem may lie in <code>(a['last'] or 'ZZZZ') < (b['last'] .. 'ZZZZ')</code>. If x['last'] == y['last'] (both "Williams", say) then this is true for both x<y and y<x, because "Williams" < "WilliamsZZZZ". (Did you mean <code>b['last'] '''or''' 'ZZZZ'</code>?) However, that comparison should only occur when the numbers are equal, which they're not. [[User:Certes|Certes]] ([[User talk:Certes|talk]]) 16:51, 20 May 2021 (UTC)
::[[User:Certes|Certes]], thank you for finding that bug. as you said, that comparison should only occur when the numbers are equal. but, when I fix that bug in the sandbox, they are now sorting correctly (see [[Template:Atlanta Dream current roster/sandbox]]) with only one table.sort()? [[User:Frietjes|Frietjes]] ([[User talk:Frietjes|talk]]) 17:08, 20 May 2021 (UTC)
::: An aside, I often create a ''fixed length sort key'' to use in sorting records/entries (ie. format numbers with leading zeroes, upper/lower case name or not depending on case sensitivity desires, code expansions, leading look ups and type of entry etc.). Since I know the lengths or each position of the key I can manipulate the original sort key accordingly to create new ones for sorting. I often used this to produce author, title, keyword indexes for manuals, catalogs, books etc. This may or not be another approach to consider. - [[User:Matroc|Matroc]] ([[User talk:Matroc|talk]]) 05:13, 25 May 2021 (UTC)

Latest revision as of 23:51, 20 December 2024

Colours for dark mode

[edit]

A module sets colours for table headings by using colour names such as 'white', 'black' or hex values for text, background and cell border. This is fine for normal skins but how should it be coded to say "use the inverse colour in dark mode"? Dark mode is picking up the names and using those as absolute, where I think what I want it to say is "unless colour is specified use skin defaults for text and background" (the default for border is 'none' so that's not a problem). Nthep (talk) 15:47, 28 October 2024 (UTC)[reply]

Isn't styling something that could be / should be done with template styles css?
Trappist the monk (talk) 16:17, 28 October 2024 (UTC)[reply]
if i understood template styles, quite possibly. Nthep (talk) 16:29, 28 October 2024 (UTC)[reply]
This probably should have been asked on WP:VPT since it has nothing to do with modules.
mw:Recommendations for night mode compatibility on Wikimedia wikis are the official recommendations from WMF about how to deal with dark mode consideration. The relevant section is this one.
You can probably be assisted further by providing a specific template/module of interest where you are trying to be dark-mode conscious. Izno (talk) 17:59, 28 October 2024 (UTC)[reply]
And I gather this is about Module:Rugby league match squad. While you can do something of the "if this isn't defined, use the basic colors", you still need to cover your bases when it is defined. Basically you have these options in that case:
  1. Remove custom color support with its obvious downside. Branding is not that important, and that's almost exclusively the reason that a module like this uses color.
  2. Apply hue-rotate using a TemplateStyles sheet. This will result in the branding color being incorrect but the table will be dark rather than light.
  3. Forcibly override any colors inserted using TemplateStyles and !important while in dark mode. Anything using !important is usually considered to be technical debt, but at least your table is dark.
  4. Live with light mode colors for both light and dark. Which preserves the branding information but makes someone using dark mode have to put goggles on. :)
That's it. That's the story. You won't get everything you want all in one nice package. :( Izno (talk) 18:08, 28 October 2024 (UTC)[reply]
@Izno thanks. I'd go for #1 but as I seem to be in a minority about colours among rugby editors, I can see it being reverted. I'll see what I can work out about template styles (have to say that what there is on the subject here and on media wiki isn't very helpful) and look at #3. Nthep (talk) 09:03, 29 October 2024 (UTC)[reply]
@Izno Thanks again. I managed to adapt Module:Rugby league match squad/sandbox and it's calling template to use TemplateStyles ({{Rugby league match squad/sandbox/styles.css}} which seems to work ok on my sandbox [1].
I'm conscious that the module isn't the greatest piece of coding and is at serious risk of becoming an unitelligible mish-mash of code and styling. I see that TemplateStyles can be called from a module using frame:extensionTag (mw:Help:TemplateStyles#How_can_Lua_modules_interact_with_styles?) and my thought is could all the styling could all be pulled out into TemplateStyles using function p.templateStyle( frame, src )? Nthep (talk) 21:23, 5 November 2024 (UTC)[reply]
You can do something like this at the very end of main():
return table.concat ({
		frame:extensionTag ('templatestyles', '', {src='Rugby league match squad/sandbox/styles.css'}),
		return_t
		});
Trappist the monk (talk) 22:25, 5 November 2024 (UTC)[reply]
Yes, I would recommend placing the styles all in the sheet, at least those which can be. The above is the function call version, barring that I moved the TemplateStyles page just now. The object call version of it looks like
frame:extensionTag { name = 'templatestyles', args = {src='Module:Rugby league match squad/sandbox/styles.css'}}
(which I prefer since it names the arguments to extensionTag). I normally just concatenate it like your general string, but of course you may need tostring the return item depending on what you're concatenating e.g.
local templatestyles = above_bit return templatestyles .. return_t
Izno (talk) 22:45, 5 November 2024 (UTC)[reply]
Thank you both for the replies, I will have a mess around and see where I get to. Doubtless I will be back with more questions. Nthep (talk) 10:52, 6 November 2024 (UTC)[reply]

Request

[edit]

Please help me in creating a page Module:Sandbox/பொதுஉதவி. பொதுஉதவி (talk) 05:48, 1 November 2024 (UTC)[reply]

I've gone ahead and made the page at Module:Sandbox/பொதுஉதவி. I assume the title blacklist was the only issue? Aidan9382 (talk) 08:33, 1 November 2024 (UTC)[reply]

Using #invoke in mainspace, as an alternative to templates

[edit]

I've come across List of common misconceptions, which uses {{#invoke:cite web|}} instead of using {{cite web}} (and other CS1 templates) directly. Is this a good idea, or discouraged? --YodinT 18:15, 17 November 2024 (UTC)[reply]

It's a necessary evil when working with huge articles that would otherwise exceed the post-expand include size. Otherwise it's discouraged. * Pppery * it has begun... 18:18, 17 November 2024 (UTC)[reply]

Output unreadable with "2-ary truth table" template

[edit]
The template uses Lua whose output is unreadable with Wikipedia's "Vector (2022)" dark mode skin.

As you can see, Template:2-ary_truth_table uses Lua whose output is unreadable with Wikipedia's "Vector (2022)" dark mode skin. Chai T. Rex (talk) 07:39, 26 November 2024 (UTC)[reply]

@Chai T. Rex It already has a Wikipedia:TemplateStyles stylesheet, Template:2-ary truth table/style.css, so it's a question of editing that to include some dark mode options. Is it just the text colour in the third column that's the issue? Nthep (talk) 13:38, 26 November 2024 (UTC)[reply]
Yes, the third column is unreadable. Chai T. Rex (talk) 21:06, 26 November 2024 (UTC)[reply]
If there is no further help here, ask at WP:VPT what is needed in that css page. Johnuniq (talk) 01:32, 27 November 2024 (UTC)[reply]
Fixed. Izno (talk) 02:23, 27 November 2024 (UTC)[reply]

Non-Latin assistance needed

[edit]

Eyes at Module talk:Political party § For languages not using latin would be appreciated, I am not sure how best to proceed. Primefac (talk) 14:55, 8 December 2024 (UTC)[reply]