Constructor
new GlobalWatchlistWatchlistUtils(linker)
#
General helper for converting the api response data into the form we use to display
Parameters:
Name | Type | Description |
---|---|---|
linker |
GlobalWatchlistLinker | Linker for the relevant site, used for Links to user pages for registered users Links to contributions pages for anonymous users Converting links in edit summaries to not be relative to the current site |
- Source:
Methods
convertEdits(editInfo, groupPage) → {}
#
Convert edit info, including adding links to user pages / anonymous users' contributions and grouping results by page when called for
Parameters:
Name | Type | Description |
---|---|---|
editInfo |
Object | |
groupPage |
boolean | Whether to group results by page |
- Source:
Returns:
Converted edits
- Type
getFinalEntries(entries, tagsInfo, EntryClass) → {Array.<GlobalWatchlistEntryBase>}
#
Do various cleanup of entries that goes after merging grouped edits and splitting edits and log entries. This is where we will convert the plain objects to the new classes in T288385.
- Convert raw expiration strings into the tooltip to be shown.
- Add a "flags" property to each entry that will either be
false
or a string with the flags to show next to the entry (new page, minor edit, bot action). - Truncate the timestamp to only show details down to the minute, see T262176. This needs to be done after the sorting of edits and log entries by timestamp, which should be done using the full untruncated version, see T286977.
- Create the HTML to show for the tags associated with an entry. For each tag, if there is
a display configured onwiki, that is shown, otherwise its just the name. See
SiteBase#getTagList
for where the info is retrieved. - Set the comment display to include the updated links in edit summaries/log entries.
In fast mode, or for grouped changes, there is no comment display. The commentDisplay
set here is treated as raw html by the display. We use the
parsedcomment
result from the api, and MediaWiki core takes care of escaping.
Parameters:
Name | Type | Description |
---|---|---|
entries |
Entries to update |
|
tagsInfo |
Object | Keys are tag names, values are the html to display (either the display text with local links updated, or just the name) |
EntryClass |
function | either |
- Source:
Returns:
updated entries, each entry converted to either
GlobalWatchlistEntryEdits
or GlobalWatchlistEntryLog
- Type
- Array.<GlobalWatchlistEntryBase>
makeSingleUserLink(userMessage, isAnon) → {string}
#
Shortcut for makeUserLinks when there is only one user (single edits, ungrouped edits, or log entries) and no need for showing a message for the edit count
Parameters:
Name | Type | Description |
---|---|---|
userMessage |
string | either name or ip address |
isAnon |
boolean | Whether the link is for an anonymous user |
- Source:
Returns:
- Type
- string
makeUserLinks(editsByUser) → {string}
#
Create links based on one-or-more editors
editsByUser has the information for the links to create. It is a map in the following format:
⧼user name/ip address⧽ -> { editCount: ⧼count⧽ anon: ⧼true/false⧽ }
For edits where the user was hidden, the key is: ##hidden##
WARNING: This method returns RAW HTML that is the displayed. jQuery isn't used because we need to handle creating multiple links and returning the same way a single link does, since the caller doesn't know if the entry row is for a single edit or multiple edits grouped For each entry in editsByUser:
- if the user was hidden, the output is hard-coded as the core message
rev-deleted-user
wrapped in a span for styling - if the user wasn't hidden, a link is shown. The text for the link is the username, and the target is the user page (for users) or the contributions page (for anonymous editors), just like at Special:Watchlist. See RCCacheEntryFactory::getUserLink and Linker::userLink.
- if the user made multiple edits, or multiple edits were made by hidden users, the number of
edits is appended after the link, using the
ntimes
core message. This is only the case when grouping results by page. See EnhancedChangesList::recentChangesBlockGroup
Parameters:
Name | Type | Description |
---|---|---|
editsByUser |
Object | Edit information |
- Source:
Returns:
the raw HTML to display
- Type
- string
mergePageEdits(edits) → {Object}
#
Convert an array of two or more objects for specific edits to the same page to one object with the information grouped
Parameters:
Name | Type | Description |
---|---|---|
edits |
Edits to merge |
- Source:
Returns:
Merged information
- Type
- Object
normalizeEntries(entries) → {}
#
Parameters:
Name | Type | Description |
---|---|---|
entries |
Entries in the format returned by the api |
- Source:
Returns:
Entries in a "normalized" format
- Type
rawToSummary(entries, groupPage, tagsInfo) → {Array.<GlobalWatchlistEntryBase>}
#
Convert result from the API to format used by this extension
This is the entry point for the JavaScript controlling Special:GlobalWatchlist and the display of each site's changes.
Parameters:
Name | Type | Description |
---|---|---|
entries |
Entries to convert |
|
groupPage |
boolean | Whether to group results by page |
tagsInfo |
Object | See details at
|
- Source:
Returns:
summary of changes, each change converted to either
GlobalWatchlistEntryEdits
or GlobalWatchlistEntryLog
- Type
- Array.<GlobalWatchlistEntryBase>