alula 0.4.16 → 0.4.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,15 +23,15 @@ module Alula
23
23
  md5 = Digest::MD5.hexdigest(name)
24
24
  asset_hash = md5[0..3]
25
25
  asset_name = File.join(path + [asset_hash]) + File.extname(name)
26
- until !mapping.key(asset_name) or mapping.key(asset_name) == name
26
+ until !mapping.key(asset_name) or mapping.key(asset_name) == name.downcase
27
27
  asset_hash = md5[0..(asset_hash.length)]
28
28
  asset_name = File.join(path + [asset_hash]) + File.extname(name)
29
29
  end
30
30
 
31
- mapping[name] = asset_name
31
+ mapping[name.downcase] = asset_name
32
32
  end
33
33
 
34
- mapping[name]
34
+ mapping[name.downcase]
35
35
  end
36
36
 
37
37
  def get(item)
@@ -56,22 +56,27 @@ module Alula
56
56
  file = self.context.asset_path(attachment_path(source, type))
57
57
  return Hashie::Mash.new if file.nil?
58
58
 
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]
64
- end
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
65
  Hashie::Mash.new({
66
- width: info[0],
67
- height: info[1],
66
+ width: info.imagewidth,
67
+ height: info.imageheight,
68
+ rotation: info.rotation,
69
+ copyright: info.copyrightnotice,
70
+ filetype: info.filetype,
71
+ title: info.title,
72
+ caption: info.caption,
68
73
  })
69
74
  end
70
75
  end
71
76
 
72
77
  def attachment_path(source, type = nil)
73
78
  name = (type.nil?) ? source : File.join(type.to_s, source)
74
- self.context.attachments.mapping[name]
79
+ self.context.attachments.mapping[name.downcase]
75
80
  end
76
81
 
77
82
  def attachment_url(source, type = nil)
@@ -28,6 +28,11 @@ module Alula
28
28
 
29
29
  classes = opts.delete(:classes) || @options["classes"]
30
30
 
31
+ unless @options['alternative'] or @options['title']
32
+ @options['title'] = info(source, type).title
33
+ @options['alternative'] = info(source, type).title
34
+ end
35
+
31
36
  tag = "<img"
32
37
  tag += " alt=\"#{@options["alternative"]}\"" if @options["alternative"]
33
38
  tag += " title=\"#{@options["title"]}\"" if @options["title"]
@@ -33,11 +33,6 @@ module Alula
33
33
  layout: "sitemap",
34
34
  })
35
35
  self.site.content.pages << @sitemap_page
36
-
37
- # Add link to head
38
- Alula::Plugin.addon(:head, ->(context) {
39
- "<link rel=\"sitemap\" type=\"application/xml\" title=\"Sitemap\" href=\"#{context.url_for(@sitemap_page.url(context.locale))}\">"
40
- })
41
36
  end
42
37
  end
43
38
  end
data/lib/alula/plugin.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'hashie/mash'
2
-
3
1
  module Alula
4
2
  class Plugin
5
3
  def self.register(name, klass); plugins[name.to_s] = klass; end
@@ -13,9 +11,38 @@ module Alula
13
11
  end
14
12
  end
15
13
 
16
- def self.addons; @@addons ||= Hash.new {|hash, key| hash[key] = []}; end
17
- def self.addon(type, content_or_block); addons[type] << content_or_block; end
18
- def self.prepend_addon(type, content_or_block); addons[type].unshift content_or_block; end
14
+ def self.addons
15
+ @@addons ||= Hash.new {|hash, key| hash[key] = []}
16
+ end
17
+
18
+ def self.addon(type, content_or_block)
19
+ addons[type] << content_or_block
20
+ end
21
+
22
+ def self.prepend_addon(type, content_or_block)
23
+ addons[type].unshift content_or_block
24
+ end
25
+
26
+ def self.script(type, content_or_block)
27
+ script = <<-EOS
28
+ <script type="#{self.cookieconsent? ? "text/plain" : "text/javascript"}" #{self.cookieconsent? ? "style=\"cc-onconsent-analytics\"" : ""}>
29
+ EOS
30
+ if content_or_block.kind_of?(Proc)
31
+ scpt = ->(context) { script + content_or_block.call(context) + "</script>" }
32
+ else
33
+ scpt = script + content_or_block + "</script>"
34
+ end
35
+
36
+ addons[type] << scpt
37
+ end
38
+
39
+ def self.needs_cookieconsent
40
+ @@cookieconsent = true
41
+ end
42
+
43
+ def self.cookieconsent?
44
+ @@cookieconsent == true
45
+ end
19
46
 
20
47
  def self.script_load_mode=(mode)
21
48
  @@script_load_mode = case mode
data/lib/alula/site.rb CHANGED
@@ -323,6 +323,7 @@ module Alula
323
323
  end
324
324
 
325
325
  # Vendored
326
+ io.puts " *= require cookieconsent" if Alula::Plugin.cookieconsent?
326
327
 
327
328
  # Blog customization
328
329
  @storage.custom(/stylesheets\/.*.css.*$/).each do |name, item|
@@ -349,6 +350,7 @@ module Alula
349
350
 
350
351
  # Vendored
351
352
  io.puts " *= require lazyload" if self.config.attachments.image.lazyload
353
+ io.puts " *= require cookieconsent" if Alula::Plugin.cookieconsent?
352
354
 
353
355
  # Customisation
354
356
  @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 = 16
5
+ PATCH = 17
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.16
4
+ version: 0.4.17
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-23 00:00:00.000000000 Z
12
+ date: 2012-08-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hashie