Extension:CentralNotice

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
CentralNotice

Release status: stable

Implementation Special page, API
Description Adds a central sitenotice
Author(s) Brion Vibber, Tomasz Finc, Trevor Parscal, Kaldari
License GPL
Download
Parameters
  • $wgNoticeInfrastructure
  • $wgNoticeLang
  • $wgNoticeProject
  • $wgNoticeProjects
  • $wgCentralDBname
  • $wgCentralPagePath
  • $wgCentralNoticeLoader
  • $wgNoticeCookieDomain
  • $wgNoticeCounterSource
Added rights
  • centralnotice-admin
Hooks used
BeforePageDisplay

LoadExtensionSchemaUpdates
MakeGlobalVariablesScript
SiteNoticeAfter
SkinAfterBottomScripts
UnitTestsList
User

Check usage and version matrix

CentralNotice adds the possibility to manage sitenotices from one central wiki. If you only need to post one global message (sitenotice) to a single wiki, you may want to use MediaWiki:Sitenotice instead.

Contents

Installation [edit]

Note: CentralNotice assumes you are not using table prefixes in your database. If you are, it is likely to not work.

  1. Download the latest snapshot and extract it to your extensions directory.
  2. Add
    require_once( "$IP/extensions/CentralNotice/CentralNotice.php" );
    to LocalSettings.php.
  3. From the command line, go to the wiki root and run php maintenance/update.php
  4. The extension should now be active.

Settings [edit]

  • $wgNoticeInfrastructure (default: true) — Set to true on the infrastructure wiki (the wiki you will be managing the campaigns from). Set to false on your target wikis.
  • $wgCentralDBname (default: $wgDBname) — The name of the database for the infrastructure wiki. (This is needed so that the target wikis can retrieve banners from the controller wiki.)
  • $wgCentralPagePathScript path to the wiki serving actual banners. Should be adjusted if secure connection is used.
  • $wgCentralNoticeLoader (default: true) — enable actual hooks.
  • $wgNoticeLang, $wgNoticeProject (default: $wgLanguageCode and "wikipedia") — Determines which banners will be selected for this project.
  • $wgNoticeProjects — The infrastructure wiki uses this as a list of possible $wgNoticeProjects that banners can be assigned to.
  • $wgNoticeCookieDomain — Domain to have cookies set by the Special:HideBanner feature.
  • $wgNoticeHideBannersExpiration - When the cookie set by Special:HideBanner should expire
  • $wgNoticeCounterSource — Full URL to the script that returns amount of money donated to the WMF.

Permissions [edit]

  • centralnotice-admin — Permission required to modify campaigns and banners. Relevant only to the infrastructure wikis (see also bugzilla:26377).

Design [edit]

The CentralNotice system consists of both campaigns (a.k.a. notices) and banners (a.k.a. templates).

  • Banner — a single block of text/css/image that will display at the top of all set wiki pages.
  • Campaign — a collection of banners that are set to show according to a specified weight. You can configure as many campaigns at the same time as you want and each one will show with its configured banners at their own weighted percentages.
  • Preferred — A campaign with preferred set will always replace any other campaigns that happens to have the same language & wiki combo.
  • Locked — A locked notice can not be deleted unless it is unlocked.
  • Enabled — only campaigns that are enabled will show banners.

CentralNotice may work on a single wiki, but Wikimedia has a centralized setup, having the CentralNotice extension installed on all wikis, but the designated wiki instance (currently Meta) is used to provide the management interface. This designated wiki is called the infrastructure wiki and has $wgNoticeInfrastructure set to "true". All sister wikis should have $wgCentralDBname set to the database name of the infrastructure wiki in order to be able to roll out the centrally defined campaigns. Actual banners are served from the central wiki, as defined by $wgCentralPagePath (this is also Meta in case of Wikimedia wikis).

Other technical articles are broken out by category:

Usage [edit]

Full usage instructions can be found at meta:Help:CentralNotice.

New Banner [edit]

  1. Load Special:NoticeTemplate
  2. Click on the add banner link at the bottom of the page (must be logged in as an admin).
  3. Enter in a name and the raw HTML for the given banner.
    1. If this banner is going to be translated then enclose any text to be translated with triple parens - {{{FOO}}}.
  4. Submit

New Campaign [edit]

  • Each banner has its banner definition stored in MediaWiki:Centralnotice-template-<name>
  • All of its messages are stored below the banner def ala MediaWiki:Centralnotice-template-<name>-<message>/<language_code>
  1. Load Special:CentralNotice
  2. Add a campaign with a given start time at the bottom portion of the page and click submit.
    1. If this campaign is only run on a specific wiki and or language then select it from the pull downs.
  3. Click on the new campaign and add the banners you want within this running campaign and their respective weights.
  4. If all looks well then set this campaign to enabled and it will show at the corresponding time.

Testing [edit]

You can test-load any banner on any wiki by adding ?banner=<bannername> to the end of the URL.

You can simulate loading a wiki page from any country (to test campaign geotargeting) by adding ?country=<countrycode> to the end of the URL. (Use the 2-letter ISO 3166-1 code.)

File descriptions [edit]

CentralNotice includes the following files:

API [edit]

CentralNotice adds an API call centralnoticeallocations. This call returns the expected allocation of banners for both anonymous and logged in users in a given country, language, and project group.

It accepts three arguments

  • project - The project to filter on, ie: 'wikipedia' or 'wikibooks'
  • country - The ISO country code to filter on, ie: 'US' or 'RU'
  • language - The ISO language code to filter on, ie: 'en' or 'es'

As of this time, the XML output of this API does not work.

Development [edit]

See also [edit]

CentralNotice CentralNotice/Allocation history
CentralNotice/BannerController Events CentralNotice/Banner mixins CentralNotice/Buckets
CentralNotice/Caching Overhaul -- Edge Side Includes CentralNotice/Database schema
CentralNotice/Phase 2 CentralNotice/Phase 3 CentralNotice/Phase 3/Open questions
CentralNotice/RFC: Allocation system CentralNotice/Slots