Page MenuHomePhabricator

Create new cat-a-lot version
Open, Needs TriagePublic

Description

Consolidate changes from Outreachy contribution period to new cat-a-lot version and publish it to the test.

Code

Howto load script
Example for loading:

mw.loader.load('//commons.wikimedia.org/w/index.php?title=User:Zache/Gadget-Cat-a-lot-20250602.js&action=raw&ctype=text/javascript');

Also note, i you need to remove the official version from Wikimedia Commons preferences or gadget will be loaded twice.

Testing guide in Google Docs

Currently merged and ready for testing
Mark here when these are tested to be working after merge

  • T389718 - Add class "noprint" to the main Cat-a-lot UI container
  • T389719 - Allow translating Cat-a-lot's name
  • T388118 - Limit Cat-a-lot box height
  • T390242 - Add pause / continue editing to Gadget-libAPI.js and error dialog to Cat-a-lot
  • T387090 - Add Wikimedia Commons datanamespace support to Cat-a-lot
  • T390485 - Add clickable button to category search
  • T386783 - Cat-a-lot: Prevent self-categorization
  • T390490 - Cat-a-lot dialog boxes to be responsive
  • T389319 - Cat-a-lot gallery support is broken
  • T399919 - Remember Cat-a-lot state over pageloads
  • T390180 - Cat-a-lot translations

Waiting for the merge

  • T388123 - Add export selected files feature to Cat-a-lot
  • T389716 - Beta commons / other wiki preferences fix
  • T397849 - QuickCategories integration

Related Objects

StatusSubtypeAssignedTask
OpenNone
OpenBUG REPORTNone
ResolvedBUG REPORTZache

Event Timeline

Zache updated the task description. (Show Details)

Hi @Zache

As per our conversation on slack, I wanted to give you an update on the resizing issue.

At first, I was trying to fix the problem just by editing the CSS file, but no matter what I did, the dialog box height wasn’t updating the way I expected. After spending quite a bit of time on that, I looked into the JavaScript file and added some dynamic resizing logic there which is similar to the existing width resizing logic. I also made a few changes to the CSS. With both those updates, the original issue is now solved — the dialog resizes properly based on the number of categories and still stays under 65% of the screen size.

But now a new problem has come up. If I manually resize the dialog and then search for another category, the dialog stays stuck at the size I set manually. Even if I close and reopen it, the size doesn’t reset — it no longer adjusts dynamically.

I tried resetting the height and width with JavaScript, but that didn’t fix it.

Here are diffs between your version and mine:

CSS file link

JS file link

Let me know if you have any ideas on what could help fix this.

Thanks, I solved the issue by removing most of the javascript height calculations from code and trusted that CSS can handle it. I also added to minimize and maximize functions to store current state so it could restore the current position when window is maximized again. There was also pretty hard to detect bug. If cat-a-lot window was closed and then reopened then it added multiple onclick handlers to minimize and maximize button which would break opening the window in correct size.

(diffs: cat-a-lot.js and cat-a-lot.css ).

Most important changes

  • Removed remaining JavaScript height calculations so there are no 450px initial sizes anymore
  • Made unified handler for minimizing and maximizing which is set only when window is created. This prevents it from being added multiple times, which causes hard-to-detect bugs.
  • Removed 65% limit when user is resizing window manually. This also prevents the resize action from changing to move window on the fly when max-height has been reached.
  • Changed category_list width to be handled via CSS instead of JavaScript. This was just to make the list look nicer if the window width has been changed.

About the placement of "max-height: 65vh", I think that if it is in the #cat_a_lot_category_list container instead of the main #cat_a_lot container, then it allows keeping a fixed height for other elements in the container while only the category list changes. When I tested it previously it allowed to make CSS only solution for window resizing. However, I kept the height limitation still in the main container because it was already there and seemed to work well enough.

I try the new version and have a weird bug with gadget being displayed twice:

image.png (1×1 px, 399 KB)

Hey! I made a patch that aims to make Cat-a-lot's settings work directly through the UI on other wikis like Beta Commons and enwiki, where the gadget modules aren't preloaded by default. It detects whether the script is running outside Commons and dynamically loads SettingsManager and SettingsUI from Commons if needed.

