alula 0.4.18 → 0.4.19

Sign up to get free protection for your applications and to get access to all the features.
data/lib/alula/config.rb CHANGED
@@ -83,6 +83,16 @@ module Alula
83
83
  # Plugins
84
84
  plugins: {},
85
85
 
86
+ # Cookie consent
87
+ cookieconsent: {
88
+ consenttype: "implicit",
89
+ style: "light",
90
+ bannerPosition: "push",
91
+ onlyshowbanneronce: true,
92
+ privacysettingstab: false,
93
+ ipinfodbkey: "",
94
+ },
95
+
86
96
  # Deployment options
87
97
  deployment: { "package" => {}},
88
98
 
@@ -1,5 +1,5 @@
1
1
  require 'liquid'
2
- require 'dimensions'
2
+ require 'mini_exiftool'
3
3
 
4
4
  module Alula
5
5
  module LiquidExt
@@ -57,11 +57,6 @@ module Alula
57
57
  return Hashie::Mash.new if file.nil?
58
58
 
59
59
  info = MiniExiftool.new File.join self.context.storage.path(:public), file
60
- # # info = Dimensions.dimensions(File.join(self.context.storage.path(:public), file))
61
- # info ||= begin
62
- # _info = MiniExiftool.new File.join(self.context.storage.path(:public), file)
63
- # [_info.imagewidth, _info.imageheight, _info.copyrightnotice]
64
- # end
65
60
  Hashie::Mash.new({
66
61
  width: info.imagewidth,
67
62
  height: info.imageheight,
@@ -35,6 +35,7 @@ module Alula
35
35
  generator: self,
36
36
  posts: archive[:content],
37
37
  title: archive[:title],
38
+ priority: 0.2,
38
39
  description: archive[:description],
39
40
  name: name,
40
41
  slug: name,
@@ -52,7 +52,6 @@ module Alula
52
52
  Alula::Plugin.addon(:head, ->(context) {
53
53
  "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"#{context.url_for(@feed_page.url(context.locale))}\">"
54
54
  })
55
- # -# %link{rel: "alternate", type: "application/rss+xml", title: "RSS", href: "/feed.xml"}
56
55
  end
57
56
  end
58
57
  end
@@ -15,7 +15,7 @@ module Alula
15
15
  content.languages.collect{|lang| {
16
16
  url: content.url(lang),
17
17
  lastmod: content.last_modified,
18
- priority: content.generator.nil? ? 0.5 : 0.3,
18
+ priority: content.generator.nil? ? 1.0 : !content.metadata.priority.nil? ? content.metadata.priority : 0.3,
19
19
  }
20
20
  }
21
21
  }.flatten
data/lib/alula/plugin.rb CHANGED
@@ -1,8 +1,16 @@
1
1
  module Alula
2
2
  class Plugin
3
- def self.register(name, klass); plugins[name.to_s] = klass; end
4
- def self.plugins; @@plugins ||= {}; end
5
- def plugins; self.class.plugins; end
3
+ def self.register(name, klass)
4
+ plugins[name.to_s] = klass
5
+ end
6
+
7
+ def self.plugins
8
+ @@plugins ||= {}
9
+ end
10
+
11
+ def plugins
12
+ self.class.plugins
13
+ end
6
14
 
7
15
  def self.load(name, options)
8
16
  if plugins[name] and !(!!options == options and !options)
@@ -23,25 +31,52 @@ module Alula
23
31
  addons[type].unshift content_or_block
24
32
  end
25
33
 
26
- def self.script(type, content_or_block)
34
+ def self.script(placement, content_or_block)
35
+ name = caller_name
36
+
37
+ if self.cookieconsent?(name)
38
+ self.cookieconsented(name)
39
+ end
40
+
27
41
  script = <<-EOS
28
- <script type="#{self.cookieconsent? ? "text/plain" : "text/javascript"}" #{self.cookieconsent? ? "style=\"cc-onconsent-analytics\"" : ""}>
42
+ <script type="#{self.cookieconsent?(name) ? "text/plain" : "text/javascript"}" #{self.cookieconsent?(name) ? "style=\"cc-onconsent-#{@@cookieconsent[name].to_s}\"" : ""}>
29
43
  EOS
30
44
  if content_or_block.kind_of?(Proc)
31
45
  scpt = ->(context) { script + content_or_block.call(context) + "</script>" }
32
46
  else
33
47
  scpt = script + content_or_block + "</script>"
34
48
  end
49
+
50
+ self.addon(placement, scpt)
51
+ end
52
+
53
+ def self.needs_cookieconsent(type = 'analytics')
54
+ name = caller_name
35
55
 
36
- addons[type] << scpt
56
+ @@cookieconsent ||= {}
57
+ @@cookieconsent[name] = type
37
58
  end
38
59
 
39
- def self.needs_cookieconsent
40
- @@cookieconsent = true
60
+ def self.cookieconsent?(name = nil)
61
+ if name.nil?
62
+ @@cookieconsent.kind_of?(Hash)
63
+ else
64
+ @@cookieconsent.kind_of?(Hash) and @@cookieconsent.key?(name)
65
+ end
41
66
  end
42
67
 
43
- def self.cookieconsent?
44
- @@cookieconsent == true
68
+ def self.cookieconsented(name)
69
+ @@cookieconsented ||= {}
70
+ @@cookieconsented[name] = true
71
+ end
72
+
73
+ def self.cookieconsent_types
74
+ @@cookieconsented ||= {}
75
+ if @@cookieconsented.kind_of?(Hash)
76
+ @@cookieconsented.keys
77
+ else
78
+ []
79
+ end
45
80
  end
46
81
 
47
82
  def self.script_load_mode=(mode)
@@ -56,5 +91,10 @@ module Alula
56
91
  def self.script_load_mode
57
92
  @@script_load_mode ||= :async
58
93
  end
94
+
95
+ private
96
+ def self.caller_name
97
+ caller[1].gsub(/.*\/(.*)\.\w+:\d+.*/, '\1').downcase
98
+ end
59
99
  end
60
100
  end
data/lib/alula/site.rb CHANGED
@@ -131,10 +131,6 @@ module Alula
131
131
  # Set up default head addons
132
132
  Alula::Plugin.addon(:head, "<meta name=\"generator\" content=\"Alula #{Alula::VERSION::STRING}\">")
133
133
  Alula::Plugin.addon(:head, ->(context){"<link rel=\"icon\" type=\"image/png\" href=\"#{context.asset_url('favicon.png')}\">"})
134
-
135
- # Set up footer addons (disclaimer, copyright)
136
- Alula::Plugin.addon(:footer, ->(context){ "<p class=\"disclaimer\">#{context.site.config.disclaimer(context.locale)}</p>" }) if self.config.disclaimer
137
- Alula::Plugin.addon(:footer, ->(context){ "<p class=\"copyright\">#{context.site.config.copyright(context.locale)}</p>" }) if self.config.copyright
138
134
  end
139
135
 
140
136
  # Compiles a site to static website
@@ -326,7 +322,7 @@ module Alula
326
322
  end
327
323
 
328
324
  # Vendored
329
- io.puts " *= require cookieconsent" if Alula::Plugin.cookieconsent?
325
+ io.puts " *= require cookieconsent" unless Alula::Plugin.cookieconsent_types.empty?
330
326
 
331
327
  # Blog customization
332
328
  @storage.custom(/stylesheets\/.*.css.*$/).each do |name, item|
@@ -336,7 +332,7 @@ module Alula
336
332
 
337
333
  io.puts "*/"
338
334
  end
339
- # Add stlesheet to template
335
+ # Add stylesheet to template
340
336
  Alula::Plugin.prepend_addon(:head, ->(context){ context.stylesheet_link("style") })
341
337
 
342
338
  # Generate javascript
@@ -353,7 +349,7 @@ module Alula
353
349
 
354
350
  # Vendored
355
351
  io.puts " *= require lazyload" if self.config.attachments.image.lazyload
356
- io.puts " *= require cookieconsent" if Alula::Plugin.cookieconsent?
352
+ io.puts " *= require cookieconsent" unless Alula::Plugin.cookieconsent_types.empty?
357
353
 
358
354
  # Customisation
359
355
  @storage.custom(/javascripts\/.*.js.*$/).each do |name, item|
data/lib/alula/version.rb CHANGED
@@ -2,7 +2,7 @@ module Alula
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 4
5
- PATCH = 18
5
+ PATCH = 19
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alula
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.18
4
+ version: 0.4.19
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-27 00:00:00.000000000 Z
12
+ date: 2012-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hashie