Extension:ZeroBanner

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
ZeroBanner

Release status:Extension status beta

Wikipedia Zero Logo.svg
ImplementationTemplate:Extension#type MyWiki, Special page, ContentHandler, Skin
DescriptionTemplate:Extension#description Provides features for mobile providers that provide free access to Wikipedia
Author(s)Template:Extension#username Yuri Astrakhan (yuriktalk)
Latest versionTemplate:Extension#version 1.1.0 (2016-12-07; 7 months ago (2016-12-07))
MediaWikiTemplate:Extension#mediawiki 1.28+
PHPTemplate:Extension#php 5.5.9+
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license GNU General Public License 2.0 or later
Download
README
Deployments
ParametersTemplate:Extension#parameters
  • $wgJsonConfigs
  • $wgZeroSiteOverride
  • $wgZeroBannerClusterDomain
  • $wgZeroBannerImageFontSize
  • $wgZeroBannerImageWidth
  • $wgZeroBannerImageHeight
  • $wgZeroBannerErrImageWidth
  • $wgZeroBannerErrImageHeight
  • $wgZeroBannerFont
Hooks usedTemplate:Extension#hook
BeforePageDisplayMobile
GetMobileUrl
MinervaPreRender
MobileFrontendBeforeDOM
MakeGlobalVariablesScriptManual:Hooks/MakeGlobalVariablesScript
SpecialMobileEditWatchlist::images
ResourceLoaderTestModulesManual:Hooks/ResourceLoaderTestModules

Translate the ZeroBanner extension if it is available at translatewiki.net

Check usage and version matrix.

IssuesPhabricator

Open tasks · Report a bug

The ZeroBanner extension provides banner, hyperlink, and image treatment for webpages for the Wikipedia Zero program. This extension is a refactoring of ZRMA extension

Installation[edit]

Manual installation

  • Download and place the file(s) in a directory called ZeroBanner in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/ZeroBanner/ZeroBanner.php";
    
    Configure at your convenience
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration[edit]

$wgJsonConfigs['JsonZeroConfig'] = array(
   'namespace' => NS_ZERO,
   'nsname' => 'Zero',
   'islocal' => false,
   'url' => 'https://zero.wikimedia.org/w/api.php',
   'username' => $wmgZeroRatedMobileAccessApiUserName,
   'password' => $wmgZeroRatedMobileAccessApiPassword,
);

See the README for more information on configuration and settings pertaining to carrier mockup.

For local (test) wikis, try just the following:

$wgJsonConfigs['JsonZeroConfig'] = array(
    'namespace' => NS_ZERO,
    'nsName' => 'Zero',
    'remote' => array(
        'url' => 'http://localhost:8888/w/api.php'
    ),
    'cacheKey' => '1',
);
$wgZeroSiteOverride = array( 'wikipedia', 'en' );

Setting up local wiki[edit]

  • Install a browser extension for modifying request headers such as ModHeader for Chrome
  • Navigate to Zero:TEST on your wiki and create the page. Some default configuration is provided, but the JSON below may prove more useful:
{
    "comment": "[Zero] TEST",
    "enabled": true,
    "name": {
        "en": "Test Operator"
    },
    "banner": {
        "en": "{{SITENAME}} zero-rating test on $1"
    },
    "partnerInfoText": {
        "en": "Check your quota"
    },
    "partnerInfoUrl": "https://www.google.com",
    "showLangs": [
        "en",
        "he",
        "ru",
        "fr",
        "pl"
    ],
    "shrinkImg": true,
    "configs": [
        {
            "whitelistedLangs": [],
            "enableHttps": true,
            "bannerWarning": true
        }
    ],
    "ipsets": {
        "default": []
    },
    "status": {
        "technical": "edit"
    },
    "country": "US"
}
  • Add 3 new request headers in your extension:
    • X-CS: TEST
    • User-Agent: android-mobile
    • X-Subdomain: M
  • Optionally add a filter to only apply these headers to your local environment
  • Navigate to Main Page (or any article) on your local wiki. You should now see a banner rendered at the top of the article.

See also[edit]