Module talk:Random slideshow: Difference between revisions

Content deleted Content added
m Archiving 1 discussion(s) to Module talk:Random slideshow/Archive 1) (bot
Cewbot (talk | contribs)
m Maintain {{WPBS}}: 1 WikiProject template. Create {{WPBS}}.
 
(19 intermediate revisions by 7 users not shown)
Line 1:
{{WikiProject Portals}}
{{central|text=the talk pages for the following templates redirect here:
<div style="font-size:95%">{{flatlist|
Line 5 ⟶ 4:
*{{tl|Transclude&nbsp;files&nbsp;as&nbsp;random&nbsp;slideshow}}
}}</div>
}}
{{WikiProject banner shell|
{{WikiProject Portals}}
}}
{{archives|age=60|small=no|bot=Lowercase sigmabot III}}
Line 16 ⟶ 18:
| minthreadsleft = 5
}}
 
== Portals with many images ==
 
{{ping|Evad37|Northamerica1000}} Portal generation can be slow and sometimes breaches the 10-second limit. [[Portal:Pakistan]] was showing "The time allocated for running scripts has expired."; I purged it at a quiet time but it's still over 9 seconds and may flip back randomly. 66% of that is one call to {{tl|Transclude files as random slideshow}} which generates 145 images. What should we do?
 
One option is to have the module apply a maximum image count. It might be better to tune individual portals, reducing the list of articles from which images are extracted. At least that way we have some say in which ones are removed. Another idea is to limit the number of images per article (currently hard-coded as 100 in the module, which in practice means "all"). However, doing so naively would drop the later images which might be the best ones. Ideally, the module would select the "best" pictures, but that probably involves doing all the current work (and more) before discarding the mediocre, which improves the portal but doesn't solve the timing problem.
 
