Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/8.x-1.0-alpha2' into 8.x-1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
zero2one committed Jul 3, 2020
2 parents edf9fc7 + 9aec58f commit 6819272
Show file tree
Hide file tree
Showing 12 changed files with 367 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
# Ignore build artifacts.
/build
/.phpunit.result.cache

# Ignore binary translation files.
*.mo
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All Notable changes to **Digipolis DG Cookiebot** module.

## [8.x-1.0-alpha2]

### Added

* CCM-54: Added simple block to add the cookie settings link to a region

## [8.x-1.0-alpha1]

### Added
Expand All @@ -10,5 +16,6 @@ All Notable changes to **Digipolis DG Cookiebot** module.
* CCM-30: Added the proper data-cookieconsent level to video_embed_field when
the privacy option is enabled.

[8.x-1.0-alpha2]: https://github.com/digipolisgent/drupal_module_dg-cookiebot/compare/8.x-1.0-alpha1...8.x-1.0-alpha2
[8.x-1.0-alpha1]: https://github.com/digipolisgent/drupal_module_dg-cookiebot/releases/tag/8.x-1.0-alpha1
[Unreleased]: https://github.com/digipolisgent/drupal_module_dg-cookiebot/compare/8.x-1.x...8.x-1.x-dev
30 changes: 21 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,22 @@ Add the git source to the composer repositories: edit `composer.json` in the
project root and add following lines in the `repositories` section:

```json
{
"type": "composer",
"url": "https://packagist.gentgrp.gent.be"
}
{
"type": "composer",
"url": "https://packagist.gentgrp.gent.be"
}
```

Add the following Cookiebot module patch to have Cookiebot respect the language
of the current page:
Add the following Cookiebot module patches to:

- Have Cookiebot respect the language of the current page.
- Fix Cookiebot auto blocking breaking Drupal core Domready functionality.

```json
"drupal/cookiebot": {
"#3071334 Allow to set the language and multilingual support": "https://www.drupal.org/files/issues/2019-10-29/cookiebot-allow_to_set_the_language-3071334-8.patch"
},
"drupal/cookiebot": {
"#3071334 Allow to set the language and multilingual support": "https://www.drupal.org/files/issues/2019-10-29/cookiebot-allow_to_set_the_language-3071334-8.patch",
"#3091260 Blockmode `Auto` will not work with core's domready library": "https://www.drupal.org/files/issues/2020-01-29/cookiebot-attach_behaviors-3091260-30.patch"
},
```

Install the module using composer:
Expand Down Expand Up @@ -71,10 +74,19 @@ $config['cookiebot.settings']['cookiebot_cbid'] = 'COOKIEBOT DOMAIN GROUP ID';
Once the user has set his cookie consent he has by default no link to
review/edit his consent.

### Menu item

Add a menu item (e.g. to the footer menu) to update the cookie consent. The path
of the menu item should be `/cookiebot-renew`. It will be automatically
rewritten to trigger the cookie consent popup.

### Use block

There is a "Cookie settings link" block available to add the Cookie consent link
to a region on the website.

### Custom link

It's always possible to add a custom link to trigger opening the cookie consent
popup:

Expand Down
32 changes: 32 additions & 0 deletions dg_cookiebot.module
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@

declare(strict_types=1);

/**
* Implements hook_theme().
*/
function dg_cookiebot_theme() {
return [
'dg_cookiebot_settings_link' => [
'variables' => [],
],
];
}