Here’s the diff for reference: diff

Please let me know what you think.

Zache updated the task description. (Show Details)

Hey! I made a patch that aims to make Cat-a-lot's settings work directly through the UI on other wikis like Beta Commons and enwiki, where the gadget modules aren't preloaded by default. It detects whether the script is running outside Commons and dynamically loads SettingsManager and SettingsUI from Commons if needed.

Here’s the diff for reference: diff

Please let me know what you think.

Thanks, I used it to make a simplified version which only modifies the manageSettings() function, so it is easier to see what has been changed. I left detailed version to the T389716#10910056.

Two bugs reported

  1. The test version of CaL refuses to move for example file Aap from cat:Monkey Bands to cat:Monkey Bands|~. The move can be prepared but the button 'move' does nothing. In the old version it would.
  2. the old version would completely prohibit turning the page when files are selected, the test version gives no warning and turns the page. But nowadays we can go back and the earlier selection is still valid.

Bug #1 needs investigation, but #2 could be fixed by adding check if there is selected files and if it is true then confirm if user wants to leave from a page.

Thanks! For bug #1, I looked into it, it’s related to how sort keys are handled. I tested both versions and the consolidated version silently fails when sort keys are used, while the old version supported it. I’ll work on restoring that behavior.
For bug #2, agreed. Adding a confirmation when navigating away with selected files should be straightforward.

Just as an update that I merged some changes from T399919 and now the code warns if user leaves from page and there is selections. This change restored the original functionality.(diff) The code also remembers now the last category which was selected by user (diff) and if Cat-a-lot UI was open / minimized. (diff) .

The code uses sessionStorage for saving values, so there is no expiry time, but when the user opens a new tab, it doesn't remember them. This is something where we need user input to know if Cat-a-lot should keep the values when the user opens pages in new tabs AND when the values should expire.

As this version of Cat-a-lot

  • It now remembers if it was open or closed last time. (in same browser tab)
  • It now remembers the last selected category (in same browser tab)
  • It does not remember the position and size of the Cat-a-lot window over page loads

We would like to get feedback specifically.

  • Should Cat-a-lot remember its state also when user opens link to new tab?
  • How long it should remember the last searchkey, selected category and if Cat-a-lot was open/closed. (ie. when "session" ends)?
    • currently it remembers indefinitely in same tab.
    • Closing the cat-a-lot using "X" button resets the state.

I updated the testing version. It now has an option (in the cat-a-lot dialog) to remember the position and size of the Cat-a-lot window over page loads. The position is stored in sessionStorage so it is persistent across different tabs and sessions. We also restored the sortkey functionality in wikitext to be similar to what it was before our changes and added sortkey support to data namespace files

diff to changes

I made an update version to testing per comments in MediaWiki talk:Gadget-Cat-a-lot.js - Cat-a-lot not staying open.

Major changes on how it remembers if it was open are

  1. Now there is setting in ui Remember category and if it is set then it will remember selected category until session is over (60 minutes from last Cat-a-lot startup). It will remember the selected category even if user closes Cat-a-lot with X button. If it is not set then doesn't remember category (ie. original behaviour)
  2. It will startup automatically if User have left the Cat-a-lot open AND
    1. the new page is one of following category page, Special:Search , Special:MediaSearch, Special: Uncategorizedimages , Special:Listfiles
    2. If page is in same namespace where Cat-a-lot was used on last Cat-a-lot startup. Special namespace is excluded
    3. User is in same special page where Cat-a-lot was started last time

note Cat-a-lot doesn't work anymore in Special:Listfiles but it is unrelated to these changes.

Here is diff to changes

Note that I updated the sortkeyfixes for the problems described by Peli to the User:Zache/Gadget-Cat-a-lot-20250602.js (diff)

Updated the User:Zache/Gadget-Cat-a-lot-20250602.js diff with following changes.

  • Added preferences setting for session timeout in minutes
  • fixed regression about wrong message when page was moved to category where it already existed. Original behaviour was that it notified that it was "removed" from source cat and regression was that it said that page was moved. Now original behaviour is returned to original.
  • changed code so that cat-a-lot doesn't autoreopen when wgAction = edit