Extensão:MobileFrontend

This page is a translated version of the page Extension:MobileFrontend and the translation is 22% complete.
Outdated translations are marked like this.
Manual de extensões do MediaWiki
MobileFrontend
Estado de lançamento: estável
Implementação Interface do utilizador, Hook
Descrição Provides a mobile-friendly view
Autor(es)
Última versão 2.4.1
Política de compatibilidade Lançamentos de capturas de ecrã junto com o MediaWiki. Original não é compatível com versões anteriores.
MediaWiki 1.33+[1]
PHP 5.5.9+
Licença GNU - Licença Pública Geral 2.0 ou superior
Transferência
README
Exemplo m.mediawiki.org
  • $wgMFSearchGenerator
  • $wgMFStopRedirectCookieHost
  • $wgMFShowMobileViewToTablets
  • $wgMFLazyLoadImages
  • $wgMFRSSFeedLink
  • $wgMFNamespacesWithLeadParagraphs
  • $wgMFAmcOutreachMinEditCount
  • $wgMFEnableMobilePreferences
  • $wgMFMobileFormatterOptions
  • $wgMFRemovableClasses
  • $wgMFNoindexPages
  • $wgMFShowFirstParagraphBeforeInfobox
  • $wgMFEnableVEWikitextEditor
  • $wgMFVaryOnUA
  • $wgMFLogWrappedInfoboxes
  • $wgMFDisplayWikibaseDescriptions
  • $wgMFEnableJSConsoleRecruitment
  • $wgMobileFrontendFormatCookieExpiry
  • $wgMFLazyLoadSkipSmallImages
  • $wgMFSearchAPIParams
  • $wgMFMobileHeader
  • $wgMFCustomSiteModules
  • $wgMFEnableXAnalyticsLogging
  • $wgMFAutodetectMobileView
  • $wgMFSiteStylesRenderBlocking
  • $wgDefaultMobileSkin
  • $wgMFUseDesktopSpecialEditWatchlistPage
  • $wgMFCollapseSectionsByDefault
  • $wgMFEnableFontChanger
  • $wgMFScriptPath
  • $wgMFEditNoticesConflictingGadgetName
  • $wgMFStopMobileRedirectCookieSecureValue
  • $wgMFAdvancedMobileContributions
  • $wgMFFallbackEditor
  • $wgMFEnableBeta
  • $wgMFSpecialPageTaglines
  • $wgMFQueryPropModules
  • $wgMFAmcOutreach
  • $wgMFBetaFeedbackLink
  • $wgMFDefaultEditor
  • $wgMFManifestBackgroundColor
  • $wgMFManifestThemeColor
  • $wgMFEnableManifest
  • $wgMFEnableWikidataDescriptions
  • $wgMFUseWikibase
  • $wgMFNamespacesWithoutCollapsibleSections
  • $wgMFTrackBlockNotices
  • $wgMobileUrlCallback
  • $wgMFMinCachedPageSize
Quarterly downloads 798 (Ranked 3rd)
Public wikis using 9,025 (Ranked 14th)
Traduza a extensão MobileFrontend se ela estiver disponível em translatewiki.net
Problemas Tarefas em aberto · Reportar um erro

A extensão MobileFrontend:

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 to get involved.

Pré-requisitos

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). Consulte a formatação da página inicial para dispositivo móvel.

Instalação

  • Exporte e coloque o ficheiro, ou ficheiros, num diretório chamado MobileFrontend, na sua pasta extensions/.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/MobileFrontend
  • Acrescente o seguinte código ao fundo do ficheiro $LocalSettings:
    wfLoadExtension( 'MobileFrontend' );
    
  • [[#Configuration settings|* Se necessário configure à sua vontade]]
  •   Pronto – Na página especial Special:Version da sua wiki verifique se a extensão foi instalada.


Vagrant installation:

  • Se estiver a utilizar Vagrant , instale com vagrant roles enable mobilefrontend --provision

Setup Nearby

The Nearby feature in MobileFrontend has been removed in MediaWiki 1.40. Instead, a rewritten version of this feature is available at Extension:NearbyPages .

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.
  1. Install the GeoData extension
  1. Run update.php
  2. In LocalSettings.php add $wgMFNearby = true;
  3. Determine article coordinates:
    1. 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 .
    2. 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.

Configurar um tema

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 chosen code to bottom of LocalSettings.php file:
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:

  • Skin:Vector (default desktop skin, uses an experimental responsive mode for mobile)

Definições de configuração

Consulte Extension:MobileFrontend/Configuration

All configuration options are detailed in the README.md file.

Ajustes adicionais

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

Personalizações locais

Estilo de CSS

Versão MediaWiki:
1.40

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.

Mais informação

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.

Funcionalidades legadas de 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 Page Content Service. Use these APIs at your own risk. They may disappear (although we will give you sufficient notice when they do)!

API de MobileView

action=parse estendida

action=parse accepts extra parameters:

mobileformat=
Return rendered page HTML in a mobile format 1.23+.
mainpage
Apply mobile main page transformations.

Exemplo:

Resultado
{
    "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.

Para programadores/administradores de sistema

Configuração

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)

Utilizar a visualização de dispositivo móvel

Sites da WMF

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

Sites externos da WMF

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. See Extension: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)

To set up a mobile domain, add the following rule to .htaccess or http.config

<IfModule mod_headers.c>
<If "req('Host') =~ /^mobile./i">
RequestHeader set X-Subdomain "mobile"
</If>
</IfModule>

In your hosts file (assuming your desktop site is on localhost):

127.0.0.1  mobile.localhost

In LocalSettings.php:

wfLoadExtension('MobileFrontend');

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

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

Perguntas Mais Frequentes

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 (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 Minerva Neue skin installed. If you don't you'll need to install this or configure your mobile skin per instructions above.

Para Programadores de Extensão

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.

Consulte também

Referências

  1. :Fatal error: Uncaught ExtensionDependencyError: MobileFrontend is not compatible with the current MediaWiki core (version 1.32.2), it requires: >= 1.33.0.