middleman-gdpr 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 644b704a5ba83280c4d287fa1f271ac3c0a938db390c6086d98a1d58b1e486ed
4
- data.tar.gz: 46b00fd0a01b1f24e96244602209e0ca450047e929dd219371a7ef0f0a4c59a0
3
+ metadata.gz: be520ef04f3b04c32e8c4b7016e2066c9ebd7260bb20ce84c23dea7334345cb3
4
+ data.tar.gz: 33fb71074ba4b54234b98619d7b62f09dc8afbc047ba8f8e628a4c461a16e13b
5
5
  SHA512:
6
- metadata.gz: 01b92206c792ebdbb447fb06197a8fbdfc9c3e3ba69d43e7af270c7e54e4ea01b954d54c9a8ccc4e0968b41873f97e58960641a81db2c7467c5767ffb1d3b384
7
- data.tar.gz: 6ff5caee0f6e04ace4b7cf5ebc475b5067cfde9ff70817f8585e581a374a75913296e1adfdd150d596676659dce71accbac46db9816086ab742551508077be93
6
+ metadata.gz: ba6f87b7f5edcf4f07eab964bc8ab6714d351aa0d615d031d5b70cdc24832dfcbab49284b37229656d7a0b2d3ef913f3ed3f59f551c2e6627842f5e471e2877d
7
+ data.tar.gz: 9883c6af14e9355467cbf38e7cb203cb169cf7deca90fde4c6211d51c1f1ee94d512dfd2cefccbe7659d7e982ac24e9f9e7919d58bb4fcadceb73439de6b86f8
data/README.md CHANGED
@@ -27,7 +27,7 @@ activate :i18n
27
27
 
28
28
  Add this to the layout:
29
29
  ```ruby
30
- <%= gdpr %>
30
+ <%= gdpr :cookie_consent %>
31
31
  ```
32
32
 
33
33
  Add this to javascripts:
@@ -40,6 +40,13 @@ Add this to stylesheets:
40
40
  @import 'gdpr/cookie_consent'
41
41
  ```
42
42
 
43
+ If your site isn't localized but you want gdpr messages to be in a given language (default: English), just add the corresponding option when activating I18n:
44
+
45
+ ```ruby
46
+ # config.rb
47
+ activate :i18n, langs: [:fr]
48
+ ```
49
+
43
50
  Set the privacy policy url in the locales.
44
51
 
45
52
  ## Checklist
@@ -6,8 +6,8 @@ module Middleman
6
6
  # end
7
7
 
8
8
  def after_configuration
9
- puts "\e[91mGDPR: Sprockets extension not found, GDPR extension has not been activated\e[39m" and return if sprockets.blank?
10
- puts "\e[91mGDPR: I18n extension not found, GDPR extension has not been activated\e[39m" and return if i18n.blank?
9
+ puts "\e[91mGDPR: Sprockets extension not found, GDPR extension has not been activated. Please activate Sprockets in config.rb:\nactivate :sprockets\e[39m\n" and return if sprockets.blank?
10
+ puts "\e[91mGDPR: I18n extension not found, GDPR extension has not been activated. Please activate I18n in config.rb:\nactivate :i18n\e[39m\n" and return if i18n.blank?
11
11
 
12
12
  ['source/stylesheets', 'source/javascripts', 'node_modules'].each do |path|
13
13
  sprockets.environment.append_path root + path
@@ -17,23 +17,30 @@ module Middleman
17
17
  end
18
18
 
19
19
  def root
20
- Pathname.new(__dir__) + '../..'
20
+ self.class.root
21
21
  end
22
22
 
23
23
  helpers do
24
- def gdpr
25
- <<~HTML
26
- <div class="gdpr__cookie_consent js-gdpr__cookie_consent">
27
- <div class="gdpr__cookie_consent__text">
28
- #{t 'gdpr.cookie_consent.text'}
29
- <br />
30
- #{t 'gdpr.cookie_consent.learn_more_html', link: t('gdpr.privacy_policy')}
31
- </div>
32
- <div class="gdpr__cookie_consent__buttons">
33
- <button class="gdpr__cookie_consent__buttons__ok js-gdpr__cookie_consent__buttons__ok"> #{t 'gdpr.cookie_consent.button' }</button>
34
- </div>
35
- </div>
36
- HTML
24
+ def gdpr(partial)
25
+ template = Middleman::Gdpr::Extension.template_for partial
26
+ raise "GDPR: \"#{partial}\" partial doesn't exist" if template.blank?
27
+ return ERB.new(template).result binding
28
+ end
29
+ end
30
+
31
+ class << self
32
+ def root
33
+ Pathname.new(__dir__) + '../..'
34
+ end
35
+
36
+ def template_for(partial)
37
+ partial = File.basename(partial.to_s)
38
+ .sub(/\A_/, '')
39
+ .sub(/\.(html|erb|html\.erb)\z/, '')
40
+
41
+ path = root + "source/gdpr/_#{partial}.html.erb"
42
+
43
+ return File.read path if File.exists? path
37
44
  end
38
45
  end
39
46
 
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module Gdpr
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -0,0 +1,10 @@
1
+ <div class="gdpr__cookie_consent js-gdpr__cookie_consent">
2
+ <div class="gdpr__cookie_consent__text">
3
+ <%= t 'gdpr.cookie_consent.text' %>
4
+ <br />
5
+ <%= t 'gdpr.cookie_consent.learn_more_html', link: t('gdpr.privacy_policy') %>
6
+ </div>
7
+ <div class="gdpr__cookie_consent__buttons">
8
+ <button class="gdpr__cookie_consent__buttons__ok js-gdpr__cookie_consent__buttons__ok"> <%= t 'gdpr.cookie_consent.button' %></button>
9
+ </div>
10
+ </div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-gdpr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Levy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-07-02 00:00:00.000000000 Z
13
+ date: 2018-07-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: middleman-core
@@ -82,6 +82,7 @@ files:
82
82
  - node_modules/js-cookie/SERVER_SIDE.md
83
83
  - node_modules/js-cookie/package.json
84
84
  - node_modules/js-cookie/src/js.cookie.js
85
+ - source/gdpr/_cookie_consent.html.erb
85
86
  - source/javascripts/gdpr/cookie_consent.js
86
87
  - source/stylesheets/gdpr/cookie_consent.sass
87
88
  homepage: https://github.com/lespoupeesrusses/middleman-gdpr