Extension:PageTriage/en

PageTriage is an extension that aims to provide a feature-rich interface for triaging newly-created articles. It is intended to replace the new page patrol core function while adding additional functionality for reviewing, tagging, and improving new articles. It adds a Special:NewPagesFeed page, and a page curation toolbar to new pages for those with the 'patrol' permission. It was developed by the Wikimedia Foundation's Features Engineering team. For additional details see Page Curation.

An important note is that some of the configuration and code is specific to the English-language Wikipedia's workflows and as it's constructed now the extension is pretty much impossible to internationalise. (See T50552.)

Checking for successful install
To actually see the extension working:


 * Create a new page containing just a few sentences of text as an anonymous user.
 * Visit Special:NewPagesFeed

The new page should appear, flagged as "", "", etc. To see the page curation toolbar:


 * Login as a user with the 'sysop' permission, or add a group with the "patrol" permission, and add some user to that group, and login as that user.
 * Visit Special:NewPagesFeed
 * Now you should see a "" button next to the new page.
 * Click this and you should see the page curation toolbar on the new page.

Additional extensions
For full functionality, you'll also need to install some additional extensions, although PageTriage works without them.


 * - Allows users to receive notifications for things like when an article they created has been marked as reviewed.
 * - In Special:NewPagesFeed, allows filtering by "predicted class" ( : stub, start, c-class, b-class, good, featured) and "potential issues" ( : vandalism, spam, attack, copyvio). The predictions are done with machine learning. ORES AI is typically trained by editors via https://labels.wmflabs.org/ui/, or by analyzing reverts. The ORES database provides probabilities which are accessed via the ORES extension. A threshold (tolerable false positive rate) is applied to this data, and some of the thresholds are set in the ORES extension's extension.json file.
 * - Adds a button to the Page Curation toolbar that allows you to leave a person a barnstar more easily.

Enabling draft namespace
By default, the draft namespace is disabled, but can be enabled with the following update to LocalSettings.php

When enabled, a new "articles for creation" tab will show up on Special:NewPagesFeed.

By default pages edited in the draft namespace will be "unsubmitted".

Articles in the draft namespace can be submitted for review by adding to the draft page. At which point they will show up under "awaiting review".

Note the toolbar controlled by the configuration variable $wgPageTriageEnableCurationToolbar does not show up in the draft namespace.

Cron jobs
To make sure old articles are eventually taken out of the new pages feed, you should set up a cron job to run the following file every 48 hours:

Special:NewPagesFeed -> Articles for Creation

 * Enable draftspace by following the directions above in the section.
 * In Special:NewPagesFeed, to place a draft in one of the AFC states, you need to create a page in the "Draft" namespace, and add it to the following categories:
 * Unsubmitted: (no category)
 * Awaiting review: Category:Pending AfC submissions
 * Under review: Category:Pending AfC submissions being reviewed now
 * Declined: Category:Declined AfC submissions

Note: The Page Curation toolbar does not display for drafts.

ORES
Enwiki has the ORES extension installed, which provides machine learning predictions of an article's quality and of some common issues. ORES works fine in production, but requires some setup if you want to test in a localhost environment. It can be desirable to test with ORES turned on, for example, if you are changing the layout of Special:NewPagesFeed. Here is a localhost testing procedure:


 * Clone Extension:ORES and add  in
 * Add this to


 * Run

Status codes
There are status codes used to track whether a page is reviewed or not. These are the values given when you query,  , and  :


 * Unreviewed
 * 0 - unreviewed
 * Reviewed
 * 1 - reviewed (someone clicked the green check mark in the Page Curation toolbar)
 * 2 - patrolled (someone clicked the "Mark as patrolled" link at the bottom right corner of a page)
 * 3 - autopatrolled (someone with the  user right created the page, or moved the page from a non-tracked namespace to a tracked namespace)
 * no result - will occur if the page is not in a tracked namespace (mainspace, userspace, and draftspace), if the article was created before PageTriage was installed, or if the article was reviewed for longer than 30 days (these records are deleted by a cron job)

Via the API
To check the review status of pages using an API query, you can use.

