Requests for comment/ChangesList formatting
ChangesList formatting | |
---|---|
Component | General |
Creation date | |
Author(s) | aude |
Document status | accepted See Phabricator. |
Background
[edit]The list of changes on the Special:Recentchanges, Special:Watchlist and Special:RecentChangesLinked ("Related changes") are formatted using the ChangesList class or derivatives of it. There are several formats for ChangesList, including OldChangesList, EnhancedChangesList, as well, as CleanChanges provided by an extension and perhaps others. ChangesList generally take a list or RecentChange records and one-by-one format them in a standard way, with special casing for log entries.
Problem
[edit]As new types of RecentChange entries become available, such as provided by extensions (e.g. Flow, Wikibase), the standard formatting does not always work well. For the OldChangesList, there is a hook for each change line, at the end, after formatting it in the standard way, where extensions can modify it or replace it. There is no equivalent hook(s) for EnhancedChanges and even if there were, certain aspects of formatting are hardcoded like formatting the recent changes flags.
Proposal
[edit]Formatters for rc_source types
[edit]The recentchanges table now has a newish column, rc_source, which allows specifying the type of change and for more flexible for specifying different types of RecentChange entries. For example, 'mw.edit', 'mw.log', 'mw.new' for core RecentChange types and 'wb' and 'flow' provided by extensions.
A more flexible approach would be to define ChangeLineFormatter interface and allow registering ChangeLineFormatter implementations for each rc_source type. This could be done by registering formatting callbacks or formatter classes per source type. If a formatter is not registered, then the default formatting (e.g. current stuff) can be applied.
ChangesListFormatter
[edit]To ensure consistent formatting in these formatters, the formatting code in the ChangesList class needs to be split out into a utility class that is not an abstract class, as it doesn't make sense for the formatters to be subclasses of ChangesList.
See also
[edit]Related extensions
[edit]- https://github.com/wikimedia/mediawiki-extensions-CleanChanges
- https://github.com/svn2github/wikia/tree/master/extensions/uniwiki/FormatChanges
- https://github.com/wikimedia/mediawiki-extensions-SimpleChanges
- https://github.com/wikimedia/mediawiki-extensions-RecentActivityFeed
- https://github.com/wikimedia/mediawiki-extensions-InterwikiIntegration