Jump to content

扩展:CookieWarning

From mediawiki.org
This page is a translated version of the page Extension:CookieWarning and the translation is 89% complete.
MediaWiki扩展手册
CookieWarning
发行状态: 稳定版
实现 用户界面
描述 在页面顶部添加通知,告知用户此 Wiki 使用 Cookie 进行操作。
作者
最新版本 0.3.0 (2021年2月)
MediaWiki 1.35+
PHP 7.1+
许可协议 MIT授權條款
下載
  • $wgCookieWarningGeoIPLookup
  • $wgCookieWarningGeoIPServiceURL
  • $wgCookieWarningForCountryCodes
  • $wgCookieWarningMoreUrl
  • $wgCookieWarningEnabled
季度下載量 42 (Ranked 88th)
正在使用的公开wiki数 985 (Ranked 258th)
前往translatewiki.net翻譯CookieWarning扩展
問題 开启的任务 · 报告错误

扩展 CookieWarning 是一个小而简单的扩展,它在你的维基上添加了一个小但清晰可见的信息横幅,通知用户这个维基使用 Cookie 来正常运行。 默认消息还包括一句话,如果用户继续使用 wiki ,则用户同意 wiki 使用 Cookie。

背景

在一些国家,法律要求(如欧盟)作为网站运营商,您需要向用户申请在网站上使用 Cookie 的许可。 In the EU, some of your partners may require you to ask your users to use cookies (e.g., because you use Google AdSense, which requires this notice[1]). To make it easier for wiki administrators to implement these notices, this extension was created (by Florianschmidtwelzow, primarily for use on droidwiki.de).

历史

This extension was merged with the former CookiePolicy extension, which provided a similar functionality and was originally written by Liz Lee for Wikia and further cleaned up and enhanced by Jack Phoenix for ShoutWiki .

安裝

  • 下载文件,并将解压后的CookieWarning文件夹移动到extensions/目录中。
    开发者和代码贡献人员应从Git安装扩展,输入:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/CookieWarning
  • 将下列代码放置在您的LocalSettings.php 的底部:
    wfLoadExtension( 'CookieWarning' );
    
  • Yes 完成 – 在您的wiki上导航至Special:Version,以验证已成功安装扩展。

配置

After the successful installation of CookieWarning, you need to enable it with the configuration option $wgCookieWarningEnabled, which you need to set to true in your LocalSettings.php. 如果你有一个页面,解释你和你的合作伙伴如何在维基中使用 Cookies ,你可能想链接到这个页面。 For this, you can add another configuration option, $wgCookieWarningMoreUrl, which simply takes the URL of the page (full or relative, but relative may not work, if you use subpages in your wiki!). Alternatively, you can set [[MediaWiki:Cookiewarning-more-link]] to the URL of your site's privacy policy or similar page which explains about cookies.

配置参数

还有一些其他配置,可以帮助您使用 Cookie 信息栏定位正确的用户。 下表包含所有可能的选项。

配置 默认值 描述
$wgCookieWarningEnabled false 必须将此变量设置为 true 才能使扩展工作。
$wgCookieWarningMoreUrl '' 将URL设置为“更多信息”页面。
$wgCookieWarningGeoIPServiceURL '' An IP location service takes the visitor's IP address and returns a JSON string that complies with the freegeoip.net schema (example). CAUTION: If the geo-targeting is enabled, the IP address of your users will be directly (NOT anonymized!) sent to the service configured in this option, which may be a problem in some countries or jurisdictions.
$wgCookieWarningGeoIPLookup 'none' 您希望 Wiki 何时以及如何尝试定位用户。 可能的值:
  • none - 地理定位已关闭,扩展不会尝试根据 IP 地址定位用户。
  • php - The extension ships with a class that handles the request of the service configured in wgCookieWarningGeoIPServiceURL to locate the user. The request timeout is 2 seconds, so depending on your server's connection and the configured service's load, this may slow down the request for the user. However, locating the user will work even if the user has turned off JavaScript.
  • js - The extension will ship a client-side JavaScript code to the user with each request, which will try to locate the user (again, using the service configured in $wgCookieWarningGeoIPServiceURL). The size of the shipped page will increase accordingly. However, the processing of the request does not depend on a third-party site anymore (like when using php).
$wgCookieWarningForCountryCodes
{
	"EU": "Europe",
	"AD": "Andorra",
	"AL": "Albania",
	"AT": "Austria",
	"BA": "Bosnia and Herzegovina",
	"BE": "Belgium",
	"BG": "Bulgaria",
	"BY": "Belarus",
	"CH": "Switzerland",
	"CS": "Serbia and Montenegro",
	"CZ": "Czech Republic",
	"DE": "Germany",
	"DK": "Denmark",
	"EE": "Estonia",
	"ES": "Spain",
	"FI": "Finland",
	"FO": "Faroe Islands",
	"FR": "France",
	"FX": "France, Metropolitan",
	"GB": "United Kingdom",
	"GI": "Gibraltar",
	"GR": "Greece",
	"HR": "Croatia",
	"HU": "Hungary",
	"IE": "Ireland",
	"IS": "Iceland",
	"IT": "Italy",
	"LI": "Liechtenstein",
	"LT": "Lithuania",
	"LU": "Luxembourg",
	"LV": "Latvia",
	"MC": "Monaco",
	"MD": "Moldova, Republic of",
	"MK": "Macedonia",
	"MT": "Malta",
	"NL": "Netherlands",
	"NO": "Norway",
	"PL": "Poland",
	"PT": "Portugal",
	"RO": "Romania",
	"SE": "Sweden",
	"SI": "Slovenia",
	"SJ": "Svalbard and Jan Mayen",
	"SK": "Slovakia",
	"SM": "San Marino",
	"UA": "Ukraine",
	"VA": "Holy See (Vatican City State)"
}
用户应在 Cookie 通知栏中看到的区域列表。

系统消息

If you would like to change the text of the messages shown, navigate to the following pages and adjust as required:

  • "MediaWiki:Cookiewarning-info"
  • "MediaWiki:Cookiewarning-moreinfo-label"
  • "MediaWiki:Cookiewarning-more-link"
  • "MediaWiki:Cookiewarning-ok-label"

从CookiePolicy扩展迁移

In October 2016, the CookiePolicy extension was merged into the CookieWarning extension, as both tried to solve the same problem. 以下部分将为您提供将 CookiePolicy 迁移到 CookieWarning 所需的信息。

[[MediaWiki:Cookie-policy-link]]

The [[MediaWiki:Cookie-policy-link]] interface message will be observed by CookieWarning, too, so you can use your customization of the message shown to the user with CookieWarning, too. However, as this is just for backward compatibility reasons, it is strongly recommended to change to the message [[MediaWiki:Cookiewarning-more-link]], e.g., by moving the page on your wiki, or using the configuration option $wgCookieWarningMoreUrl to configure the target link.

基于 JavaScript 的地理定位

定位 CookiePolicy 中使用的用户的逻辑被合并到 CookieWarning 中。 但是,您需要通过在 LocalSettings.php 中设置以下选项来配置某些功能以启用它:

$wgCookieWarningEnabled = true;
$wgCookieWarningGeoIPLookup = 'js';

$wgCookiePolicyGeoIPServiceURL

在 CookieWarning 中, $wgCookiePolicyGeoIPServiceURL 配置选项名为 $wgCookieWarningGeoIPServiceURL ,如果您使用它,您需要在 LocalSettings.php 中更改它。

參見

参考资料