Extension:中央公告
发行状态: 稳定版 |
|
|---|---|
| 实现 | 特殊页面, API |
| 描述 | Adds a central sitenotice |
| 作者 | Andrew Russell Green, Matthew Walker, Adam Roses Wight Formerly: Brooke Vibber, Tomasz Finc, Trevor Parscal, Ryan Kaldari |
| 最新版本 | 2.6.1 (continuous updates) |
| 兼容性政策 | 快照跟随MediaWiki发布。 master分支不向后兼容。 |
| 数据库更改 | 是 |
| 虚拟域 | virtual-centralnotice |
|
|
| 许可证 | GNU General Public License 2.0 or later |
| 下載 | |
| 示例 | Special:CentralNotice on Meta (read-only) |
| 前往translatewiki.net翻譯CentralNotice扩展 | |
| 問題 | 开启的任务 · 报告错误 |
CentralNotice扩展会向维基媒体的wiki傳送公告(通常是以横幅的形式)。 Fundraising團隊大量使用它來募集捐款,以及做為維基媒體社群和使用者感興趣的公告。 CentralNotice可根據國家、語言、專案、裝置、和登入狀態來訂定公告。
本頁提供給希望在自己的網站上安裝CentralNotice的CentralNotice開發者以及維基管理員的相關資訊。 如需瞭解如何建立及設定CentralNotice的各種活動,請參閱 Help:CentralNotice on Meta-Wiki。 有關維基媒體基金會叢集上CentralNotice架設的資訊,請參閱 CentralNotice 至 Wikitech。
CentralNotice 可以從一個中央維基(稱為「基礎設施」的維基)向多個維基(稱為「訂閱」的維基)集中發佈公告。 若您只需在單一維基上發佈訊息, 建議改用 Sitenotice。
安裝
- Install Extension:EventLogging first
- 下载文件,并解压
CentralNotice文件夹到extensions/目录中。
开发者和代码贡献人员应改从Git安装此扩展,输入:cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/CentralNotice
- 請新增下列代码到您的LocalSettings.php文件的底部:
wfLoadExtension( 'CentralNotice' );
- 請运行更新脚本,它将自动创建此扩展所必须的数据库表。
- 預設情況下,GeoIP 查詢功能已停用。 然而,如果
Geo這個變數已被預先賦值,則會使用其值。 在本地開發時,您可以啟用以下這種使用 https://freegeoip.net 的客戶端實作方式。 更多資訊,請參閱#GeoIP查詢。$wgCentralNoticeGeoIPBackgroundLookupModule = 'ext.centralNotice.freegeoipLookup';
完成 – 請导航至您的wiki上的Special:Version,以验证此扩展已成功安装。
基礎設施的維基
對於大多數開發任務,您可以讓單一維基擔任既是基礎設施、同時也是訂閱的角色。
sysop群組的成員有權管理CentralNotice的活動和橫幅廣告。
如果需要新增額外的群組,請為它們指定 centralnotice-admin 和 editinterface 權限。
某些CentralNotice功能需要其他MediaWiki的擴充功能,其包括有$1和Translate(翻译)。
僅限訂閱用戶存取的維基
编辑LocalSettings.php然後设定...
$wgNoticeInfrastructure為false;$wgCentralSelectedBannerDispatcher為連結至中央維基上的Special:BannerLoader,例如:https://meta.wikimedia.org/w/index.php/Special:BannerLoader;$wgCentralDBname為基礎設施維基的資料庫名稱,或將$wgCentralNoticeApiUrl設為基礎設施維基的API端點,二擇一;然後$wgCentralBannerRecorder為中央維基上Special:RecordImpression的網址。 例如https://meta.wikimedia.org/w/index.php/Special:RecordImpression;
所有在訂閱維基上執行的程式碼都應使用MobileFrontend(移动版前端)進行初步測試,以確保其在網站的行動版上能正常運作。
尋求協助
維基媒體基金會的Fundraising tech團隊是CentralNotice的維護者。 若對CentralNotice的安裝、錯誤回報、或使用方式有任何疑問,請寄送電子郵件至郵件列表wikitech-l@lists.wikimedia.org,或加入我們IRC的#wikimedia-fundraising 在线頻道。
权限
centralnotice-admin— 修改活動和橫幅需取得授權。 僅適用於基礎設施維基(另請參閱 bugzilla:26377)。editinterface- 編輯橫幅的內容時需要。
設計概念
從使用者端的角度來看,CentralNotice 物件的高階類別為 campaigns(亦稱通知)和 banners(亦稱模板)。 這些受到 selectors 和 allocation 的後端概念所影響。
- Banner——是一組可翻譯的html/wikitext/css/javascript區塊,將顯示於手册:$wgContentNamespaces頁面的頂端。 使用者狀態、裝置類型、及UI語言selectors會套用至橫幅。
- 橫幅可每 category 為一組。 同一類別中的所有橫幅會共用使用者端的Cookie,例如當使用者點擊橫幅的關閉按鈕時所設定的隱藏Cookie。
- Campaign——是橫幅的一個集合體。 專案、國家、及內容語言的篩選器會套用到活動的層級上。 本系統允許您同時進行任意數量的活躍活動,並會針對每個活躍活動中的橫幅動態計算一個allocation(分配)。 若中央維基的時間大於活動開始時間、小於活動結束時間,且該活動已標記為啟用狀態,則該活動被定義為「活躍」。
- 活動中的橫幅分別被指定一個bucket(篩選器)和一個weight(weight)。 桶是另一種篩選器,而權重則會影響活動內橫幅的相對分配。
- CentralNotice 共有四個「優先級」層級。 優先級較高的活動將獲得更多的頁面瀏覽量分配。
- 活動可能會被「鎖定」,這將阻止對該活動進行編輯和刪除;但活動內的橫幅廣告則不受此限制。
- Selector——任何可用於分配目的的篩選屬性。 這使得系統能夠,例如,向在阿根廷瀏覽英文維基百科的已登入與未登入使用者顯示不同的橫幅廣告。
- 所謂的「選取向量」,是指使用者在向中央維基請求橫幅時所提交的完整篩選器的集合。
- Allocation — 在給定選擇向量下,向使用者顯示橫幅的機率。
设计文档
GeoIP查詢
預設情況下,CentralNotice未配置任何客戶端側的GeoIP查詢服務。
此設定已針對維基媒體基金會的生產環境進行優化,在該環境中,Varnish 會從伺服器端填入 Geo cookie。
(請參見 wikitech:Geolocation。)
您可以透過 CentralNoticeGeoIPBackgroundLookupModule 配置變數,在客戶端將 CentralNotice 設定為使用自訂資料來源。
此變數預期接收一個匯出函式的資源載入器模組名稱。
該函式將在不傳入參數的情況下被呼叫,並應返回一個 Promise,該 Promise 解析後會產生一個包含以下屬性的物件:
- 國家:字串--兩位字母的國家代碼。
- 區域:字串--依實作而定。
- city:字符串--城市名称。
- 纬度:数字。
- 经度:数字。
用法
完整的使用说明位于meta:Help:CentralNotice。
新横幅
- 加载Special:CentralNoticeBanners
- 請點擊頁面底部的「新增橫幅」連結(必須以管理員身分登入)。
- 請輸入名稱以及該橫幅的原始 HTML 程式碼。
- 若要翻譯此橫幅,請將待翻譯的文字用三組小括號包起來 - {{{FOO}}}。
- 提交
(待辦事項:移動並擴充此片段)
- 每個橫幅的定義皆儲存於 MediaWiki:Centralnotice-template-<name> 中
- 所有訊息皆儲存於 MediaWiki:Centralnotice-template-<name>-<message>/<language_code> 中定義的橫幅下方
新活動
- Load Special:CentralNotice
- Add a campaign with a given start time at the bottom portion of the page, leave a comment, and click submit.
- If this campaign is only run on a specific wiki and or language then select it from the pull downs.
- Click on the new campaign and add the banners you want within this running campaign and their respective weights.
- If all looks well then set this campaign to enabled and it will show at the corresponding time.
覆蓋選擇
Add any of the following URL parameters to preview a specific banner, defeat "diet" schemes, or debug pseudorandom banner selection.
- banner
- You can test a banner directly on any wiki by adding
?banner=<bannername>to the end of the URL.
- randomcampaign
- A decimal number between 0 and 1, to be used as the "random" seed for choosing a campaign.
- randombanner
- A decimal number between 0 and 1, to be used as the "random" seed for choosing a banner among banners available in the chosen campaign.
- country
- Override the country code, before filtering to geotargeted campaigns. Accepts two-character ISO 3166-1 codes.
- uselang
- Its usual meaning in MediaWiki, this determines which banners you may be shown. Beware of content language vs. user language.
- force
- Override any banner hiding code, show the banner.
- reset
- Zero out any cookies being used to customize banner display (e.g. delivered impression count).
例如,
調試有問題的橫幅廣告
If there is a problematic banner in the page, you can identify which banner is active by opening your developer console and inspecting the value of: mw.centralNotice.bannerData.bannerName.
限制
Banners do not display on pages in the Special namespace, as well as edit pages and diff pages.
API
CentralNotice adds two API modules, centralnoticechoicedata and centralnoticequerycampaign.
(The API module centralnoticeallocations was deprecated and removed in MediaWiki 1.25.)
action=centralnoticechoicedata
- This module requires read rights.
- Source: CentralNotice
- License: GPL-2.0-or-later
Get data needed to choose a banner for a given project and language
- project
The project to get banner choice data for.
- This parameter is required.
- language
The language to get banner choice data for.
- This parameter is required.
- Get the data for choosing a banner for English Wikipedia users.
- api.php?action=centralnoticechoicedata&project=wikipedia&language=en [open in sandbox]
action=centralnoticequerycampaign
- This module requires read rights.
- Source: CentralNotice
- License: GPL-2.0-or-later
Get all configuration settings for a campaign.
- campaign
Campaign name. Separate multiple values with a "|" (vertical bar).
- This parameter is required.
- Show campaign "Plea_US"
- api.php?action=centralnoticequerycampaign&format=json&campaign=Plea_US [open in sandbox]
参阅
- Help:CentralNotice 與 重構後的變更 (2015-09) 在元維基上
- Extension:CentralNotice/Campaign and banner selection
- Extension:CentralNotice/Impression diet
- Extension:CentralNotice/Special:RecordImpression
- Extension:CentralNotice/Statuses, reasons and status codes
- Extension:CentralNotice/Banner_mixins
- Requests for comment/CentralNotice Caching Overhaul - Frontend Proxy
- Extension:CentralNotice/Notes/Miscelaneous doc bits
- Extension:CentralNotice/Notes/Documentation rewrite
- Extension:CentralNotice/Notes/Campaign-associated_mixins_and_banner_history
- Extension:CentralNotice/Notes/Banner controller refactoring
- 此页面的其他子页面 (警告:许多皆已过时)
| 此扩展用于一个或多个维基媒体项目。 这可能意味着扩展足够稳定、运作足够良好,可以用在这样的高流量的网站上。 请在维基媒体的CommonSettings.php和InitialiseSettings.php配置文件中查找此扩展的名称以查看哪些网站安装了该扩展。 特定wiki上的已安装的扩展的完整列表位于Special:Version页面。 |
| 此扩展在以下wiki农场/托管网站和/或软件包中提供: |
- Stable extensions/zh
- Special page extensions/zh
- API extensions/zh
- CanonicalNamespaces extensions/zh
- ChangeTagsListActive extensions/zh
- GetPreferences extensions/zh
- ListDefinedTags extensions/zh
- LoadExtensionSchemaUpdates extensions/zh
- PreferencesGetIcon extensions/zh
- ResourceLoaderRegisterModules extensions/zh
- SkinTemplateNavigation::Universal extensions/zh
- UserMergeAccountFields extensions/zh
- GPL licensed extensions/zh
- Extensions in Wikimedia version control/zh
- All extensions/zh
- Pages using deprecated NoteTA template
- Extensions used on Wikimedia/zh
- Extensions included in Miraheze/zh
- Extensions for data exchange with other local wikis/zh
- Extensions supporting fundraising and donations/zh
- Fundraising/zh
