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>
}}
}}


== Retrieving the display title value ==
== 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)
Is there a way in Lua, magic words or regular template syntax to get the Display title value of a page (which doesn't involve reading the page content)? Wondering since its a value shown in the [https://en.wikipedia.org/enwiki/w/index.php?title=ICarly_(season_6)&action=info Page information] of a page. --[[User:Gonnym|Gonnym]] ([[User talk:Gonnym|talk]]) 07:56, 20 May 2020 (UTC)
:Isn't styling something that could be / should be done with template styles css?
: See [[phab:T154738]] [[User:Pppery|* Pppery *]] [[User talk:Pppery|<sub style="color:#800000">it has begun...</sub>]] 13:18, 20 May 2020 (UTC)
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 16:17, 28 October 2024 (UTC)
::
::if i understood template styles, quite possibly. [[User:Nthep|Nthep]] ([[User talk:Nthep|talk]]) 16:29, 28 October 2024 (UTC)
:: {{re|Gonnym}} Is this sufficiently different from <code><nowiki>{{FULLPAGENAME}}</nowiki></code> to cause problems for your application?
:This probably should have been asked on [[WP:VPT]] since it has nothing to do with modules.
:: One ''workaround'' might be to use the fact that almost all articles (and some other pages) have an associated Wikidata entry that has a sitelink back to the article using its display title. So for {{q|Q10044351}}, you can use <code><nowiki>{{#invoke: WikidataIB |getSiteLink |qid=Q10044351}}</nowiki></code> to get <samp>'{{#invoke: WikidataIB |getSiteLink |qid=Q10044351}}'</samp>. Leaving out the {{para|qid}} will use the connected article for the page: <code><nowiki>{{#invoke: WikidataIB |getSiteLink}}</nowiki></code> → {{#invoke: WikidataIB |getSiteLink}}.
:[[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]].
:: Obviously it won't work on pages that don't have a connected Wikidata item. --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 16:43, 20 May 2020 (UTC)
: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)
:::If the {{tq|Display title}} is the desired result then the wikidata won't work because the displayed title is: ''iCarly'' (season 6) – italics and first character lowercase. Even if it were possible to get the displayed title, how would it be returned?
::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:
::::as wiki markup? <code><nowiki>''iCarly'' (season 6)</nowiki></code>
::# 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.
::::as html? {{code|lang=html|<i>iCarly</i> (season 6)}}
::# 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.
:::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 16:54, 20 May 2020 (UTC)
::# 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.
::::RexxS, I think maybe Wikidata might be overkill for this. The problem isn't that big, so was hoping that there might have been a simple solution. Thanks for the help guys. --[[User:Gonnym|Gonnym]] ([[User talk:Gonnym|talk]]) 17:11, 20 May 2020 (UTC)
::# 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. :)
::* Rough Lua code to parse the page content (definitely needs care (not that expensive (about 1.0 out of 50 MB)):
::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)
::** <nowiki>{{#invoke:Sandbox/Matroc/Misc|getdisplay|page=ICarly (season 6)}}</nowiki> (can be used with (safesubst) and getdisplay function can be modified as to error checking and whats to be output.
:::@[[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)
::** ''iCarly'' (season 6) -- result is <code>''iCarly'' (season 6)</code> -- [[User:Matroc|Matroc]] ([[User talk:Matroc|talk]]) 06:54, 31 May 2020 (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 ==
:You may be able to adapt [[Module:Template parameter value]], which relies on the value being introduced by a pipe rather than a colon. However, many articles have their displaytitle modified by a template such as {{tl|lowercase title}}, or indirectly via an infobox template per [[WP:ITALICTITLE]]. [[User:Certes|Certes]] ([[User talk:Certes|talk]]) 08:36, 31 May 2020 (UTC)


Please help me in creating a page Module:Sandbox/பொதுஉதவி.
:: Thank you for further clarification - my example was a simple solution and does not cover the variety of ways a DISPLAYTILE can appear -- [[User:Matroc|Matroc]] ([[User talk:Matroc|talk]]) 01:56, 1 June 2020 (UTC)
[[User:பொதுஉதவி|பொதுஉதவி]] ([[User talk:பொதுஉதவி|talk]]) 05:48, 1 November 2024 (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)


== Using #invoke in mainspace, as an alternative to templates ==
== Radio buttons for switching between historical maps ==


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)
{{Image frame||align=right|content=
: 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)
{{Location map|Israel center ta#Israel
|label = El'ad
|mark = Blue_pog.svg
|marksize = 9
|lat_deg = 32 |lat_min = 3 |lat_sec = 8.34 |lat_dir = N
|lon_deg = 34 |lon_min = 57 |lon_sec = 4.47 |lon_dir = W
}}}}
[[File:El&#039;ad 2020 street map overlaid on Survey of Palestine map from 1941.gif|thumb|El&#039;ad 2020 street map overlaid on Survey of Palestine map from 1941]]


== Output unreadable with "2-ary truth table" template ==
Please could someone help to create radio button functionality for switching between historical maps?


[[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.]]
Currently [[:Module:Location map]] gives the ability for a reader to switch between contemporary map views using radio buttons (see example on the right). For historical maps, comparing what an area looks like today to how it looked historically, there is no template or module which can do the same. It would benefit articles about historical settlements which look very different today (for example [[Tenochtitlan]] in Mexico City, [[Cahokia]] in [[St. Clair County, Illinois]], [[Londinium]] in London and [[Lutetia]] in Paris). The best I have been able to come up with is the gif on the right, but it has been fairly derided as overly "distracting".


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)
Would it be possible to extract the relevant code from Module:Location map into a new "Module:Image select" or similar? It doesn't need any of the other functionality (e.g. coordinates, labels) as it can all be covered by the buttons and captions.


:@[[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)
[[User:Onceinawhile|Onceinawhile]] ([[User talk:Onceinawhile|talk]]) 09:21, 24 June 2020 (UTC)
: You're looking for {{tl|switcher}} [[User:Pppery|* Pppery *]] [[User talk:Pppery|<sub style="color:#800000">it has begun...</sub>]] 13:56, 24 June 2020 (UTC)
::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)
::{{ping| Pppery}} that is perfect, thank you. [[User:Onceinawhile|Onceinawhile]] ([[User talk:Onceinawhile|talk]]) 14:19, 24 June 2020 (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 ==
== Help find and remove a testing module ==


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)
Right now [[Module:SimpleDebug]] is transcluded into [[Cynthia Brewer]]. My assertion is that we should avoid transcluding testing modules. Can someone see if they can remove that use from there? --[[User:Izno|Izno]] ([[User talk:Izno|talk]]) 15:01, 20 July 2020 (UTC)
:Commented out the <code>require</code> in [[Module:TNTTools]] because it did not appear to be used in that module.
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 15:18, 20 July 2020 (UTC)
:It comes from {{tl|BrewerColors}} which I believe is a recreation of {{tl|BrewerPalette}} ([[Wikipedia:Templates_for_discussion/Log/2019_November_10#Template:BrewerPalette|TfD]]). I think merging it with the article and then G4 would be a proper course of action. Alternativley it could be removed as too much detail instead relying on the external link to ColorBrewer2.org. --[[User:Trialpears|Trialpears]] ([[User talk:Trialpears|talk]]) 15:20, 20 July 2020 (UTC)
::No, it is not a recreation. TFD is probably reasonable. --[[User:Izno|Izno]] ([[User talk:Izno|talk]]) 15:38, 20 July 2020 (UTC)
::: As the nominator of the aforementioned TfD, I can say clearly that {{tl|BrewerColors}} is not a recreation of {{tl|BrewerPalette}} (the latter template used the former). Nor do I see why {{tl|BrewerColors}} should be deleted. {{ping|Izno|Trialpears}} What's the problem with {{tl|BrewerColors}} exactly? [[User:Pppery|* Pppery *]] [[User talk:Pppery|<sub style="color:#800000">it has begun...</sub>]] 16:08, 20 July 2020 (UTC)

== [[Module:Sports rbr table]] + [[Template:F1R2020]] ==

Throughout the motorsport we use mostly similar color schemes and tables. And in the popular motorsport we use and update the same data but we update it on the different pages doing more edits than we actually need. I made an intermediate [[Template:F1R2020|solution]] but it is a bit clumsy. All motorsport community will be pleased if you help us to made a module for the motorsport tables (their common look [https://en.wikipedia.org/enwiki/w/index.php?title=Template:F1_Drivers_Standings&oldid=968488373 here]. P.S. Also we had two slightly different tables , but probably they also could have connection and receive updates from the same source template/module. The example of the cells from such tables below: <nowiki>{{F1R2020|HAM|HUN}}</nowiki>
{| class="wikitable" style="text-align:center; font-size:90%"
|-
|{{F1R2020|HAM|HUN}}
|}
{| class="wikitable" style="text-align:center; font-size:90%"
|-
| {{Coltit|FFFFBF|x=}} '''''[[2020 Hungarian Grand Prix|HUN]]'''''<br>1
|}

P.S.S. The issue with Module:Sports rbr table is that we can't add [[Template:F1 race position]] or bold/italics. Also we need a possibility to add extra column for positions and numbers (in the case of the teams' standings). [[User:Corvus tristis|Corvus tristis]] ([[User talk:Corvus tristis|talk]]) 03:39, 26 July 2020 (UTC)

==Election results module==
Hello. Is anyone able to help me sort out [[Module:Election results/sandbox]]? I can't work out what I've done wrong to make {{tl|Election results/testcases}} go wrong for the latter two tables. I suspect it's something to do with the second <code>elseif cand then</code> section. There are a few other functions I'd also like to add to it, which I was planning to do by trial and error, but if anyone has a bit of time to assist, I'd be most appreciative. Cheers, [[User:Number 57|<span style="color: orange;">Number</span>]] [[User talk:Number 57|<span style="color: green;">5</span>]][[Special:Contributions/Number 57|<span style="color: blue;">7</span>]] 21:36, 2 August 2020 (UTC)
:<code>cand</code> and <code>sc</code> don't appear to be initialized by your code (Lua inits them to nil) and both are globals. Generally not a good idea to have globals if they can be avoided. Consider adding {{code|lang=lua|require('Module:No globals')}} at the top of your sandbox. It will help find (mis)used globals.
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 21:54, 2 August 2020 (UTC)
{{mdf|User talk:Trappist the monk#Lua}}
Hello Trappist. Thanks for your response at [[Wikipedia talk:Lua]], but TBH I don't understand, as I don't know Lua at all (I have no idea what a global is). I saw someone else created this module (which is great) and want to widen its use. However, I don't know how to code it, so have just been messing around doing it by trial and error... If there's any chance you could fix it (if it's a quick fix), that would be great. Cheers, [[User:Number 57|<span style="color: orange;">Number</span>]] [[User talk:Number 57|<span style="color: green;">5</span>]][[Special:Contributions/Number 57|<span style="color: blue;">7</span>]] 22:11, 2 August 2020 (UTC)
:It isn't clear to me what it is that you are wanting to do. If I preview the example templates at [[Template:Election results/testcases]] using the live template and module, I see what looks to be correct rendering. I added {{tlx|Testcase table}} to give side-by-side renderings.
:
:What is wrong with the live version that you want changed?
:
:Globals are items that have global scope – are visible and changeable (that's the dangerous part) from anywhere in the module. For safety and reliability, every function, table, and variable in a module should be declared <code>local</code> so that its scope is limited to where it is used. Stuff will still go wrong but the wrongness is usually confined to a smaller portion of the code.
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk#top|talk]]) 22:46, 2 August 2020 (UTC)
::I believe the issue with the sandbox is cand is never set to true, so rows are never populated. But, like Trappist the monk, I don't quite see what you're trying to do in the sandbox. [[User:ProcrastinatingReader|ProcrastinatingReader]] ([[User talk:ProcrastinatingReader|talk]]) 02:22, 3 August 2020 (UTC)
::As as a comment about {{tq|as I don't know Lua at all}}. Not sure how wise this is as you'll need to maintain this module and handle errors and feature requests. Just throwing stuff together until it works is almost never the correct thing to do. --[[User:Gonnym|Gonnym]] ([[User talk:Gonnym|talk]]) 06:39, 3 August 2020 (UTC)
:::{{ping|Trappist the monk}} As a starting point, the current version in the Parliamentary testcases should ideally spit out something like the below.
:::{| class="wikitable sortable" style=text-align:right
!colspan=2|Party
!Votes
!%
!Seats
!+/–
|-
|bgcolor={{Kuomintang/meta/color}}| ||align=left|[[Kuomintang]]||5,813,699||71.88||50||+50
|-
|bgcolor={{Democratic Progressive Party/meta/color}}| ||align=left|[[Democratic Progressive Party]]||2,274,586||28.12||45||–50
|- style=background-color:#eaecf0
|align=left colspan=2|Valid votes||8,088,285||98.57||colspan=2 rowspan=4|
|- style=background-color:#eaecf0
|align=left colspan=2|Invalid votes||117,160||1.43
|- style=background-color:#eaecf0
|align=left colspan=2|'''Total votes'''||'''8,205,445'''||'''100'''
|- style=background-color:#eaecf0
|align=left colspan=2|Registered voters/turnout||14,313,288||57.33
|-style=background-color:#eaecf0
|align=left colspan=6|Source: [https://www.cec.gov.tw/english/cms/pe/24830 CEC]
|}
:::{{ping|Gonnym}} The module already exists. I'd just like to make it more flexible to deal with other types of elections or electoral systems. I can produce a list of features that would need to be incorporated to allow it to cover (probably) 95% of elections if that would help. [[User:Number 57|<span style="color: orange;">Number</span>]] [[User talk:Number 57|<span style="color: green;">5</span>]][[Special:Contributions/Number 57|<span style="color: blue;">7</span>]] 12:46, 3 August 2020 (UTC)
::::As an example of an issue you can run into. If the table above will be produced by the module then it's producing semantically incorrect rows (as the last 5 rows aren't header rows) and 2 of the columns aren't following [[MOS:ABBR]] and [[WP:HEADERS]]. These issues will make any page using this fail FA and should be fixed. Also, the sorting messed up the table. --[[User:Gonnym|Gonnym]] ([[User talk:Gonnym|talk]]) 12:58, 3 August 2020 (UTC)
:::::What do you mean by 'semantically incorrect rows'? Perhaps you could show what a corrected version would look like? [[User:Number 57|<span style="color: orange;">Number</span>]] [[User talk:Number 57|<span style="color: green;">5</span>]][[Special:Contributions/Number 57|<span style="color: blue;">7</span>]] 16:04, 3 August 2020 (UTC)

== Need some Lua help for Template:Subject bar ==

*'''[[Template:Subject bar]]'''
Could someone with Lua skills please look at this discussion:
*[[Template talk:Subject bar#Lessen space between "Sister Projects" and the stuff to the right of it. 2 rows versus 3 rows]]
--[[User:Timeshifter|'''Timeshifter''']] ([[User talk:Timeshifter|talk]]) 10:12, 12 August 2020 (UTC)
:Added what I think you're trying to achieve to the module sandbox. See [[Template:Subject bar/testcases|testcases]]. [[User:ProcrastinatingReader|ProcrastinatingReader]] ([[User talk:ProcrastinatingReader|talk]]) 11:16, 12 August 2020 (UTC)
::{{u|ProcrastinatingReader}}, Thanks! I will ask that your change be implemented in the module. --[[User:Timeshifter|'''Timeshifter''']] ([[User talk:Timeshifter|talk]]) 12:01, 12 August 2020 (UTC)

== Any way to see pages where my Lua module is throwing errors? ==

I've done a little searching on the Wikipedia Lua resources and I don't think this is possible, but it would be great if it was so I figured I'd ask: is there any way to see a list of pages that are throwing errors when running a Lua module? Specifically, I recently revamped the {{tl|LDS}} template, which is used to cite to Mormon scriptures like the Book of Mormon, so that it calls a Lua module ({{m1|LDSverse}}). It works great, but there were a few places where people were misusing the original version of the template in a way that would just create broken external links—aka errors that were invisible to the reader on Wikipedia—but now when those bad parameters are passed to the Lua module it tends to create one of those big red Lua script error messages in the middle of Wikipedia pages. I might change how errors are handled to make the module fail more gracefully, but ideally it would be nice to find the handful of pages that are causing the errors and just fix them.

So is there by any chance a page that lists all the instances of the module causing an error? Or any way to somehow (easily) create that? If not, no worries, but I didn't want to find out there is after putting in a few hours of other work! ― [[User:Biggins|biggins]] ([[User talk:Biggins|talk]]) 10:49, 27 August 2020 (UTC)
:I'm not sure if there is a way to see where the errors are, but in general, if you know a way code that you write can produce an error (such as accessing a nil parameter), then your code should always handle it, regardless if there are current errors or not. I see you've added [[Module:LDSverse/testcases|/testcaeses]] which is great, so try and think of how your code can break, and make sure you handle anything you find. Unrelated, it might be better to move the module to be the same name as the template, as is common. --[[User:Gonnym|Gonnym]] ([[User talk:Gonnym|talk]]) 10:57, 27 August 2020 (UTC)
:I've been occupied elsewhere for a while and consequently have been very lazy. However, I often monitor [[:Category:Pages with script errors]] using [https://en.wikipedia.org/enwiki/w/api.php?action=query&list=categorymembers&cmprop=title&cmlimit=500&cmnamespace=0&format=xml&cmtitle=Category:Pages_with_script_errors this link for errors in articles]. A couple of days ago I saw some errors (at least two pages, maybe four) which were due to your change to use the module. After working that out, I wondered whether to alert you but decided not to because it can be a bit in-your-face to present a list of problems while you are part-way through a large update. That is, I decided to leave it for a day or two to see if the problem was fixed. That appears to have happened because there is nothing at the link showing an LDS problem now. The advantage of leaving the big red error message is that someone, perhaps me, will notice it and take action eventually. By contrast, some custom error message might never be seen except by occasional baffled readers. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 11:00, 27 August 2020 (UTC)
:One error in that list: {{lds|Book of Mormon: Introduction|bm/introduction}}. --[[User:Gonnym|Gonnym]] ([[User talk:Gonnym|talk]]) 11:09, 27 August 2020 (UTC)
:You could try [https://en.wikipedia.org/enwiki/w/index.php?search=incategory%3A%22Pages+with+script+errors%22+hastemplate%3ALDS&title=Special:Search&profile=advanced&fulltext=1&ns0=1 this search]. It's currently not returning any results. [[User:Certes|Certes]] ([[User talk:Certes|talk]]) 11:12, 27 August 2020 (UTC)
:
:The problem with using <code>assert()</code> to catch user input errors is that it makes it look like the module is broken so editors are going to shy away from such glaring error messaging; and if they do click that message they are presented with the drop-down that is helpful to the developer but not so helpful to the common editor. Take the time to create error messaging that is useful to the common editor; categorize the errors; provide help text and a link in the error message to that help text. Save <code>assert()</code> and <code>error()</code> for truly broken module code.
:
:Of course, it is common for editors to blithely ignore error messages; they do it all the time with cs1|2 ... Still, no reason to {{error|shout}} at them.
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 11:53, 27 August 2020 (UTC)

:: Many many thanks for all the quick replies, that is all extremely helpful. {{re|Johnuniq}} the link you provided is pretty much exactly what I was looking for! And to all the good points made above, I'm torn between shouting at users so that they (and now I) can more easily recognize errors vs handling them more gracefully and inevitably letting errors go unseen and uncorrected for a long while. I will try to get at the best of both worlds. Also, I do plan to move the template to the same name as the module, but I both wasn't sure yet how to do that and wanted to make sure there was consensus to do so too since it looks like renaming/moving it was considered (long ago) and rejected. Anyway, thanks to you all again! ― [[User:Biggins|biggins]] ([[User talk:Biggins|talk]]) 12:56, 27 August 2020 (UTC)
:::I've fixed the pages named in that link except [[Yaroslavsky suburban railway line]]. No error message appears on the page, and I can't see any obvious faults. Can anyone solve the problem? [[User:Certes|Certes]] ([[User talk:Certes|talk]]) 13:19, 27 August 2020 (UTC)
::::You can find the error message in the html source:
:::::<code><nowiki>{{rcr|MZD|Yaroslavsky}}</nowiki></code> → {{rcr|MZD|Yaroslavsky}}
::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 13:32, 27 August 2020 (UTC)
:::::Errors in station articles (such as [[Yaroslavsky suburban railway line]]) pop up regularly and I have given up trying to solve them. Instead, I use "related changes" to find, for example, that [[Module:Adjacent stations/MZD]] (moved to [[Module:Adjacent stations/Moscow Metro]] and then to [[Module:Adjacent stations/Nizhny Novgorod Metro]]) was changed by {{u|AJP426}} a week ago, then I alert them and they fix it. One more point: the error category can be weeks behind a change. Generally, if you edit a module and it breaks something, the error category will show a dozen or a few hundred errors within a few hours. However, after they are fixed, a trickle of other problems might appear in the category weeks later because it is only updated when pages are rendered. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 23:44, 27 August 2020 (UTC)
:: [https://en.wikipedia.org/wiki/Category:Pages_with_script_errors This link] may help.If you click on the error message in RED itself a cryptic Lua error summary can be viewed. Apologize if I have repeated some of the information found above. I also try to find if some change occurred on the page that may have initiated the error. -- [[User:Matroc|Matroc]] ([[User talk:Matroc|talk]]) 06:27, 28 August 2020 (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]