For Minerva to be pulled out of the MobileFrontend repository the skin portion needs to be agnostic to the existence of MobileFrontend.
MobileContext will stay in MobileFrontend so any references to this class should be ported to MobileFrontend.skin.hooks.
Testing Notes
N.B. for the following you should test on the mobile version of the Beta Cluster wiki.
The features immediately affected by the change(s) are:
- Some entries of the hamburger menu on the mobile site. You should test: whether you can log in/out; you can access the mobile options page.
- The "font (size) changer" on the mobile options page.
- Section collapsing (and expansion). You should test whether you see collapsed sections and can expand/collapse them.
- The "Categories" button. You should test whether you see the button at the bottom of a page (that is in one or more categories!) ---
There appear to be a handful of things that SkinMinerva gets from MobileContext:
- Whether the user is a member of the beta group (or "MobileFrontend is in beta mode" as we like to say) – seriously, we should align our language with that of the codebase…
- Whether the mobile view should be displayed (see MobileContext#shouldDisplayMobileView).
- Access to the global configuration, i.e. an instance of GlobalVarConfig with the default 'wg' prefix.
- Access to something capable of generating URLs for the mobile domain (see MobileContext#getMobileUrl).
1, 2, and 3 are just state. 4 should be extracted into its own class, which would hide away the complexity of generating URLs and for which domains. All of them, however, could be injected:
public function __construct( $shouldDisplayMobileView, $isBetaGroupMember, Config $config, Router $router ) { $this->isMobileMode = $shouldDisplayMobileView; $this->isBetaGroupMember = $isBetaGroupMember; $this->config = $config; $this->router = $router; // ... }
Plan (YMMV)
- Audit occurrances of $this->isMobileMode (according to T148197#2760151 the skin shouldn't be varying its behaviour)
- Inject an instance of GlobalVarConfig via the constructor.
- [Register a factory function with SkinFactory](https://github.com/wikimedia/mediawiki/blob/master/includes/skins/SkinFactory.php#L54-L73).
- Replace all calls to SkinMinerva#getMFConfig with $this->config.
- Create MobileFrontend\Router class, which has the following shape, and inject it via the constructor.
class Router { public function getLoginUrl( array $returnTo ) { } public function getLogoutUrl( array $returnTo ) { } }
- Replace all calls to MobileContext#getMobileUrl with the appropriate Router method.