Movatterモバイル変換


[0]ホーム

URL:


Jump to content
MediaWiki
Search

Extension:MobileFrontend

From mediawiki.org
Translate this page
Languages:
Support Level: Active Maintenance
This extension is actively maintained by theReader Growth Team with bug fixes and small feature additions.


MediaWiki extensions manual
MobileFrontend
Release status: stable
ImplementationUser interface,Hook
DescriptionProvides a mobile-friendly view
Author(s)
Latest version2.4.1
Compatibility policySnapshots releases along with MediaWiki. Master is not backward compatible.
MediaWiki1.33+[1]
PHP5.5.9+
  • $wgMFStopRedirectCookieHost
  • $wgMFShowMobileViewToTablets
  • $wgMFLazyLoadImages
  • $wgMFNamespacesWithLeadParagraphs
  • $wgMFEnableMobilePreferences
  • $wgMFMobileFormatterOptions
  • $wgMFRemovableClasses
  • $wgMFNoindexPages
  • $wgMFShowFirstParagraphBeforeInfobox
  • $wgMFEnableVEWikitextEditor
  • $wgMFVaryOnUA
  • $wgMFLogWrappedInfoboxes
  • $wgMFDisplayWikibaseDescriptions
  • $wgMFEnableJSConsoleRecruitment
  • $wgMobileFrontendFormatCookieExpiry
  • $wgMFLazyLoadSkipSmallImages
  • $wgMFSearchAPIParams
  • $wgMFMobileHeader
  • $wgMFCustomSiteModules
  • $wgMFEnableXAnalyticsLogging
  • $wgMFAutodetectMobileView
  • $wgMFSiteStylesRenderBlocking
  • $wgMFUseWikibase
  • $wgMFUseDesktopSpecialEditWatchlistPage
  • $wgMFEnableFontChanger
  • $wgMFScriptPath
  • $wgMFAdvancedMobileContributions
  • $wgMFFallbackEditor
  • $wgMFSpecialPageTaglines
  • $wgMFQueryPropModules
  • $wgMFDefaultEditor
  • $wgMFEditNoticesConflictingGadgetName
  • $wgMFStopMobileRedirectCookieSecureValue
  • $wgMFEnableWikidataDescriptions
  • $wgMFManifestBackgroundColor
  • $wgMFManifestThemeColor
  • $wgDefaultMobileSkin
  • $wgMFTrackBlockNotices
  • $wgMFNamespacesWithoutCollapsibleSections
  • $wgMobileUrlCallback
LicenseGNU General Public License 2.0 or later
Download
README
Examplem.mediawiki.org
Translate the MobileFrontend extension if it is available at translatewiki.net
IssuesOpen tasks ·Report a bug

TheMobileFrontend extension helps improve the mobile presence of a MediaWiki instance.

Features include:

  • creates a separate mobile site for your mobile traffic,
  • 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 a beta mode with a feature management system for adding experimental features for anonymous users.

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 toget involved.

Prerequisites

[edit]

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.TheTemplateStyles 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).SeeMobile homepage formatting.

Installation

[edit]
  • Download and move the extractedMobileFrontend folder to yourextensions/ directory.
    Developers and code contributors should install the extensionfrom Git instead, using:
    cdextensions/gitclonehttps://gerrit.wikimedia.org/r/mediawiki/extensions/MobileFrontend
  • Add the following code at the bottom of yourLocalSettings.php file:
    wfLoadExtension('MobileFrontend');
  • If necessary configure at your convenience
  • YesDone – Navigate toSpecial:Version on your wiki to verify that the extension is successfully installed.


Vagrant installation:

  • If usingVagrant, install withvagrant roles enable mobilefrontend --provision

Setup Nearby

[edit]
The Nearby feature in MobileFrontend has been removed in MediaWiki 1.40. Instead, a rewritten version of this feature is available atExtension:NearbyPages.

Set up a skin

[edit]

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 pairs of lines and add them to the bottom of your LocalSettings.php file.

Note that some of these skins might already be getting loaded in LocalSettings.php, in which case those lines do not need to be repeated.

wfLoadSkin('MinervaNeue');$wgDefaultMobileSkin='minerva';// use Minerva skin (You need to download and install it separately in 1.37 and older, otherwise you'll get an exception)
wfLoadSkin('Vector');$wgDefaultMobileSkin='vector';// use Vector skin
wfLoadSkin('Timeless');$wgDefaultMobileSkin='timeless';// use Timeless skin

The following skins are compatible with MobileFrontend:

Configuration settings

[edit]

SeeExtension:MobileFrontend/Configuration

All configuration options are detailed in theREADME.md file.

Additional tweaks

[edit]

Get the most out of MobileFrontend by adding these optional compatible extensions:

Local customisations