Sample JavaScript code:

Via SQL
To check the review status of pages using an SQL query, you need to query the  table and the   field. Follow the directions in  to interpret the values of this field.

pagetriage_page_tags
data is updated by calling. This is called in the following hooks:

It is called asynchronously. The user will see that their edit succeeded and can continue browsing the website, and the page tags update will occur in the background, invisibly to the user.
 * - runs when moving a page
 * - runs when saving an edit
 * - runs when clicking the "Mark this page as patrolled" link in bottom right corner of certain pages

List of tags
The  are as follows:
 * Author information
 * user_id
 * user_name - there's a filter where you can type in their username
 * user_editcount
 * user_creation_date
 * user_autoconfirmed
 * user_experience - Experience level: newcomer (non-autoconfirmed), learner (newly autoconfirmed), experienced, or anonymous. These experience levels are baked into core and can be accessed with
 * user_bot
 * user_block_status
 * Deletion tags - will display a black trash can icon if marked for deletion
 * afd_status
 * blp_prod_status
 * csd_status
 * prod_status
 * Special:NewPagesFeed red warning text
 * category_count - No categories
 * linkcount - Orphan
 * reference - No citations
 * recreated - Previously deleted
 * user_block_status - Blocked
 * Page information
 * page_len - size of article, in bytes
 * rev_count - number of edits to the article
 * snippet - text from beginning of article, used in Special:NewPagesFeed to preview the article
 * afc_state - 1 unsubmitted, 2 pending, 3 under review, 4 declined
 * copyvio - latest revision ID that has been tagged as a likely copyright violation, if any

On-wiki configuration
It is possible to configure much of PageTriage on-wiki via the pages  and , although the structure of the configuration may change in the future (to better accommodate wikis besides English Wikipedia). You can get a general idea of how the configuration works by looking at the following:

From a coding perspective, the default .js file is loaded first, and the English Wikipedia customisation file is loaded second. It's not either/or, both files are loaded. So if there is a variable set in the first file and in the second file, the second file's variable will overwrite the first one.
 * "Add tags" menu in Page Curation toolbar
 * Defaults:
 * English Wikipedia customisation: w:MediaWiki:PageTriageExternalTagsOptions.js
 * "Nominate for deletion" menu in Page Curation toolbar
 * Defaults:
 * English Wikipedia customisation: w:MediaWiki:PageTriageExternalDeletionTagsOptions.js

There are two top-level jQuery variables that define the curation templates that are listed in the curation toolbar under the (add tags) and  (nominate for deletion) buttons. These are:

The 'Main' and 'User' refer to the namespace of the page being curated. Each sub-item in the three sets above defines the tabs shown at the left side of the toolbar, and has the following form:

Then the actual templates that are listed are defined under the above  variable. Each deletion template has the following form:

At the moment, some tags must be present:



Example
So, if you don't want to use any of the built-in deletion templates (which can be imported from NewPagesFeed_Templates.xml, by the way) then you can replace them all with a single one by adding the following at the bottom of your  page:

Extension configuration
The extension is based on the 'patrol' right. For more information about configuring patrolling, see.

The following configuration variables can be set from your LocalSettings.php file:

See extension.json for the full list of config variables.

API
PageTriage adds the following API endpoints which can be used:

Special:Log
The following logs are created by the extension:

Entry points
The extension's features can be triggered by various actions:

Here is a list of some actions and the corresponding entry points they trigger:

NOINDEX
NOINDEX refers to the HTML code, which can be inserted into a page to stop the page from appearing in search engine results. In default installations of MediaWiki, all pages are indexed unless they contain the wikicode. When is set to true, PageTriage will take over deciding what pages are indexed. The logic that determines this is located in, in the   method.

First check

 * First check: Noindex the page if ALL of the following are true:
 * is turned on
 * Page age is less than (set to 90 days on enwiki)
 * Page is in  table
 * Page is marked as unpatrolled (ptrp_status = 0)

Second check
The main use case for the __NOINDEX__ magic word is in deletion templates and maintenance tag templates that are transcluded into mainspace or draftspace. See this search.
 * Second check: If the wikitext has the  magic word, noindex the page if ALL of the following are true:
 * Page age is less than (set to 90 days on enwiki)
 * If  is not null, page is in   table

