Extension:MobileFrontend/zh

移动前端（MobileFrontend）扩展：


 * 为您的wiki创建移动网站.
 * 为它们的移动流量拆分移动网站.
 * 系统管理员可提供不同的皮肤，例如Skin:MinervaNeue
 * 提供多种内容转换以使您的内容更加友好
 * 尤其是章节启闭、内容重排列与移除.
 * 为不适合移动端直接访问的MediaWiki页面提供替换特殊页面）——Special:History、Special:Contributions、Special:Watchlist、Special:Preferences、Special:MobileDiff.
 * 提供特殊页面Special:Nearby、Special:MobileLanguages、Special:MobileMenu和Special:Uploads

本页是为了想要在开发端安装此扩展的用户撰写的. 如果你乐于帮助我们改进，我们欢迎您参与改进.

先决条件

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

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


 * 1) 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
 * 2) Install the GeoData extension
 * 3) Run
 * 4) In LocalSettings.php add
 * 5) Determine article coordinates:
 * 6) Add data to your articles to one or more pages   see the documentation for GeoData for syntax details.
 * 7) Alternatively you can use a separate MediaWiki installation for Nearby by setting   in your LocalSettings.php file. For example,   will use coordinates of English Wikipedia articles. The nearby endpoint will be used to find content related to a given location.

Setup a skin
MobileFrontend provides you with a mobile formatted website to go alongside your existing desktop website. You can skin it however you want. The following skins are compatible with MobileFrontend:
 * Skin:Minerva Neue (stable, default on WMF wikis)
 * Skin:Vector (default desktop skin, uses an experimental responsive mode for mobile)
 * Skin:Timeless (experimental skin)

配置设置
参阅：Extension:MobileFrontend/Configuration

额外调整
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. MobileFrontend does not load the global Mediawiki:Common.css, neither does it load any of the user stylesheets.

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

移动前端的过时功能
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
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)!

扩充action=parse
accepts extra parameters:
 * : Return rendered page HTML in a mobile format . Prior to MediaWiki 1.23, you could specify  to output HTML for modern phones or   to output WML for dumb phones (see mailing list messagefor details).
 * : Disable images in mobile output.
 * : 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, but more flexible and returns separate sections that are always obtained from full-page parse.

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

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

示例：

用于XML的同一请求：

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

prop=extracts
已迁移至

meta=siteinfo
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  key of the general siteinfo information.

Testing with articles on a foreign wiki (live data)
MobileFrontend can now be configured locally to render articles from other MediaWiki instances. 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: This is particularly useful for testing different mobile skins using the wgMFDefaultSkinClass config option.

基金会网站
On Wikimedia Foundation-run sites, we use Varnish caching servers to check the user agent of your device.

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

FAQ
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.

Q: How do I customise the main menu of the Minerva skin?
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?'
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?
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!
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.
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.

对于扩展开发者
默认情况下，扩展中的资源模块将不会在移动视图中加载. 如果一个模块需要在移动版页面中载入，这份关于撰写对移动前端友好的模块的指南很有帮助.

参见

 * 维基媒体移动前端配置文件
 * Commons:Category:MediaWiki extension MobileFrontend
 * 维基媒体移动前端配置文件
 * Commons:Category:MediaWiki extension MobileFrontend