Interface should define what is needed to render the mobile (Minerva) skin and should be agnostic of where it comes from. It is passed into the skin or used by the skin during construction.
The MobileFormatter::newFromContext method will be passed an implementation of the IContentProvider which will provide access to the HTML for the current page. A DefaultContentProvider will obtain the chunk of HTML generated by the PHP parser.
The idea is that future implementations of IContentProvider can provide content from places such as RESTBase and the MediaWiki API.
Motivations
- The developer tool using the live mediawiki api will be an alternative solution to T104561
- It will help us debug certain issues as proven by our work in T149852 and T151838
Acceptance criteria
- Define IContentProvider which provides a basic interface that is implemented by DefaultContentProvider which is passed to MobileFormatter.
- IContentProvider provides a getHTML method. The constructor is passed an instance of GlobalVarConfig and OutputPage to allow calls to addModule, addModuleStyles and getTitle
- ExtMobileFrontend::DOMParse will be refactored so it uses IContentProvider to obtain the HTML that should be formatted by MobileFormatter
- For development purposes introduce MwApiContentProvider which obtains its HTML from a foreign (or local) mediawiki api. The api should be configurable so we can point to any wiki of our choosing. This will allow us to test MobileFormatter and styles on live Wikipedia articles.
- Make it possible to configure DefaultContentProvider or MwApiContentProvider as the default formatting engine for the wiki.
e.g. $wgMFContentProviderClass = 'MwApiContentProvider'
- The URL used by MwApiContentProvider is configurable so we can use it for any wiki in any language
e.g. $wgMFMwApiMobileFormatterBaseUri = 'https://en.wikipedia.org/w/api.php'
- Document how to use the new service on Extension:MobileFrontend
Future work
In future we may also want to create an interface for MobileFormatter. The RESTBase mobile content service for instance is a ContentProvider and a formatter so running MobileFormatter on the content provided from the mobile content service would be wasteful. This is out of scope for this particular task.