StubSorter
DescriptionA simple approach to stub sorting
Author(s)SD0001
StatusStable
UpdatedApril 21, 2023
    (11 months ago)
Browser supportAll modern desktop browsers, or IE 11
Skin supportAll skins, except Minerva
SourceUser:SD0001/StubSorter.js
StubSorter, showing a preview

StubSorter is a script intended to make stub sorting easier. It provides a simple HotCat-like search field to search for and add templates from Category:Stub message templates. It also allows you to remove existing stub templates.

When navigating to an article from the sorting backlog category CAT:STUBS, the script interface is opened automatically. Also to save you another click, {{stub}} is automatically removed when you add another stub template and save.

The keyboard shortcut Alt+⇧ Shift+S or Alt+S (on Mac Control+⌥ Option+S) can be used for saving.

Installation edit

If you have the script-installer gadget, just click on the "Install" button in the infobox.

Otherwise, place the following line in your common.js or skin.js page:

importScript('User:SD0001/StubSorter.js'); // [[User:SD0001/StubSorter.js]]

Search modes edit

StubSorter searches for templates in Category:Stub message templates.

  • prefix matches: Search results from the search prefix:"Template:your search query" within the category.
  • intitle matches: Search results from the search intitle:"your search query" within the category.

Note that all search results from a prefix search will not also appear in an intitle search, as one may expect. This is because the intitle search is looking for whole-word matches, whereas prefix search is happy to match partial-word matches. For example an intitle search for "jap" will not find "Japan-stub" whereas a prefix search will. An intitle search for "bio" on the other hand, will find "Japan-bio-stub" whereas a prefix search obviously wouldn't.

When you search, both prefix matches and intitle matches are retrieved. By default the prefix matches are shown at the top. You can change this using the dropdown menu.

  • List prefix matches first (prefix): lists prefix matches before the initle matches
  • List intitle matches first (intitle): lists intitle matches before the prefix matches
  • Use strict character-match search (regex): Strictly match the sequence of characters in the template name. This will find all the prefix matches and intitle matches, plus some more. Done internally by querying the search results for intitle:/searchString/. Any regex special characters are escaped.

The default mode is the first one. You may customize the default by adding to your common.js page:

StubSorter_searchBy = "searchMode"

replacing searchMode with prefix, intitle or regex.

Freeze button edit

The "Freeze" button freezes the search results in place so that any more changing of the search query doesn't change the available options. Rather, the existing options are searched. This can be handy in situations where you want to do a search to filter the list of available templates, and then do another search to find the template from the filtered list.

As a bonus, freezing the menu will silently add extra results to the dropdown for the current search query, upto 500 prefix matches and 500 intitle matches. Otherwise, only upto 100 prefix and intitle matches each are shown.

Customisation edit

Watchlisting edit

By default, the pages you stub-sort will not be added to your watchlist. To customise this, add the following line, just below the above one in your common.js:

StubSorter_watchlist = "watch";

The value can be:

  • "watch" - add the page to watchlist
  • "nochange" - (DEFAULT) watchlist status of the page is not changed - if the page is watched, it will remain watched, if unwatched, it will remain unwatched.
  • "preferences" - watchlisting will depend on your site preference given at Special:Preferences#mw-prefsection-watchlist-pageswatchlist.
  • "unwatch" - explicitly unwatch the page, even if it was watched earlier (not recommended).

Minor edit edit

By default edits are marked as minor. To disable this, add

StubSorter_minor = false;

Menu placement edit

The "Stub sort" menu option is available in the "More" dropdown menu (the p-cactions menu). You may change its location to any of the other portlet menus per Help:Customizing toolbars.

StubSorter_portlet = "portlet-name";

Troubleshooting edit

Are suggestions being loaded too slowly?

This could happen occasionally due to delays in getting responses to API calls. If you are experiencing issues persistently, drop me a line with the following information:

  • Your browser and operating system.
  • Your internet speed, measured through a service like fast.com or speedtest.net or both.
Unable to see a particular stub template?

This is because the stub template is not there in Category:Stub message templates, most probably because the template is malformed.

See also edit