Extension:MobileFrontend
| This extension is maintained by the Reading Web team and subject to their Release process. |
The MobileFrontend extension provides a mobile-friendly 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.
Contents
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.
Installation[edit]
- If using Vagrant, install with
vagrant enable-role mobilefrontend && vagrant provision
- Manual installation
- Download and place the file(s) in a directory called
MobileFrontendin yourextensions/folder. - Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/MobileFrontend/MobileFrontend.php";
$wgMFAutodetectMobileView = true;
- If necessary configure at your convenience
Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Configuration settings[edit]
MobileFrontend supports various configuration options that you can define in LocalSettings.php after calling require_once "$IP/extensions/MobileFrontend/MobileFrontend.php";. Note that for a simple site adding $wgMFAutodetectMobileView = true; might be all you need to make it Just Work™.
Configuring mobile browser auto detection[edit]
See /Configuring browser auto-detection
Configuring the main page[edit]
Install Nearby[edit]
MobileFrontend provides the Special:Nearby page with a little configuration. To get this to work a few optional steps are required:
- Install GeoData
- Run update.php
- in LocalSettings.php add $wgMFNearby = true;
- 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 an alien MediaWiki instance for Nearby with the following 2 lines in your LocalSettings. The nearby endpoint will be used to find related content to a given location.
$wgMFNearbyEndpoint = 'http://en.m.wikipedia.org/w/api.php';
$wgMFNearby = true;
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.
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 see the wap version of the mobile extension, use ?useformat=mobile-wap instead.
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 ?mobileaction=beta
If you would like to force your wiki to always display in mobile view, add the following to your LocalSettings.php:
MobileContext::singleton()->setForceMobileView( true );
API[edit]
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 or mobileformat=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) or no. 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 page
- normalizedtitle: 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
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. If your user agent appears to be coming from a mobile device, the Varnish servers will set an appropriate 'X-Device' header for your request, and you will be redirected to the MobileFrontend version of an article. Alternatively, you can click 'Mobile view' in the footer of an article or append "useformat=mobile" to the query string to view an article in the mobile view. Example:
Varnish server vcl config for X-Device
sub vcl_recv {
set req.http.X-Device = req.http.User-Agent;
}
If you are viewing the mobile version of article but wish to see the desktop-version of that article, you can click 'View this article on regular <SITENAME>' to switch back.
If you want to permanently disable the mobile view for your web browser, you can click 'Permanently disable mobile site', which will set a cookie instructing the WMF servers to always display the desktop version of the site.
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.
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
| 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
- MediaWiki extensions without a screenshot
- User interface extensions
- Hook extensions
- Extensions in Wikimedia version control
- Extensions which add rights
- RequestContextCreateSkin extensions
- BeforePageRedirect extensions
- SkinTemplateOutputPageBeforeExec extensions
- TestCanonicalRedirect extensions
- ResourceLoaderTestModules extensions
- GetCacheVaryCookies extensions
- ResourceLoaderRegisterModules extensions
- APIGetAllowedParams extensions
- APIAfterExecute extensions
- APIGetParamDescription extensions
- APIGetDescription extensions
- UnitTestsList extensions
- GetBetaFeaturePreferences extensions
- All extensions
- Extensions used on Wikimedia
- ListDefinedTags extensions
- Mobile skins

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