[edit]

CSS styling

[edit]
MediaWiki version:
1.40

To apply CSS to your mobile theme, editMediaWiki:Mobile.css, the counterpart ofMediaWiki:Common.css.In order for the stylesheet to function you may have to addmw.loader.using('mobile.site.styles') to yourMediaWiki:Mobile.js.

MobileFrontend does not load the global MediaWiki:Common.css, neither does it load any of the user stylesheets.

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 URL query string:?useformat=mobile. For example:https://en.wikipedia.org/wiki/MediaWiki?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

[edit]

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

[edit]

APIs are provided by the MobileFrontend extension, but long term we expect to deprecate them in favour ofPage Content Service. Use these APIs at your own risk.They may disappear (although we will give you sufficient notice when they do)!

Extended action=parse

[edit]

action=parse accepts extra parameters:

mobileformat=
Return rendered page HTML in a mobile format1.23+.
mainpage
Apply mobile main page transformations.

Example:

api.php?action=parse&page=Therion_(band)&mobileformat=&prop=text [try in ApiSandbox]
Result
{"parse":{"title":"Therion (band)","text":{"*":"<div><tableclass=\"infoboxvcardplainlist\"style=\"width:22em\"><tr><thcolspan=\"2\"style=\"text-align:center;font-size:125%;font-weight:bold;background-color:#b0c4de\"><spanclass=\"fnorg\">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

[edit]

The domain of the mobile version of the site (which might or might not be the same as the normal domain) is available under themobileserver key of the general siteinfo information.

For developers/sysadmins

[edit]

Setup

[edit]

You may need to runnpm 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)

[edit]

SeeExtension:MobileFrontendContentProvider.

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.

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.SeeExtension:MobileFrontend/Configuring browser auto-detection.

Starting from the snapshot version 1.28, the default $wgMFMobileHeader was changed from X-WAP to X-Subdomain. You could either set$wgMFMobileHeader='X-WAP'; or modify your cache (Varnish) header setting, as long as they match.

Using Apache (.htaccess or httpd.conf)

[edit]

To set up a mobile domain, add the following rule to .htaccess or httpd.conf

<IfModulemod_headers.c><If"req('Host') =~ /^mobile./i">RequestHeadersetX-Subdomain"mobile"</If></IfModule>

In yourhosts file (assuming your desktop site is onlocalhost):

127.0.0.1  mobile.localhost

InLocalSettings.php:

wfLoadExtension('MobileFrontend');$wgMFAutodetectMobileView=true;$wgMobileUrlCallback=fn($domain)=>"mobile.$domain";

Now if you navigate to mobile.localhost you should see the mobile site.

FAQ

[edit]

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 detect the mobile site in frontend code?

[edit]

A: Ideally you shouldn't need to do this.It is preferable to usemw.config.get('skin') orwindow.matchMedia('(max-width: 1119px)').matches to detect a mobile user.You can also make use of the stablemw-mf class which is present on the BODY element if the mobile site is active.

If your code makes modifications to content, you may need to update your code to consider MobileFrontend markup by inspecting the DOM for presence of certain elements.

Please note whilemw.config.get( 'wgMFMode' ) exists and can be used by extensions as a last resort (for now) it shouldnot be considered stable for use by gadgets.

Q: How do I customise the main menu of the Minerva skin?

[edit]

A: This istracked in Phabricator but you can seeExtension talk:MobileFrontend/2017#h-MODIFY THE MAIN MENU-2017-01-04T02:24:00.000Z for an interim solution.

Q: How do I add HTML to the Minerva skin, for example to add ads or additional script tags?

[edit]

A: You can do this by editing the template file for the skin (currentlyinclude/skins/minerva.mustache).See thisdiscussion for details.

Q: The extension I am using doesn't seem to work on MobileFrontend. Why?

[edit]

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 toResourceLoader/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 onPhabricator (you can login using your MediaWiki.org username) for a quicker response.

Q: I upgraded MobileFrontend and now I'm getting a fatal exception!

[edit]

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.

[edit]

A: MobileFrontend currently assumes you have theMinerva Neue skin installed.If you don't you'll need to install this or configure your mobile skinper instructions above.

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 viewthis guide on writing MobileFrontend friendly modules will be of help.

See also

[edit]

References

[edit]
  1. :Fatal error: Uncaught ExtensionDependencyError: MobileFrontend is not compatible with the current MediaWiki core (version 1.32.2), it requires: >=1.33.0.
This extension is being used on one or moreWikimedia 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'sCommonSettings.php andInitialiseSettings.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'sSpecial:Version page.
This extension is included in the following wiki farms/hosts and/or packages:
Retrieved from "https://www.mediawiki.org/w/index.php?title=Extension:MobileFrontend&oldid=8218105"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp