Jump to content

Extension:MobileFrontend

From DawoumWiki, the free Mathematics self-learning

MobileFrontend 확장은 미디어위키 인스턴스의 모바일 존재감을 개선하는 데 도움이 됩니다.

특징은 다음과 같습니다:

  • 모바일 트래픽에 대해 분리된 모바일 사이트를 만듭니다.
    • 시스템 관리자는 다른 스킨, 예를 들어 mw:Skin:MinervaNeue을 제공할 수 있습니다.
  • 다양한 컨텐츠 변환 기능을 제공하여 당신의 컨텐츠를 보다 친숙하게 만듭니다.
    • 특히 섹션 접기 그리고 컨텐츠 재배치 그리고 제거.
    • 모바일 바닥글을 단순화하고 데스크탑/모바일 사이트 링크를 추가합니다.
  • 모바일 친화적이지 않은 미디어위키 페이지에 대해 대체 특수 페이지를 제공합니다 – Special:History, Special:Contributions, Special:Watchlist, Special:Preferences, Special:MobileDiff.
  • 그것은 다음 특수 페이지를 제공합니다: Special:Nearby, (모바일 스킨 설정에 대해) Special:MobileOptions, (언어 선택에 대해) Special:MobileLanguages, (모바일 스틴에서 non-JS 메뉴에 대해) Special:MobileMenu 그리고 (모바일 친화적 이미지 업로드 보기에 대해) Special:Uploads.

이 기사는 그들 개발 예제에 그것을 설치하기 원하는 최종 사용자에 대해 설계되었습니다. 만약 여러분이 그것을 구축하고 그것을 개선하기 위해 우리를 돕고 싶다면 우리는 당신의 참여를 권장합니다.

Prerequisites

모바일프론트엔드를 설치하기 전에, 만약 템플릿 및/또는 인라인 스타일 (스타일 속성)을 많이 사용한다면, 그것이 모바일 친화적인지 여부를 보기 위해 컨텐츠를 검토해야 합니다. TemplateStyles 확장은 모바일과 데스크탑에서 멋지게 렌더링하도록 컨텐츠에 스타일을 맞추도록 사용될 수 있습니다. 모바일프론트엔드는 마술처럼 이것을 고쳐주지는 않을 것입니다!

특히, 방문 페이지 (메인 페이지)를 검토하기를 원할 수 있습니다. 모바일 홈페이지 형식화를 참조하십시오.

Installation

미디어위키 확장 내려받기 지면에서 해당하는 버전을 다운로드하고 위키의 extensions 디렉토리에 MobileFrontend에 푸십시오.

또는 개발자와 코드 기여자는 대신 다음을 사용하여 Git에서 확장 프로그램을 설치해야 합니다.

cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/MobileFrontend

미디어위키 설정 LocalSettings.php에 다음을 추가하십시오:

wfLoadExtension( 'MobileFrontend' );

필요하다면, 설정하십시오.

Special:Version에 접근해서 확장이 정상적으로 설치가 되었는지 확인하십시오.

Vagrant installation

만약 Vagrant를 사용하면, 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 .

모바일프론트엔드는 약간의 구성과 함께 Special:Nearby 지면을 제공합니다. 이 기능을 사용하기 위해서, 몇 가지 선택적 단계가 요구됩니다:

  1. 브라우저 보안으로 인해 SSL을 통해 보안 사이트를 실행할 필요가 있습니다 – 상대적으로 보안성이 약한 http를 통해 사용자의 위치를 요청할 수 없습니다.
  2. GeoData extension을 설치하십시오.
  3. update.php 를 실행하십시오.
  4. LocalSettings.php 파일에 $wgMFNearby = true; 설정을 추가하십시오.
  5. 기사 좌표를 결정합니다:
    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.

Setup a skin

모바일프론트엔드는 기존의 데스크탑 웹 사이트와 나란히 가기 위해 모바일 형식의 웹 사이트를 제공합니다. 원하는 스킨을 적용할 수 있습니다.

// 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:

Configuration settings

See Extension:MobileFrontend/Configuration

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

Additional tweaks

이러한 다른 선택적인 종속성을 더함으로써 모바일프론트엔드를 최대한 활용하십시요:

Local customisations

CSS styling

MediaWiki version:
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.

More information

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

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)!

MobileView API

See Extension:MobileFrontend/MobileViewAPI .

Extended action=parse

action=parse accepts extra parameters:

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

Example:

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

For developers/sysadmins

Setup

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)

See Extension:MobileFrontendContentProvider .

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

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

For Extension Developers

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.

See also

References