Is the page in the pagetriage_page table?
In regards to the requirement "Page is in  table", there are several ways a for a page to get into this table:
 * Not been deleted by a PageTriage cron job
 * One cron job deletes redirects older than days old (default 180 days as of Sep 2022), regardless of patrol status. In other words, this cron job autopatrols them.
 * Another cron job deletes reviewed pages after 30 days of being reviewed
 * In a namespace that PageTriage is configured to patrol
 * Isn't an article that is so old it predates the installation of PageTriage

Directory structure

 * /modules/
 * ext.pageTriage.article - related to marking an article as reviewed
 * ext.pageTriage.defaultTagsOptions - tag options that will get merged with tag options found onwiki to populate the list of items in the deletion tag panel and maintenance tag panel
 * ext.pageTriage.enqueue - related to the "Add to the New Pages feed" link that shows up in the left menu toolbox, and the ooui alert box it generates
 * ext.pageTriage.init - creates a mw.pageTriage object
 * ext.pageTriage.list - Special:NewPagesFeed (Vue version)
 * ext.pageTriage.toolbar - Page Curation toolbar (Vue version)
 * ext.pageTriage.toolbarStartup - ActionQueue and toolbar startup code
 * ext.pageTriage.util - Backbone.js models (article, revision, stats)
 * ext.pageTriage.views.list - Special:NewPagesFeed
 * ext.pageTriage.views.toolbar - Page Curation toolbar

Toolbar
The toolbar has three states:,  , and. The maximized toolbar is the full-size toolbar with all buttons. The minimized toolbar still displays and floats, but simply says "Curation" and has an X you can click to close it. The hidden toolbar doesn't display at all, and can be re-opened by clicking the "Open Page Curation" link in the left menu.

External libraries

 * front end
 * old (moving away from)
 * Backbone.js
 * jQuery
 * jQuery Badge
 * jQuery Waypoints
 * jQuery UI
 * Mustache (template system)
 * OOUI - used in modules/ext.PageTriage.enqueue (codesearch)
 * Underscore.js
 * new (moving towards)
 * Codex
 * Moment.js
 * Vue

Backbone and Underscore are unusual libraries to use in MediaWiki extensions, and jQuery UI is deprecated. Long term, we are interested in replacing these front end libraries, to make the extension easier to maintain.

mw.pageTriage.actionQueue
PageTriage provides a specialised action queue system to allow other scripts and gadgets to integrate with it. This is similar to  except that it uses promises. This is done using the  module. See the comments in the for documentation on how the system works. It is not currently used by any scripts or gadgets on enwiki, but it is used internally by PageTriage.

The actionQueue module is available after the mw.hook  fires. PageTriage will give the action queue handler an Object with the following data, in addition to other data as noted below:


 * — ID of the page being reviewed.
 * — Title of the page, including namespace.
 * — Username of who is using PageTriage.
 * — Username of the creator of the page.
 * — Whether or not the page is currently or will be marked as reviewed.

Available actions

 * — Fired when the reviewer tags a page for deletion. The data given to the handler also includes:
 * — An object of all the templates added to the page. The keys are the template title, and the values are an object of metadata, including things like the speedy deletion code.
 * — Fired when the review status of a page is changed. Also includes:
 * — The personal message the reviewer added for the creator of the page. This may be blank.
 * — Fired when maintenance tags are added to the page. Also includes:
 * — An array of the titles of all templates that were added to the page.
 * — The personal message the reviewer added for the creator of the page. This may be blank.

Example
To use the action queue, register a function to be ran when an aforementioned action is fired. PageTriage will wait for any asynchronous code to complete before doing anything else, such as refreshing the page. For example, to edit Sandbox after a page has been marked as reviewed, you could use:

Where are preferences stored?
Preferences such as the user's Special:NewPagesFeed selected filters are stored as MediaWiki user preferences. The preference name is. It is set using  and read using. This data ends up in the SQL  table. Temporary accounts (IP masking) will not be able to store their preferences.