I think that choosing 50 at random is as simple as adding the <code>, 1, 50</code> in <code>local galleryContent = table.concat(sortedLines, '\n', 1, 50)</code>, though pruning the selection earlier might be more efficient and we may want to accept a parameter to override the value of 50 that I plucked from thin air. Any thoughts? [[User:Certes|Certes]] ([[User talk:Certes|talk]]) 12:47, 30 September 2020 (UTC)
*I noticed that {{u|Pakieditor}} significantly expanded the General images section on 20 September 2020 ([https://en.wikipedia.org/w/index.php?title=Portal:Pakistan&diff=979444187&oldid=972187558 diff]), which is very likely contributing to the Lua timeout errors. An immediate fix would be to prune some of the entries from the General images section. From past experience, this tends to stop the timeouts. <span class="smallcaps" style="font-variant:small-caps;">[[User:Northamerica1000|North America]]<sup>[[User talk:Northamerica1000|<span style="font-size: x-small;">1000</span>]]</sup></span> 13:20, 30 September 2020 (UTC)
:{{re|Certes}} That's rather late in the piece to be limiting the number of images. The expensive (time-consuming) work is likely to be in the {{tt|extractRegularFiles}} function, which does a bunch of string manipluation and (potentially) preprocessing of templates in a loop. - <u>'''[[User:Evad37|Evad]]''37'''''</u>&nbsp;<span style="font-size:95%;">&#91;[[d:w:User talk:Evad37|talk]]]</span> 13:29, 30 September 2020 (UTC)
::You're right; it's too late. extractRegularFiles is efficient: gsub takes 0.32 seconds, some of which lies elsewhere. I suspect the time goes even earlier, in the parse function of Module:Excerpt/portals (which is mainly my fault, though the attribution has become separated). The killer there is retrieving up to 100 file description pages to check for non-free licences. We should probably set files=1-50 rather than 100 in this module but also remove some articles from the list in Portal:Pakistan and similar cases. [[User:Certes|Certes]] ([[User talk:Certes|talk]]) 13:59, 30 September 2020 (UTC)
:I've removed subnational articles such as [[Quetta]] from [[Portal:Pakistan]]. It now renders in 6 seconds, of which only 2 s is the slideshow. As an experiment, I've introduced some variety via a region of the day: one final article of {{tlx|Random item|Islamabad|Lahore|Karachi|Quetta|Peshawar|Northern Pakistan}} rotates the evicted images. [[User:Certes|Certes]] ([[User talk:Certes|talk]]) 14:41, 30 September 2020 (UTC)
:{{ping|GKFX}} I see the maximum number of images is down to 4. This seems rather low compared to the 50/100 discussed above. Is a new problem occurring with higher numbers? [[User:Certes|Certes]] ([[User talk:Certes|talk]]) 00:15, 9 May 2021 (UTC)
::{{ping|Certes}} [[Portal:Arithmetic]] passes article names not filenames and was struggling at 5 articles. I will revert and make changes to the portal instead. [[User:GKFX]]<sup>[[User talk:GKFX|talk]]</sup> 08:39, 9 May 2021 (UTC)
:::{{ping|GKFX}} That portal is taking 9.7 seconds (close to the maximum of 10). 37% is in {{tl|Transclude files as random slideshow}}. Although there are only five arguments, each of them has several files (images). However, there are only 14 altogether and I can't see why this is slow. Maybe {{u|Evad37}} can advise us. Another 29% is in {{tl|Transclude list item excerpts as random slideshow}}. That runs on [[Portal:Arithmetic/Selected article]], which lists about 60 articles. I tried adding {{para|limit|30}} to that call, but it didn't seem to help. It runs again on [[Portal:Arithmetic/Biographies]] but that list is short. [[User:Certes|Certes]] ([[User talk:Certes|talk]]) 11:05, 9 May 2021 (UTC)
 
== Mobile view improvement ==
Line 76 ⟶ 63:
I reset [[Module:Random slideshow/sandbox]] to the production version of 14:50, 10 March 2021 by [[User:Frietjes|Freitjes]], and using {{tl|Transclude files as random slideshow/sandbox}} in the above markup, the bogus file option goes away ... almost. It's replaced by one of those pesky, dare I say "bogus px" bogus file options. Anyway, the longer bogus file option is attributable to your latest change. —[[User:Anomalocaris|Anomalocaris]] ([[User talk:Anomalocaris|talk]]) 17:20, 14 May 2021 (UTC)
:[[User:Anomalocaris|Anomalocaris]], have you considered fixing the articles instead? if the parameters image parameters are bogus, then there should be no reason not to fix the articles. for example, [//en.wikipedia.org/w/index.php?search=insource%3A%2Fupright{{urlencode:[ ]*[0-9]}}%2B%2F&title=Special%3ASearch&profile=advanced&fulltext=1&ns0=1 this search] shows many upright problems (syntax not documented in [[Wikipedia:Extended image syntax]]). [[User:Frietjes|Frietjes]] ([[User talk:Frietjes|talk]]) 19:39, 14 May 2021 (UTC)
Some version of this error is still present on a few Portal pages. I used [[Special:ExpandTemplates]] with "Portal:Marine life" in the Context title to expand the following:
<pre>
{{Transclude files as random slideshow
| Marine habitats
}}
</pre>
That results in a bogus image option here:
<pre>
File:Eurythenes plasticus (10.11646-zootaxa.4748.1.9) Figure 3.jpg|<span class="switcher-label" style="display:none"><span class="randomSlideshow-sr-only">Image 2</span></span>thumb|640&nbsp;µm microplastic found in the deep sea amphipod ''Eurythenes plasticus'' (from '''[[Marine habitats]]''')
</pre>
An error-free instance looks like this:
<pre>
File:The White Rocks near Portrush (1) - geograph.org.uk - 785899.jpg|<span class="switcher-label" style="display:none"><span class="randomSlideshow-sr-only">Image 3</span></span>Sandy shores provide shifting homes to many species (from '''[[Marine habitats]]''')
</pre>
Note the undesirable presence of <code><nowiki>thumb|</nowiki></code> in the former example. It looks like the module attempts to strip out "thumb" and similar parameters from gallery entries, but in this case, it appears to have failed. This "thumb" problem appears to be happening in a just a couple of Portal pages, but there are similar errors in [https://en.wikipedia.org/wiki/Special:LintErrors/bogus-image-options?namespace=100 a dozen or so Portal pages], so fixing it in the module would be best. There are a few more instances of complex markup in image captions failing to be stripped or parsed correctly (e.g. "Map of counties in Missouri by racial plurality, per the 2020 US Census" from [[Missouri]]). I'm hoping a change to the regex in the module will be sufficient. – [[User:Jonesey95|Jonesey95]] ([[User talk:Jonesey95|talk]]) 20:43, 16 September 2022 (UTC)
 
:{{ping|Jonesey95}} In the case of the Marine habitats, that appearance of <code>thumb</code> appears to be more of a case of [[GIGO]] than the module's fault. The image causing issues there is from a {{tag|gallery}}, and images in galleries do not support the <code>|thumb|</code> option (or at least not as far as I can tell), so the module never expects to have to remove it. I've removed the occurance of it from the article it's on, but correct me if I'm wrong on this call. [[User:Aidan9382|Aidan9382]] <sub>([[User talk:Aidan9382|talk]])</sub> 18:07, 30 September 2022 (UTC)
::As for the errors appearing on some of the other portal pages, like [[Portal:Pennsylvania]] (the issue lies in <code>File:Pennsylvania Counties by race (2020 census).svg</code> from [[Pennsylvania]]) is because of the fact that the description includes tables and templates, which, due to one reason or another (potentially due to the more limited form of gallery compared to files, but im not sure), isn't going to work or display nicely in the slideshow. In terms of fixing that, I'm not exactly sure what to recommend, as what the issue is ''specifically'' is hard to pin down. Any ideas? [[User:Aidan9382|Aidan9382]] <sub>([[User talk:Aidan9382|talk]])</sub> 18:58, 30 September 2022 (UTC)
:::As I suggested in the other discussion, maybe one solution is to render the file on its own, then insert a line break and then render the caption without any processing, outside of the File: invocation. – [[User:Jonesey95|Jonesey95]] ([[User talk:Jonesey95|talk]]) 20:25, 30 September 2022 (UTC)
::::I have created [[Template:Transclude files as random slideshow/testcases2]] to demonstrate two of these errors. – [[User:Jonesey95|Jonesey95]] ([[User talk:Jonesey95|talk]]) 14:01, 2 October 2022 (UTC)
:::::Came across this issue again while investigating something else, so I decided to take a look. The primary issue lies in how galleries work, and how they don't respect tables that well, and unfortunately I'm not sure if this has a simple solution. I've left my findings on what I've noticed on [[Special:Permalink/1116592103|this page]] with examples, which should explain it well. As for solutions, the only idea I have is preventing the expansion of templates, but I have yet to test this, and I'm not sure if the expansion is currently intentional for a different reason. [[User:Aidan9382|Aidan9382]] <sub>([[User talk:Aidan9382|talk]])</sub> 10:16, 17 October 2022 (UTC)
::::::{{ping|Jonesey95}} Good news - after quite a touch up today with how the module works and some more light work yesterday, I've mostly fixed the 2 main causes of the bogus file option linter errors, bringing down the total number of errors from what I think was ~140 to ''10'' (and a few are human errors, not the module). I'm going to do a minor look into weird upright inclusion behaviour after this post, but as far as I can see the new version is working fine, though if you notice any issues or have suggestions, do tell me. Hope this helps. [[User:Aidan9382|Aidan9382]] <sub>([[User talk:Aidan9382|talk]])</sub> 12:16, 4 November 2022 (UTC)
::::::...iiiiif I didn't run into issues, which apparently seems to be impossible with me :). Turns out [[Module:Excerpt slideshow]] was quite unhappy with what I tried and blew up on the spot, so I also now have to go fix that. If the linter errors are back to below 15, I've found a fix before you've seen this. If not, hopefully I will soon after. [[User:Aidan9382|Aidan9382]] <sub>([[User talk:Aidan9382|talk]])</sub> 12:31, 4 November 2022 (UTC)
:::::::Thanks for continuing to work on it. – [[User:Jonesey95|Jonesey95]] ([[User talk:Jonesey95|talk]]) 13:16, 4 November 2022 (UTC)
 
== Link to transcluded article ==
Line 85 ⟶ 96:
 
{{ping|Evad37}} Just following up to see, with the recent improvements to the mobile version, if this is good to copy over to Commons? Thanks. &mdash; <samp>[[User:Rhododendrites|<span style="font-size:90%;letter-spacing:1px;text-shadow:0px -1px 0px Indigo;">Rhododendrites</span>]] <sup style="font-size:80%;">[[User_talk:Rhododendrites|talk]]</sup></samp> \\ 14:34, 9 June 2021 (UTC)
:{{ping|Evad37}} One more nudge on this and I'll leave you alone/find something different. :) &mdash; <samp>[[User:Rhododendrites|<span style="font-size:90%;letter-spacing:1px;text-shadow:0px -1px 0px Indigo;">Rhododendrites</span>]] <sup style="font-size:80%;">[[User_talk:Rhododendrites|talk]]</sup></samp> \\ 17:09, 20 July 2021 (UTC)
::{{re|Rhododendrites}} Sorry, I haven't had much free time IRL to spend on wiki stuff. The pieces should be pretty much ready, and should be able to be copied over to commons – except I'm not sure what the modules are like over there, which might make it harder to put it all together. Plus article excerpt slideshows don't need to be a thing over on commons, but are part of the module here. Feel free to ping me again in a couple of weeks if I haven't gotten around to it by then, or leave a message on my talk page - <u>'''[[User:Evad37|Evad]]''37'''''</u>&nbsp;<span style="font-size:95%;">&#91;[[d:w:User talk:Evad37|talk]]]</span> 05:18, 23 July 2021 (UTC)
:::Copied over (without the transclusion stuff), and seems to be working fine! {{thumbsup}} &mdash; <samp>[[User:Rhododendrites|<span style="font-size:90%;letter-spacing:1px;text-shadow:0px -1px 0px Indigo;">Rhododendrites</span>]] <sup style="font-size:80%;">[[User_talk:Rhododendrites|talk]]</sup></samp> \\ 22:18, 25 July 2021 (UTC)
 
== Random pic from category ==
 
Instead of lists; has anyone built a Random Slideshow from Category? Wouldn't it be much easier to have a "{PortalName} Portal Pictures" category? [[User:Mjquinn id|Mjquinn_id]] ([[User talk:Mjquinn id|talk]]) 19:58, 26 August 2021 (UTC)
:There is [[Wikipedia:Village pump (technical)/Archive 165#Listing category members in a module or template|no way]] for a template or module to find out what pages are in a category (short of reading in every file in Wikipedia and scanning for "Category:Whatever"). [[User:Certes|Certes]] ([[User talk:Certes|talk]]) 20:31, 26 August 2021 (UTC)