Extension:Proofread Page/Lua reference

Getting started
On a MediaWiki wiki with ProofreadPage and enabled, a Lua module is provided which allows access to certain features and information about pages in the Index and Page namespaces.

Expensive functions
Some functions result in a database lookup and are classed as "expensive". Expensive lookups are cached where possible, so repeated access to the same data is "free" after the first lookup.

Note that there are several "types" of expensive data: first access to each of these is a new expensive lookup:


 * Index pages:
 * Getting the page count of an index
 * Getting the n'th page for an index (each index is cached, so getting two pages from the same index counts as a single expensive operation
 * Getting progress stats for an index (expensive once per index)
 * Loading index page content: categories and fields share a cache, so will only count as one expensive lookup per index


 * Page pages:
 * Getting the index for a given page (expensive once per page)
 * Getting the page numbering for a page: one expensive call if the index for the page is not cached, and another for the pagination of the index (only once per index)
 * Getting pages with a given offset requires the current page object's numbering (see above), plus the index for the page (expensive per-page)

Constants and functions

 * Namespaces:
 * : the current Index namespace number
 * : the current Page namespace number
 * level constants:

Construction
Access an object representing an index object with the  function:

The argument can be a string or an object.

Fields and methods
The Index object has the following fields:


 * title: gets the  object referring to this page
 * pageCount: gets the number of pages in the index (this is expensive)
 * getPage( n ): gets the n'th Page of the index as a Page object (this is expensive if the page hasn't been looked up before)
 * Progress statistics:
 * existingPages: gets the number of pages in the index that currently exist (this is expensive if the progress stats are not cached)
 * missingPages: gets the number of pages in the index that currently do not exist (this is expensive if the progress stats are not cached)
 * pagesWithLevel( level ): gets the number of pages in the index that currently have the given level (this is expensive if the progress stats are not cached)
 * categories: Get a list of the categories the index page specifies, as  objects (this is expensive if the index content is not cached)
 * fields: Get a table of the fields that the index page has set (this is expensive if the index content is not cached)

All fields are read-only.

Construction
Access an object representing an index object with the  function:

The argument can be a string or an  object.

Fields and methods
The Page object has the following fields:


 * title: gets the  object referring to this page
 * index: gets the index object referring to the parent Index page (this is expensive if the parent index is not cached)
 * quality: gets the quality level of the page (this is expensive if the quality information is not cached)
 * position: gets the position of the page in the index pagelist, starting at 1 (this is expensive if the page numbering is not cached)
 * displayedNumber: gets the displayed page number of the page (this is expensive if the page numbering is not cached)
 * rawNumber: gets the raw page number of the page (this is expensive if the page numbering is not cached)
 * Access to other pages in the same index:
 * withOffset( n ): get the page the the given offset (e.g. 1 is the next page) in the index page list (this is expensive if the resultant page hasn't been looked up before)
 * nextPage: shorthand for withOffset( 1 )
 * previousPage: shorthand for withOffset( -1 )

All fields are read-only.