Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add insertAfterTemplates to Morebits.wikitext.page, respect MOS:ORDER when tagging, update hatnotes #1022

Merged
merged 4 commits into from Jul 14, 2020

Commits on Jul 14, 2020

  1. morebits: Allow chaining of Morebits.wikitext.page methods

    Toss `return this` at the end of the methods.  Uses of `removeLink` and `commentOutImage` were pretty simple and amenable to chaining; `removeTemplate` and `addToImageComment` are currently unused by Twinkle.
    Amorymeltzer committed Jul 14, 2020
    Configuration menu
    Copy the full SHA
    062cc99 View commit details
    Browse the repository at this point in the history
  2. morebits: add insertAfterTemplates to wikitext.page

    Takes the structure of the regex from the `tag` module, and uses it in `Morebits.wikitext.page.prototype.insertAfterTemplates` to properly find complex templates in the page wikitext, then insert a given string after them.  The regex is identical to what has been used in `tag`:
    
    - The regex for a series of templates is provided as either a string or as an array, from which each item will be pipe-separate.  This is what in `tag` is the CSD, PROD, and "various hatnote templates" section.
    - An optional regex flag can be provided; default is `\i`.
    - There's an optional `preRegex` for stuff that comes *before* the templates proper (i.e., before `{{`).  This is mainly because enWiki's AfD has an annoying hidden html comment before the `/dated` transclusion.
    
    We could add `postRegex` in the future, although that's likely overengineering
    Amorymeltzer committed Jul 14, 2020
    Configuration menu
    Copy the full SHA
    541b38a View commit details
    Browse the repository at this point in the history
  3. xfd/csd/prod/protect: Respect MOS:ORDER for hatnotes and shortdesc

    Uses `Morebits.wikitext.page.insertAfterTemplates` with a customized regex string in the hidden preference string `hatnoteRegex`.  `tag` adds on the deletion templates (CSD/PROD/XfD), and finally learns about protection templates.
    Amorymeltzer committed Jul 14, 2020
    Configuration menu
    Copy the full SHA
    bdae96f View commit details
    Browse the repository at this point in the history
  4. Update hatnote regex

    Barely been updated in a decade; `the` was deleted (https://en.wikipedia.org/wiki/Wikipedia:Templates_for_discussion/Log/2011_January_17#Template:The) in 2011!!!  Includes most templates from https://en.wikipedia.org/w/index.php?title=Template:Hatnote_templates with more than ~100, 150 transclusions.  A few commonish redirects included as well.
    Amorymeltzer committed Jul 14, 2020
    Configuration menu
    Copy the full SHA
    92f9642 View commit details
    Browse the repository at this point in the history