Extension:MobileFrontend/zh

移动前端（MobileFrontend）扩展提供一个为移动设备改进的外观. 此页面专为希望在他们的开发实例中安装它终端用户服务. 如果您渴望帮助我们构造它并改进它，我们鼓励您前往项目介绍页面.

先决条件

 * 虽然MediaWiki不需要，但PHP必须有mbstring支持以使此扩展工作（）.
 * 用于MediaWiki ≤ 1.24发布版本的移动前端需要扩展Mantle.

配置设置
MobileFrontend supports various configuration options that you can define in LocalSettings.php after calling. Note that for a simple site adding  might be all you need to make it Just Work™.

Configuring mobile browser auto detection
参见/配置浏览器自动检测

Install Nearby
MobileFrontend provides the Special:Nearby page with a little configuration. To get this to work a few optional steps are required:

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.
 * Install GeoData
 * Run update.php
 * in LocalSettings.php add $wgMFNearby = true;
 * Add data to your articles to one or more pages   see the documentation for GeoData for syntax details

Additional tweaks
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样式
To apply CSS to your mobile theme, edit MediaWiki:Mobile.css, the counterpart of MediaWiki:Common.css.

更多信息
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

If you would like to force your wiki to always display in mobile view, add the following to your LocalSettings.php:

Extended action=parse
action=parse accepts extra parameters:
 * mobileformat=: Return rendered page HTML in a mobile format . 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.

示例：

action=mobileview
Delivers content optimized for mobile devices for use by mobile apps and dynamic section views. Almost like a restricted-functionality action=parse</tt>, but more flexible and returns separate sections that are always obtained from full-page parse.

Parameters:
 * page</tt>: Title of page to process.
 * sections</tt>: Pipe-separated list of section numbers for which to return text or all</tt> for all sections.
 * redirect</tt>: Whether redirects should be followed, yes</tt> (default) or no</tt>. This parameter is intentionally made similar to the one to index.php.
 * prop</tt>: Which information to get:
 * text</tt>: HTML of selected section(s)
 * sections</tt>: Information about all sections on page
 * normalizedtitle</tt>: Normalized page title, will be returned only if it differs from the specified one.
 * 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.
 * noheadings</tt>: Return HTML without headings.

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

示例：

Same request for XML:

[//www.mediawiki.org/w/api.php?action=mobileview&page=Extension:MobileFrontend/Example&sections=0&prop=text|sections&format=xmlfm api.php?action=mobileview&page=Extension:MobileFrontend/Example&sections=0&prop=text|sections&format=xml]

prop=extracts
已迁移至

基金会网站
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. 示例：

Varnish server vcl config for X-Device 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.

非基金会网站
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.

对于扩展开发者
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.

参见

 * 维基媒体移动前端配置文件
 * 维基媒体移动前端配置文件
 * 维基媒体移动前端配置文件