User:BlackShadowG/StubSorter

维基百科,自由的百科全书
StubSorter
描述用于分类小作品
作者
状态稳定
更新2023年10月1日(5個月前)
浏览器支持所有现代浏览器,或IE 11
皮肤支持除Minerva外所有皮肤
源码User:BlackShadowG/StubSorter.js

StubSorter是可轻松分类小作品的脚本。它提供了一个类似HotCaT的搜索框来搜索和添加Category:小作品訊息模板中的模板,也可删除条目已有的小作品模板。

当你点开一篇处于积压工作分类Category:小作品的条目时,脚本界面会自动打开,其它页面则需要点击页面右上角的“更多”下拉菜单,找到“小作品分类”按钮(默认,可修改)。同时为了省去另一次点击,当你添加另一个小作品模板并保存时,{{stub}}会自动删除。

保存的快捷方式是Alt+⇧ Shift+SAlt+S(Mac是Control+⌥ Option+S

启用

将下列代码加入你的common.jsskin.js页面中:

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

搜索模式

StubSorter会搜索Category:小作品訊息模板中的模板。

  • 前缀匹配(prefix):搜索结果来自分类中搜索prefix:"Template:您输入的搜索词"的结果。
  • 标题内匹配(intitle):搜索结果来自分类中搜索intitle:"您输入的搜索词"的结果。

请注意,前缀匹配的所有搜索结果不会出现在标题内匹配的搜索结果中。这是因为标题内搜索寻找的是全词匹配,而前缀搜索则乐意匹配部分词。例如,“jap”的标题内搜索不会找到“Japan-stub”,而前缀搜索会找到。“bio”的标题内搜索会找到“Japan-bio-stub”,前缀搜索则不会。

当你搜索时,前缀匹配和标题内匹配的结果都会被检索出来。默认情况下,前缀匹配会优先显示。你可以使用下拉菜单进行更改。

  • 优先列出前缀匹配(prefix):将前缀匹配的结果列在标题内匹配上方
  • 优先列出标题内匹配(intitle):将标题内匹配的结果列在前缀匹配上方
  • 严格匹配(regex):严格匹配模板名称中的字符序列。This will find all the prefix matches and intitle matches, plus some more. Done internally by querying the search results for intitle:/searchString/。任何正则表达式特殊字符都会被转义。

默认模式是第一种。你可以将以下代码添加到您的common.js页面来修改默认模式:

StubSorter_searchBy = "searchMode"

searchMode替换成prefixintitleregex,各自对应的模式上方的括号中的标注。

锁定按钮

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.

自定义

监视

默认情况下,您分类的小作品页面将不会被添加到你的监视列表中。如要自定义,请在您的common.js中添加以下一行代码:

StubSorter_watchlist = "watch";

该值可以是:

  • watch” - 将页面加入监视列表
  • nochange” - (默认)不改变页面的监视状态(无论页面是否被监视都会维持原样)
  • preferences” - 监视列表将取决你的偏好设置:Special:Preferences#mw-prefsection-watchlist-pageswatchlist
  • unwatch” - 若页面已加入监视列表,则取消监视(不推荐)

小编辑

默认情况下,您的编辑被标记为小编辑。如要禁用,请添加:

StubSorter_minor = false;

菜单位置

默认情况下,打开此脚本界面的“小作品分类”按钮在页面右上角的“更多”下拉菜单(p-cactions菜单)中。您可以通过添加以下代码,并根据en:Help:Customizing toolbars填入其他portletId以将于置于其他菜单中:

StubSorter_portlet = "portletId";