Constructor
new Page(mwTitle, genderedNameopt)
- Source:
Create a page instance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
mwTitle |
external:mw.Title | ||
genderedName |
string |
<optional> |
Throws:
-
If the string in the first parameter is not a valid title.
- Type
- CdError
Members
addSectionForm :CommentForm|undefined
- Source:
"Add section" form.
Type:
- CommentForm | undefined
areNewTopicsOnTop :boolean|undefined
- Source:
Whether new topics go on top on this page. Filled upon running module:pageRegistry.Page#guessNewTopicPlacement.
Type:
- boolean | undefined
code :string|undefined
- Source:
Page's source code (wikitext), ending with \n
. Filled upon running module:pageRegistry.Page#loadCode.
Type:
- string | undefined
firstSectionStartIndex :number|undefined
- Source:
The start index of the first section, if new topics are on top on this page. Filled upon running module:pageRegistry.Page#guessNewTopicPlacement.
Type:
- number | undefined
isActionable :boolean
- Source:
Is the page actionable, i.e. you can add a section to it. Can be true
only for the current
page.
Type:
- boolean
mwTitle
- Source:
Page's mw.Title object.
name :string
- Source:
Page name, with a namespace name, not necessarily normalized (not normalized if a gendered name is available). The word separator is a space, not an underline.
Type:
- string
namespaceId :number
- Source:
Namespace number.
Type:
- number
pageId :number|undefined
- Source:
Page ID on the wiki. Filled upon running module:pageRegistry.Page#loadCode or module:pageRegistry.Page#edit. In the latter case, it is useful for newly created pages.
Type:
- number | undefined
queryTimestamp :string|undefined
- Source:
Time when module:pageRegistry.Page#code was queried (as the server reports it). Filled upon running module:pageRegistry.Page#loadCode.
Type:
- string | undefined
realName :string|undefined
- Source:
If module:pageRegistry.Page#name redirects to some other page, the value is that page. If not, the value is the same as module:pageRegistry.Page#name. Filled upon running module:pageRegistry.Page#loadCode.
Type:
- string | undefined
(nullable) redirectTarget :string|undefined
- Source:
Page where module:pageRegistry.Page#name redirects. Filled upon running module:pageRegistry.Page#loadCode.
Type:
- string | undefined
revisionId :number|undefined
- Source:
ID of the revision that has module:pageRegistry.Page#code. Filled upon running module:pageRegistry.Page#loadCode.
Type:
- number | undefined
source :PageSource
- Source:
Page's source code object. This is mostly for polymorphism with CommentSource and SectionSource; the source code is in module:pageRegistry.Page#code.
Type:
- PageSource
title :string
- Source:
Page title, with no namespace name, normalized. The word separator is a space, not an underline.
Type:
- string
Methods
addAddTopicButton()
- Source:
For internal use. Add an "Add topic" button to the bottom of the page if there is an "Add topic" tab. (Otherwise, it may be added to a wrong place.)
addCommentFormToPage(mode, commentForm)
- Source:
Clean up traces of a comment form targeted at this page to the page.
Parameters:
Name | Type | Description |
---|---|---|
mode |
string | |
commentForm |
CommentForm |
addSection(initialStateopt, commentFormopt, preloadConfigopt, newTopicOnTopopt)
- Source:
Create an add section form if not existent.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
initialState |
object |
<optional> |
||
commentForm |
CommentForm |
<optional> |
||
preloadConfig |
object |
<optional> |
CommentForm.getDefaultPreloadConfig()
|
|
newTopicOnTop |
boolean |
<optional> |
false
|
autoAddSection(dtFormData)
- Source:
Add an "Add section" form or not on page load depending on the URL and presence of a DiscussionTools' "New topic" form.
Parameters:
Name | Type | Description |
---|---|---|
dtFormData |
object |
canHaveArchives() → (nullable) {boolean}
- Source:
Check if this page can have archives. If the page is an archive page, returns false
. Relies
on module:defaultConfig.pagesWithoutArchives and
module:defaultConfig.archivePaths and/or, for the current page, elements with the class
cd-archivingInfo
and attribute data-can-have-archives
.
Returns:
- Type
- boolean
cleanUpCommentFormTraces()
- Source:
Remove a comment form targeted at this page from the page.
(async) compareRevisions(revisionIdFrom, revisionIdTo) → {Promise.<string>}
- Source:
Get a diff between two revisions of the page.
Parameters:
Name | Type | Description |
---|---|---|
revisionIdFrom |
number | |
revisionIdTo |
number |
Returns:
- Type
- Promise.<string>
(async) edit(customOptions) → {Promise.<string>}
- Source:
Make an edit API request (https://www.mediawiki.org/wiki/API:Edit).
Parameters:
Name | Type | Description |
---|---|---|
customOptions |
object | See https://www.mediawiki.org/wiki/API:Edit. At least
|
Returns:
Timestamp of the edit in the ISO format or 'nochange'
if nothing
has changed.
- Type
- Promise.<string>
exists() → {boolean}
- Source:
Check whether the current page exists (is not 404).
Returns:
- Type
- boolean
findNewSelf() → {module:pageRegistry.Page}
- Source:
Returns:
getArchivedPage() → {module:pageRegistry.Page}
- Source:
Get the source page for the page (i.e., the page from which archiving is happening). Returns
the page itself if it is not an archive page. Relies on
module:defaultConfig.archivePaths and/or, for the current page, elements with the class
cd-archivingInfo
and attribute data-archived-page
.
Returns:
getArchivePrefix(onlyExplicitopt) → (nullable) {string}
- Source:
Get the archive prefix for the page. If no prefix is found based on
module:defaultConfig.archivePaths and/or, for the current page, elements with the class
cd-archivingInfo
and attribute data-archive-prefix
, returns the current page's name. If the
page is an archive page or can't have archives, returns null
.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
onlyExplicit |
boolean |
<optional> |
false
|
Returns:
- Type
- string
getCommentAboveReply(commentForm) → (nullable) {Comment}
- Source:
If a new section is added to the page, get the comment that will end up directly above the section.
Parameters:
Name | Type | Description |
---|---|---|
commentForm |
CommentForm |
Returns:
- Type
- Comment
getCommentFormMethodName(mode) → {string}
- Source:
Get the name of the page's method creating a comment form with the specified mode. Used for polymorphism with Section.
Parameters:
Name | Type | Description |
---|---|---|
mode |
string |
Returns:
- Type
- string
getDecodedUrlWithFragment(fragment, permanent) → {string}
- Source:
Get a decoded URL with a fragment identifier.
Parameters:
Name | Type | Description |
---|---|---|
fragment |
string | |
permanent |
boolean | Get a permanent URL. |
Returns:
- Type
- string
getIdentifyingData() → {null}
- Source:
Used for polymorphism with Comment#getIdentifyingData and Section#getIdentifyingData.
Returns:
- Type
- null
getRelevantComment() → {null}
- Source:
Used for polymorphism with Comment#getRelevantComment and Section#getRelevantComment.
Returns:
- Type
- null
getRelevantSection() → {null}
- Source:
Used for polymorphism with Comment#getRelevantSection and Section#getRelevantSection.
Returns:
- Type
- null
(async) getRevisions(customOptionsopt, inBackgroundopt) → {Promise.<Array>}
- Source:
Get a list of revisions of the page (the redirects
parameter is set to true
by default).
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
customOptions |
object |
<optional> |
{}
|
|
inBackground |
boolean |
<optional> |
false
|
Make a request that won't set the process on hold when the tab is in the background. |
Returns:
- Type
- Promise.<Array>
getUrl(parameters) → {string}
- Source:
Get the URL of the page with the specified parameters.
Parameters:
Name | Type | Description |
---|---|---|
parameters |
object |
Returns:
- Type
- string
guessNewTopicPlacement()
- Source:
Enrich the page instance with the properties regarding whether new topics go on top on this page (based on various factors) and, if new topics are on top, the start index of the first section.
Throws:
isActive() → (nullable) {boolean}
- Source:
Check whether the current page is an active talk page: existing, the current revision, not an archive page.
This value is constant in most cases, but there are exceptions:
- The user may switch to another revision using RevisionSlider.
- On a really rare occasion, an active page may become inactive if it becomes identified as an archive page. This was switched off when I wrote this.
Returns:
- Type
- boolean
isArchive() → {boolean}
- Source:
Check if the page is an archive page. Relies on module:defaultConfig.archivePaths
and/or, for the current page, elements with the class cd-archivingInfo
and attribute
data-is-archive-page
.
Returns:
- Type
- boolean
isCommentable() → (nullable) {boolean}
- Source:
Check whether the current page is eligible for submitting comments to.
Returns:
- Type
- boolean
isCurrentArchive() → {boolean}
- Source:
Check whether the current page is an archive and the displayed revision the current one.
Returns:
- Type
- boolean
isOwnTalkPage() → {boolean}
- Source:
Check whether the page is the user's own talk page.
Returns:
- Type
- boolean
isProbablyTalkPage() → {boolean}
- Source:
Check if the page is probably a talk page.
Returns:
- Type
- boolean
(async) loadCode(tolerateMissingopt)
- Source:
Make a revision request (see https://www.mediawiki.org/wiki/API:Revisions) to load the
wikitext of the page, together with a few revision properties: the timestamp, redirect target,
and query timestamp (curtimestamp
). Enrich the page instance with those properties. Also set
the realName
property that indicates either the redirect target if it's present or the page
name.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
tolerateMissing |
boolean |
<optional> |
true
|
Assign |
Throws:
(async) markAsRead(revisionId)
- Source:
Mark the page as read, optionally setting the revision to mark as read.
Parameters:
Name | Type | Description |
---|---|---|
revisionId |
number | Revision to mark as read (setting all newer revisions unread). |
(async) parse(customOptionsopt, inBackgroundopt, markAsReadopt) → {Promise.<object>}
- Source:
Make a parse request (see https://www.mediawiki.org/wiki/API:Parsing_wikitext).
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
customOptions |
boolean |
<optional> |
||
inBackground |
boolean |
<optional> |
false
|
Make a request that won't set the process on hold when the tab is in the background. |
markAsRead |
boolean |
<optional> |
false
|
Mark the current page as read in the watchlist. |
Throws:
Returns:
- Type
- Promise.<object>
(async) purge()
- Source:
Purge cache of the page.