Расширение:MobileFrontend
Расширение MobileFrontend:
- Creates a separate mobile site for your mobile traffic,
- System administrators are able to provide a different skin, e.g. Skin:Minerva Neue.
- provides various content transformations to make your content more friendly,
- Notably section collapsing and content re-arrangement and removal, including putting the lead paragraph above the lead photo or info box, even if the lead paragraph is below them in the page's source code.
- simplifies mobile footer and adds a desktop/mobile site link,
- provides replacements for special pages that are not mobile friendly:
Special:History, Special:Contributions, Special:Watchlist, Special:Preferences, Special:MobileDiff
- provides the special pages Special:Nearby, Special:MobileOptions (for mobile skin preferences), Special:MobileLanguages (for language selection),
- provides a beta mode with a feature management system for adding experimental features for anonymous users.
MobileFrontend Статус релиза: стабильный |
|
---|---|
![]() |
|
Реализация | Пользовательский интерфейс, Hook |
Описание | Provides a mobile-friendly view |
Автор(ы) | |
Последняя версия | 2.3.0 |
Политика совместимости | ветвь релиза |
MediaWiki | 1.33+[1] |
PHP | 5.5.9+ |
Лицензия | GNU General Public License 2.0 or later |
Загрузка | README |
Пример | m.mediawiki.org |
|
|
|
|
Переведите расширение MobileFrontend если оно доступно на translatewiki.net | |
Проблемы | Открытые задачи · Сообщить об ошибке |
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.
![]() | Это расширение поддерживается командой Reading Web. |
Необходимые компоненты
- Хотя сама MediaWiki не требует этого, понадобится поддержка mbstring в PHP чтобы это расширение заработало (смотрите задача T62174).
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.
Установка
- Если вы используете Vagrant , установите с помощью
vagrant roles enable mobilefrontend --provision
- Ручная установка
- Скачайте и распакуйте файл(ы) в папку с названием
MobileFrontend
в вашей папкеextensions/
. - Добавьте следующие строки в конец файла LocalSettings.php:
wfLoadExtension( 'MobileFrontend' );
- При необходимости настройте
Готово – Перейдите на страницу Special:Version на своей вики, чтобы удостовериться в том, что расширение успешно установлено.
Setup Nearby
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 location data to your articles by using the
coordinates
parser function, for example{{#coordinates:37.786971|-122.399677|primary}}
. For syntax details, see the documentation for GeoData . - 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 location data to your articles by using the
Установка темы оформления
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 these and add chosen code to bottom of LocalSettings.php file:
wfLoadSkin( 'MinervaNeue' );
$wgMFDefaultSkinClass = 'SkinMinerva'; // use Minerva skin (You need to download and install it separately, otherwise you'll get an exception)
wfLoadSkin( 'Vector' );
$wgMFDefaultSkinClass = 'SkinVector'; // use Vector skin
wfLoadSkin( 'Timeless' );
$wgMFDefaultSkinClass = 'SkinTimeless'; // use Timeless skin
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 optional compatible extensions:
- 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
CSS styling
To apply CSS to your mobile theme, edit MediaWiki:Mobile.css, the counterpart of MediaWiki:Common.css.
In order for the stylesheet to function you may have to add mw.loader.using('mobile.site.styles')
to your MediaWiki:Mobile.js.
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 URL query string: ?useformat=mobile
. For example: https://en.wikipedia.org/wiki/Chuck_Schuldiner?useformat=mobile
If you would like to view the mobile version of a page without enabling the extension across the entire site you can append the string to the URL on that page, too.
Legacy features of MobileFrontend
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)!
MobileView API
Extended action=parse
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.
Пример:
Результат |
---|
{
"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\">
...
|
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 mobileserver
key of the general siteinfo information.
Для разработчиков/администраторов
Установка
You may need to run npm install
and install php composer to get the precommit hook to run, depending on what you're doing with the extension.
Testing with articles on a foreign wiki (live data)
MobileFrontend can now be configured locally to render articles from other MediaWiki instances.[2] 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
WMF sites
On Wikimedia Foundation-run sites, we use Varnish caching servers to check the user agent of your device.
Non-WMF sites
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 they match.ЧаВо
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.
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 (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.
Для разработчиков расширений
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.
Смотрите также
- Mobile web browsers supported by MobileFrontend
- Extension:TextExtracts
- Wikimedia's MobileFrontend configuration file
- Commons:Category:MediaWiki extension MobileFrontend
Примечания
- ↑ :Fatal error: Uncaught ExtensionDependencyError: MobileFrontend is not compatible with the current MediaWiki core (version 1.32.2), it requires: >= 1.33.0.
- ↑ See this YouTube demo video
![]() | Это расширение используется в одном или нескольких проектах Викимедиа. Вероятно, это означает, что расширение стабильно и работает достаточно хорошо, чтобы использоваться такими сайтами с высоким трафиком. Найдите название этого расширения в файлах конфигурации Викимедиа CommonSettings.php и InitialiseSettings.php, чтобы узнать, где оно установлено. Полный список расширений, установленных на конкретной вики, можно увидеть на странице Special:Version wiki. |
- Stable extensions/ru
- User interface extensions/ru
- Hook extensions/ru
- GPL licensed extensions/ru
- Extensions in Wikimedia version control/ru
- APIAfterExecute extensions/ru
- APIGetAllowedParams extensions/ru
- APIQuerySiteInfoGeneralInfo extensions/ru
- AbuseFilter-builder extensions/ru
- AbuseFilter-generateUserVars extensions/ru
- AfterBuildFeedLinks extensions/ru
- AuthChangeFormFields extensions/ru
- BeforeInitialize extensions/ru
- BeforePageDisplay extensions/ru
- BeforePageRedirect extensions/ru
- CentralAuthLoginRedirectData extensions/ru
- CentralAuthSilentLoginRedirect extensions/ru
- ChangeTagsListActive extensions/ru
- DifferenceEngineViewHeader extensions/ru
- Gadgets::allowLegacy extensions/ru
- GetCacheVaryCookies extensions/ru
- GetPreferences extensions/ru
- HTMLFileCache::useFileCache extensions/ru
- ListDefinedTags extensions/ru
- LoginFormValidErrorMessages extensions/ru
- MakeGlobalVariablesScript extensions/ru
- ManualLogEntryBeforePublish extensions/ru
- MediaWikiPerformAction extensions/ru
- OutputPageBeforeHTML extensions/ru
- OutputPageParserOutput extensions/ru
- PageRenderingHash extensions/ru
- RecentChange save extensions/ru
- RequestContextCreateSkin extensions/ru
- ResourceLoaderRegisterModules extensions/ru
- ResourceLoaderSiteModulePages extensions/ru
- ResourceLoaderSiteStylesModulePages extensions/ru
- SkinAddFooterLinks extensions/ru
- SkinAfterBottomScripts extensions/ru
- SpecialPageBeforeExecute extensions/ru
- SpecialPage initList extensions/ru
- ThumbnailBeforeProduceHTML extensions/ru
- TitleSquidURLs extensions/ru
- UserGetDefaultOptions extensions/ru
- UserLoginComplete extensions/ru
- All extensions/ru
- Extensions used on Wikimedia/ru
- MobileFrontend/ru