Extension:MobileFrontend

Installation

 * 1) Copy the files from the SVN repository to your server (see the "Download" links in the sidebox).
 * 2) Add this link to the bottom of LocalSettings.php:

Configuration settings
The following variables can be defined in LocalSettings.php after calling require_once("$IP/extensions/MobileFrontend/MobileFrontend.php"):

Homepage
By default, the only content that a user will see on their project homepage is search, license, and action control. In order to see content you have to use the appropriate css selectors. See http://meta.wikimedia.org/wiki/Mobile_Projects/Mobile_Gateway#Mobile_homepage

More information
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 querystring: 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.





Legacy API
Currently, MobileFrontend has an ad-hoc API available through the main entry point. If you add a &format=json you will get back a document that has the following sections


 * title ~ Page title
 * html ~ HTML body

ex. http://en.wikipedia.org/wiki/Main_Page?useformat=mobile&format=json {   "title": "Main Page", "html":" Today's featured article<\/h2> \n <\/img><\/a> <\/div>\n Tom Driberg<\/a><\/b> (1905\u20131976) was a British journalist and politician who was a Labour Party<\/a> Member of Parliament<\/a> between 1942 and 1974. ....

New API
The new API currently under development does the following:

Extended action=parse
action=parse</tt> receives the following extra parameters:
 * mobileformat={html|wml}</tt>: Return rendered page in a mobile format, HTML for modern phones or WML for dumb phones.
 * noimages</tt>: Disable images in mobile output.
 * mainpage</tt>: Apply mobile main page transformations.

Example:

api.php?action=parse&page=Main_Page&mobileformat=html&prop=text&format=json

 {	"parse": { "title": "Main Page", "text": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<?xml encoding=\"UTF-8\"?>\n <div id=\"content\"> This is a <a href=\"http:\/\/www.mediawiki.org\/wiki\/Extension:GeoData\" class=\"extiw\" title=\"mediawikiwiki:Extension:GeoData\">GeoData<\/a> test wiki. . . . </tt>

action=mobileview
Delivers rendered mobile- for mobile app and dynamic section views. Almost like a restricted-functionality action=parse</tt>, but more flexible and separate sections HTML is always result of full page parse.

Parameters:
 * page</tt>: Title of page to process.
 * sections</tt>: Pipe-separated list of section numbers for which to return text.
 * prop</tt>: Which information to get:
 * text</tt>: HTML of selected section(s)
 * sections</tt>: Information about all sections on page
 * sectionprop</tt>: 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</tt>: Return HTML without images.

Returned section information also includes the id</tt> for every section - its zero-based number; and for sections that contains references added by Extension:Cite, there's also references</tt> data member.

Examples:


 * |sections&format=jsonfm api.php?action=mobileview&page=Example_page&sections=0&prop=text|sections&format=json

Same request for XML: |sections&format=xmlfm api.php?action=mobileview&page=Example_page&sections=0&prop=text|sections&format=xml

prop=excerpts
Returns article excerpts - text representation of ledes. Two formats are available: cleaned up HTML and plain text. Parameters:


 * length</tt>: Length of excerpts. If this parameter is omitted, all text until the first section heading will be returned.
 * limit</tt>: Maximum number of excerpts to return. Because excerpts generation can be slow, the limit is capped at 10 (20 for users with <tt>apihighlimits</tt> permission).
 * <tt>plaintext</tt>: Return plain-text excerpts.
 * <tt>continue</tt>: When more results are available, use this parameter to continue.

Example:

api.php?action=query&prop=excerpts&exlength=100&titles=Earth&format=json