Extension:MobileFrontend
The MobileFrontend extension:
- Creates a separate mobile site for your mobile traffic.
- system administrators to provide a different skin e.g. Skin:MinervaNeue
- provides various content transformations to make your content more friendly
- notably section collapsing and content re-arrangement and removal.
- simplifies mobile footer and adds a desktop/mobile site link
- provides replacement special pages for MediaWiki pages that are not mobile friendly - Special:History, Special:Contributions, Special:MobileCite, Special:Watchlist, Special:Preferences, Special:MobileDiff.
- It provides the special pages Special:Nearby, Special:MobileOptions (for mobile skin preferences), Special:MobileLanguages (for language selection), Special:MobileMenu (for non-JS menu support in mobile skins) and Special:Uploads (for mobile friendly image upload view)
This page is designed for end users who want to install it on their development instance. If you are keen to help us build it and improve it we encourage you to get involved.
![]() | This extension is maintained by the Reading Web team. |
Contents
- 1 Prerequisites
- 2 Installation
- 3 Configuration settings
- 4 Local customisations
- 5 Legacy features of MobileFrontend
- 6 For developers/sysadmins
- 7 Using the mobile view
- 8 FAQ
- 8.1 Q: How do I customise the main menu of the Minerva skin?
- 8.2 Q: How do I add HTML to the Minerva skin, for example to add ads or additional script tags?'
- 8.3 Q: The extension I am using doesn't seem to work on MobileFrontend. Why?
- 8.4 Q: I upgraded MobileFrontend and now I'm getting a fatal exception!
- 8.5 Q: After upgrading MediaWiki I'm getting an exception wgMFDefaultSkinClass is not setup correctly.
- 9 For Extension Developers
- 10 See also
- 11 References
Prerequisites[edit]
- Although MediaWiki doesn't require it, PHP must have mbstring support for this extension to work (task T62174).
- Release for MediaWiki ≤ 1.24 of MobileFrontend requires the extension Mantle.
Before installing MobileFrontend, if you make heavy use of templates and/or inline styles (the style attribute) you should review your content to see whether it is mobile friendly. The TemplateStyles extension can be used to style content so that it renders nicely on mobile and desktop. MobileFrontend will not magically fix this for you!
In particular, you may want to review your landing page (main page). See Mobile homepage formatting.
Installation[edit]
- If using Vagrant , install with
vagrant roles enable mobilefrontend --provision
Manual installation
- Download and place the file(s) in a directory called
MobileFrontend
in yourextensions/
folder.
- Add the following code at the bottom of your LocalSettings.php:
wfLoadExtension( 'MobileFrontend' ); $wgMFAutodetectMobileView = true;
- If necessary configure at your convenience
Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Setup Nearby[edit]
MobileFrontend provides the Special:Nearby page with a little configuration. To get this to work a few optional steps are required:
- Due to browser security you will need to be running a secure site over SSL — it is not possible to request a user's location over http
- Install the GeoData extension
- Run update.php
- In LocalSettings.php add
$wgMFNearby = true;
- Determine article coordinates:
- Add data to your articles to one or more pages
{{#coordinates:37.786971|-122.399677|primary}}
see the documentation for GeoData for syntax details. - Alternatively you can use a separate MediaWiki installation for Nearby by setting
$wgMFNearbyEndpoint
in your LocalSettings.php file. For example,$wgMFNearbyEndpoint = 'https://en.m.wikipedia.org/w/api.php';
will use coordinates of English Wikipedia articles. The nearby endpoint will be used to find content related to a given location.
- Add data to your articles to one or more pages
Setup a skin[edit]
MobileFrontend provides you with a mobile formatted website to go alongside your existing desktop website. You can skin it however you want.
// Choose one of those:
$wgMFDefaultSkinClass = 'SkinMinerva'; // use Minerva skin
$wgMFDefaultSkinClass = 'SkinVector'; // use Vector skin
$wgMFDefaultSkinClass = 'SkinTimeless'; // use Timeless skin
The following skins are compatible with MobileFrontend:
- Skin:Minerva (stable, default on WMF wikis)
- Skin:Vector (default desktop skin, uses an experimental responsive mode for mobile)
- Skin:Timeless (experimental skin)
Configuration settings[edit]
See Extension:MobileFrontend/Configuration
Additional tweaks[edit]
Get the most out of MobileFrontend by adding these other optional dependencies:
- Extension:Geodata - get Special:Nearby and geotag your articles
- Extension:PageImages - adds images to search and nearby results
- Extension:VisualEditor - add Visual editing to your mobile experience.
Local customisations[edit]
CSS styling[edit]
To apply CSS to your mobile theme, edit MediaWiki:Mobile.css, the counterpart of MediaWiki:Common.css.
More information[edit]
If you would like to test the mobile extension on a desktop browser or your device doesn't render the mobile version, you can append the following key-value pair to the query string: ?useformat=mobile
e.g., https://en.wikipedia.org/wiki/Chuck_Schuldiner?useformat=mobile
If you would like to view a page in the beta without enabling it across the entire site you can append to the query string of any page
Legacy features of MobileFrontend[edit]
MobileFrontend has traditionally been a very large extension. Many features have either surpassed their requirements or will do at some future date. These are listed below.
API[edit]
APIs are provided by the MobileFrontend extension, but long term we expect to deprecate them in favour of Mobile Content Service. Use these APIs at your own risk. They may disappear (although we will give you sufficient notice when they do)!
Extended action=parse[edit]
action=parse
accepts extra parameters:
mobileformat=
- Return rendered page HTML in a mobile format 1.23+. Prior to MediaWiki 1.23, you could specify
mobileformat=html
to output HTML for modern phones ormobileformat=wml
to output WML for dumb phones (see mailing list messagefor details). noimages
- Disable images in mobile output.
mainpage
- Apply mobile main page transformations.
Example:
Result |
---|
{
"parse": {
"title": "Therion (band)",
"text": {
"*": "<div><table class=\"infobox vcard plainlist\" style=\"width:22em\"><tr><th colspan=\"2\" style=\"text-align:center;font-size:125%;font-weight:bold;background-color: #b0c4de\"><span class=\"fn org\">Therion</span></th>\n</tr><tr><td colspan=\"2\" style=\"text-align:center\"><a href=\"/wiki/File:2130860153_281d30b3bf_b.jpg\" class=\"image\">
...
|
action=mobileview[edit]
mobileview | |
---|---|
This module cannot be used as a Generator . |
|
Prefix | |
Required rights | none |
Post only? | No |
Generated help | Current |
Delivers content optimized for mobile devices for use by mobile apps and dynamic section views. Almost like a restricted-functionality action=parse
, but more flexible and returns separate sections that are always obtained from full-page parse.
Parameters:
page
- Title of page to process.
sections
- Pipe-separated list of section numbers for which to return text or
all
for all sections. redirect
- Whether redirects should be followed,
yes
(default) orno
. This parameter is intentionally made similar to the one to index.php. prop
- Which information to get:
text
: HTML of selected section(s)sections
: Information about all sections on pagenormalizedtitle
: Normalized page title, will be returned only if it differs from the specified one.
sectionprop
- What information about sections to get: pipe-separated list of value types defined by parser. It's the same as in action=parse: toclevel, level, line, number, index, fromtitle, anchor. "byteoffset" has been excluded as it makes no sense for this action.
noimages
- Return HTML without images.
noheadings
- Return HTML without headings.
Returned section information also includes the id
for every section - its zero-based number; and for sections that contains references added by Cite, there's also references
data member.
Examples:
Result |
---|
{
"mobileview": {
"sections": [
{
"id": 0,
"text": "<p>Hi<sup id=\"cite_ref-1\" class=\"reference\"><a href=\"#cite_note-1\">[1]</a></sup></p>"
},
{
"toclevel": 1,
"line": "This is first section",
"id": 1
},
{
"toclevel": 2,
"line": "This is nested section",
"id": 2
},
{
"toclevel": 1,
"line": "References",
"id": 3,
"references": ""
}
]
}
}
|
Same request for XML:
Result |
---|
<?xml version="1.0"?>
<api>
<mobileview>
<sections>
<section id="0" xml:space="preserve"><p>Hi<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup></p></section>
<section toclevel="1" line="This is first section" id="1" />
<section toclevel="2" line="This is nested section" id="2" />
<section toclevel="1" line="References" id="3" references="" />
</sections>
</mobileview>
</api>
|
prop=extracts[edit]
Migrated to Extension:TextExtracts
meta=siteinfo[edit]
The domain of the mobile version of the site (which might or might not be the same as the normal domain) is available under the mobileserver
key of the general siteinfo information.
For developers/sysadmins[edit]
Testing with articles on a foreign wiki (live data)[edit]
MobileFrontend can now be configured locally to render articles from other MediaWiki instances.[1] This can help you debug problems locally instead of importing articles which may have dependencies on various templates and Wikibase identifiers from production to your local instance. This is not recommended for production usage.
The code below will turn your local MediaWiki mobile site into a Wikivoyage viewer:
$wgMFContentProviderClass = 'MobileFrontend\ContentProviders\MwApiContentProvider';
$wgMFMwApiContentProviderBaseUri = 'https://en.m.wikivoyage.org/w/api.php';
This is particularly useful for testing different mobile skins using the wgMFDefaultSkinClass config option.
Using the mobile view[edit]
WMF sites[edit]
On Wikimedia Foundation-run sites, we use Varnish caching servers to check the user agent of your device.
Non-WMF sites[edit]
For non-WMF sites, you can either set up your configuration to mimic how things are done at the WMF (doing device detection at the proxy layer and setting specific X-Device headers), or you can simply use "?useformat=mobile" to switch an article to use the mobile view.
$wgMFMobileHeader = 'X-WAP';
or modify your cache (Varnish) header setting. As long as them match.FAQ[edit]
The following questions frequently appear on our talk page. Please check this list before posting about them on the talk page or use the existing talk topic, if available, to receive clarifications.
[edit]
A: This is tracked in phabricator but you can see Topic:Tiggc18fvd3stmsf has an interim solution.
Q: How do I add HTML to the Minerva skin, for example to add ads or additional script tags?'[edit]
A: You can do this by editing the template file for the skin (currently include/skins/minerva.mustache). See this discussion for details.
Q: The extension I am using doesn't seem to work on MobileFrontend. Why?[edit]
A: It's likely the extension is old and needs to add compatibility to MobileFrontend. Please contact the developer of the extension and point them to ResourceLoader/Writing a MobileFrontend friendly ResourceLoader module. Please do not post to the talk page, as in this case it would be better to file a bug on Phabricator.org (you can login using your MediaWiki.org username) for a quicker response.
Q: I upgraded MobileFrontend and now I'm getting a fatal exception![edit]
A: You are probably using incompatible versions of MobileFrontend and MediaWiki. In most cases, we can't help you here. Try upgrading MobileFrontend or MediaWiki to resolve your issue.
Q: After upgrading MediaWiki I'm getting an exception wgMFDefaultSkinClass is not setup correctly.[edit]
A: MobileFrontend currently assumes you have the MinervaNeue skin installed. If you don't you'll need to install this or configure your mobile skin per instructions above.
For Extension Developers[edit]
By default resource modules in extensions will not be loaded in mobile view. Should a module need to be loaded while in mobile view this guide on writing MobileFrontend friendly modules will be of help.
See also[edit]
- Mobile web browsers supported by MobileFrontend
- Extension:TextExtracts
- Wikimedia's MobileFrontend configuration file
References[edit]
- ↑ See this YouTube demo video
![]() | This extension is being used on one or more Wikimedia projects. This probably means that the extension is stable and works well enough to be used by such high-traffic websites. Look for this extension's name in Wikimedia's CommonSettings.php and InitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page. |
- GPL licensed extensions
- Stable extensions
- User interface extensions
- Hook extensions
- Extensions in Wikimedia version control
- APIGetAllowedParams extensions
- APIAfterExecute extensions
- APIGetParamDescription extensions
- APIGetDescription extensions
- RequestContextCreateSkin extensions
- MediaWikiPerformAction extensions
- OutputPageBeforeHTML extensions
- SkinAfterBottomScripts extensions
- SkinTemplateOutputPageBeforeExec extensions
- BeforePageRedirect extensions
- DiffViewHeader extensions
- ResourceLoaderTestModules extensions
- GetCacheVaryCookies extensions
- TestCanonicalRedirect extensions
- ResourceLoaderGetConfigVars extensions
- SpecialPage initList extensions
- ListDefinedTags extensions
- ChangeTagsListActive extensions
- RecentChange save extensions
- AbuseFilter-generateUserVars extensions
- AbuseFilter-builder extensions
- SpecialPageBeforeExecute extensions
- UserLoginComplete extensions
- BeforePageDisplay extensions
- CustomEditor extensions
- GetPreferences extensions
- GetBetaFeaturePreferences extensions
- Gadgets::allowLegacy extensions
- CentralAuthLoginRedirectData extensions
- CentralAuthSilentLoginRedirect extensions
- ResourceLoaderRegisterModules extensions
- EventLoggingRegisterSchemas extensions
- OutputPageParserOutput extensions
- HTMLFileCache::useFileCache extensions
- LoginFormValidErrorMessages extensions
- ResourceLoaderGetLessVars extensions
- ThumbnailBeforeProduceHTML extensions
- PageRenderingHash extensions
- AfterBuildFeedLinks extensions
- MakeGlobalVariablesScript extensions
- TitleSquidURLs extensions
- MediaWikiServices extensions
- All extensions
- Extensions used on Wikimedia
- Mobile skins