/**
* Implements hook_preprocess_video_embed_iframe().
*
Expand All @@ -23,3 +34,24 @@ function dg_cookiebot_preprocess_video_embed_iframe(&$variables): void {
$attributes = &$variables['attributes'];
$attributes->setAttribute('data-cookieconsent', 'necessary');
}

/**
* Implements hook_library_info_alter().
*
* Replaces the cookiebot.js file by our own.
*/
function dg_cookiebot_library_info_alter(&$libraries, $extension) {
return;

if ($extension !== 'cookiebot') {
return;
}

if (!isset($libraries['cookiebot']['js']['js/cookiebot.js'])) {
return;
}

$newPath = '/' . drupal_get_path('module', 'dg_cookiebot') . '/js/dg-cookiebot.js';
$libraries['cookiebot']['js'][$newPath] = $libraries['cookiebot']['js']['js/cookiebot.js'];
unset($libraries['cookiebot']['js']['js/cookiebot.js']);
}
26 changes: 26 additions & 0 deletions src/Plugin/Block/CookiebotSettingsLink.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Drupal\dg_cookiebot\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
* Block with link to update cookie settings.
*
* @Block(
* id = "dg_cookiebot_settings_link",
* admin_label = @Translation("Cookie settings link")
* )
*/
class CookiebotSettingsLink extends BlockBase {

/**
* {@inheritdoc}
*/
public function build() {
return [
'#theme' => 'dg_cookiebot_settings_link',
];
}

}
13 changes: 13 additions & 0 deletions templates/dg-cookiebot-settings-link.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{#
/**
* @file
* Default theme implementation to present a cookiebot settings link block.
*
* Available variables:
* None
*
* @ingroup themeable
*/
#}

<a href="javascript:Cookiebot.renew()">{{ 'Cookie settings'|t }}</a>
36 changes: 36 additions & 0 deletions tests/src/Unit/Plugin/Block/CookiebotSettingsLinkTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace Drupal\Tests\dg_cookiebot\Unit\Plugin\Block;

use Drupal\dg_cookiebot\Plugin\Block\CookiebotSettingsLink;
use Drupal\Tests\UnitTestCase;

/**
* @covers \Drupal\dg_cookiebot\Plugin\Block\CookiebotSettingsLink
*
* @group dg_cookiebot
*/
class CookiebotSettingsLinkTest extends UnitTestCase {

/**
* Block contains simple render array.
*
* @test
*/
public function buildContainsSimpleRenderArray(): void {
$block = new CookiebotSettingsLink(
[],
'dg_cookiebot_settings_link',
['provider' => 'dg_cookiebot']
);

$expected = ['#theme' => 'dg_cookiebot_settings_link'];
$this->assertArrayEquals(
$expected,
$block->build()
);
}

}
44 changes: 44 additions & 0 deletions translations/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2020-07-03 13:53+0200\n"
"PO-Revision-Date: 2020-07-03 14:01+0200\n"
"Last-Translator: Peter Decuyper <[email protected]>\n"
"Language-Team: \n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.3.1\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: modules/contrib/dg_cookiebot/dg_cookiebot.info.yml:0
msgid "Cookiebot"
msgstr ""

#: modules/contrib/dg_cookiebot/dg_cookiebot.info.yml:0
msgid "Provides extra functionality on top of the Cookiebot module."
msgstr ""

#: modules/contrib/dg_cookiebot/dg_cookiebot.info.yml:0
msgid "Digipolis"
msgstr ""

#: modules/contrib/dg_cookiebot/src/Plugin/Block/CookiebotSettingsLink.php:7
msgid "Cookie settings link"
msgstr ""

#: modules/contrib/dg_cookiebot/src/Plugin/Filter/CookiebotDeclarationFilter.php:15
msgid "Replace Cookiebot declaration placeholder"
msgstr ""

#: modules/contrib/dg_cookiebot/src/Plugin/Filter/CookiebotDeclarationFilter.php:15
msgid ""
"Replaces the <code>[COOKIEBOT_DECLARATION]</code> placeholder by the actual "
"list of cookies used within the website."
msgstr ""

#: modules/contrib/dg_cookiebot/templates/dg-cookiebot-settings-link.html.twig:13
msgid "Cookie settings"
msgstr "Cookie-Einstellungen"
44 changes: 44 additions & 0 deletions translations/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2020-07-03 13:53+0200\n"
"PO-Revision-Date: 2020-07-03 14:01+0200\n"
"Last-Translator: Peter Decuyper <[email protected]>\n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.3.1\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: modules/contrib/dg_cookiebot/dg_cookiebot.info.yml:0
msgid "Cookiebot"
msgstr ""

#: modules/contrib/dg_cookiebot/dg_cookiebot.info.yml:0
msgid "Provides extra functionality on top of the Cookiebot module."
msgstr ""

#: modules/contrib/dg_cookiebot/dg_cookiebot.info.yml:0
msgid "Digipolis"
msgstr ""

#: modules/contrib/dg_cookiebot/src/Plugin/Block/CookiebotSettingsLink.php:7
msgid "Cookie settings link"
msgstr ""

#: modules/contrib/dg_cookiebot/src/Plugin/Filter/CookiebotDeclarationFilter.php:15
msgid "Replace Cookiebot declaration placeholder"
msgstr ""

#: modules/contrib/dg_cookiebot/src/Plugin/Filter/CookiebotDeclarationFilter.php:15
msgid ""
"Replaces the <code>[COOKIEBOT_DECLARATION]</code> placeholder by the actual "
"list of cookies used within the website."
msgstr ""

#: modules/contrib/dg_cookiebot/templates/dg-cookiebot-settings-link.html.twig:13
msgid "Cookie settings"
msgstr "Configuración de cookies"
44 changes: 44 additions & 0 deletions translations/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2020-07-03 13:53+0200\n"
"PO-Revision-Date: 2020-07-03 14:00+0200\n"
"Last-Translator: Peter Decuyper <[email protected]>\n"
"Language-Team: \n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.3.1\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#: modules/contrib/dg_cookiebot/dg_cookiebot.info.yml:0
msgid "Cookiebot"
msgstr ""

#: modules/contrib/dg_cookiebot/dg_cookiebot.info.yml:0
msgid "Provides extra functionality on top of the Cookiebot module."
msgstr ""

#: modules/contrib/dg_cookiebot/dg_cookiebot.info.yml:0
msgid "Digipolis"
msgstr ""

#: modules/contrib/dg_cookiebot/src/Plugin/Block/CookiebotSettingsLink.php:7
msgid "Cookie settings link"
msgstr ""

#: modules/contrib/dg_cookiebot/src/Plugin/Filter/CookiebotDeclarationFilter.php:15
msgid "Replace Cookiebot declaration placeholder"
msgstr ""

#: modules/contrib/dg_cookiebot/src/Plugin/Filter/CookiebotDeclarationFilter.php:15
msgid ""
"Replaces the <code>[COOKIEBOT_DECLARATION]</code> placeholder by the actual "
"list of cookies used within the website."
msgstr ""

#: modules/contrib/dg_cookiebot/templates/dg-cookiebot-settings-link.html.twig:13
msgid "Cookie settings"
msgstr "Paramètres des cookies"
51 changes: 51 additions & 0 deletions translations/general.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# $Id$
#
# LANGUAGE translation of Drupal (general)
# Copyright YEAR NAME <EMAIL@ADDRESS>
# Generated from files:
# modules/contrib/dg_cookiebot/dg_cookiebot.info.yml: n/a
# modules/contrib/dg_cookiebot/src/Plugin/Block/CookiebotSettingsLink.php: n/a
# modules/contrib/dg_cookiebot/src/Plugin/Filter/CookiebotDeclarationFilter.php: n/a
# modules/contrib/dg_cookiebot/templates/dg-cookiebot-settings-link.html.twig: n/a
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"POT-Creation-Date: 2020-07-03 13:53+0200\n"
"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\n"
"Last-Translator: NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"

#: modules/contrib/dg_cookiebot/dg_cookiebot.info.yml:0
msgid "Cookiebot"
msgstr ""

#: modules/contrib/dg_cookiebot/dg_cookiebot.info.yml:0
msgid "Provides extra functionality on top of the Cookiebot module."
msgstr ""

#: modules/contrib/dg_cookiebot/dg_cookiebot.info.yml:0
msgid "Digipolis"
msgstr ""

#: modules/contrib/dg_cookiebot/src/Plugin/Block/CookiebotSettingsLink.php:7
msgid "Cookie settings link"
msgstr ""

#: modules/contrib/dg_cookiebot/src/Plugin/Filter/CookiebotDeclarationFilter.php:15
msgid "Replace Cookiebot declaration placeholder"
msgstr ""

#: modules/contrib/dg_cookiebot/src/Plugin/Filter/CookiebotDeclarationFilter.php:15
msgid "Replaces the <code>[COOKIEBOT_DECLARATION]</code> placeholder by the actual list of cookies used within the website."
msgstr ""

#: modules/contrib/dg_cookiebot/templates/dg-cookiebot-settings-link.html.twig:13
msgid "Cookie settings"
msgstr ""

Loading

0 comments on commit 6819272

Please sign in to comment.