alula 0.4.8 → 0.4.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.8
1
+ 0.4.9
@@ -22,11 +22,13 @@ module Alula
22
22
  @@lock.synchronize do
23
23
  md5 = Digest::MD5.hexdigest(name)
24
24
  asset_hash = md5[0..3]
25
- until !mapping.key(asset_hash) or mapping.key(asset_hash) == name
26
- asset_hash = md5[0..(asset_hash.length + 1)]
25
+ asset_name = File.join(path + [asset_hash]) + File.extname(name)
26
+ until !mapping.key(asset_name) or mapping.key(asset_name) == name
27
+ asset_hash = md5[0..(asset_hash.length)]
28
+ asset_name = File.join(path + [asset_hash]) + File.extname(name)
27
29
  end
28
30
 
29
- mapping[name] = File.join(path + [asset_hash]) + File.extname(name)
31
+ mapping[name] = asset_name
30
32
  end
31
33
 
32
34
  mapping[name]
data/lib/alula/config.rb CHANGED
@@ -53,7 +53,7 @@ module Alula
53
53
  hides_base_locale: true, # Hide default locale
54
54
 
55
55
  # Default theme
56
- theme: 'minimal',
56
+ theme: {'minimal' => {}},
57
57
 
58
58
  # Template for generating post permalinks
59
59
  permalinks: '/:locale/:year/:month/:title/',
@@ -122,11 +122,12 @@ module Alula
122
122
  # Attachement Processors
123
123
  attachments: {
124
124
  "image" => {
125
- "size" => "800x600",
126
- "thumbnail" => "300x300",
127
- "keep_tags" => ["CopyrightNotice", "Title", "DateTimeOriginal"],
128
- "hires" => true,
129
- "lazyload" => true,
125
+ "size" => "800x600",
126
+ "thumbnail" => "300x300",
127
+ "thumbnail_mode" => :square,
128
+ "keep_tags" => ["CopyrightNotice", "Title", "DateTimeOriginal"],
129
+ "hires" => true,
130
+ "lazyload" => true,
130
131
  },
131
132
  "video" => {
132
133
  "size-hd" => "1280x720",
@@ -371,11 +371,11 @@ module Alula
371
371
  mtime = nil
372
372
  unless @item.nil?
373
373
  mtime = @item.mtime
374
- if self.site.git
375
- rev = %x{git rev-list -n 1 HEAD #{Shellwords.escape(@item.filepath)}}.strip
376
- time = %x{git show --pretty=format:%ai --abbrev-commit #{rev}|head -1}.strip
377
- mtime = Time.parse(time) rescue nil
378
- end
374
+ # if self.site.git
375
+ # rev = %x{git rev-list -n 1 HEAD #{Shellwords.escape(@item.filepath)}}.strip
376
+ # time = %x{git show --pretty=format:%ai --abbrev-commit #{rev}|head -1}.strip
377
+ # mtime = Time.parse(time) rescue nil
378
+ # end
379
379
  end
380
380
  mtime
381
381
  end
@@ -26,8 +26,8 @@ module Alula
26
26
  @options = {}
27
27
 
28
28
  # Parse tag options
29
- if m = /^([\"'][\S\. ]+[\"']|[\S\.]+)(.*)$/.match(@markup)
30
- @source = m[1].gsub(/^['"]?([^'"]+)['"]?$/, '\1')
29
+ if m = /^([\"][\S\. ]+[\"]|[\S\.]+)(.*)$/.match(@markup)
30
+ @source = m[1].gsub(/^["]?([^"]+)["]?$/, '\1')
31
31
  @source = "" if @source == '""'
32
32
  @options["source"] = @source unless @source.empty?
33
33
 
@@ -9,11 +9,16 @@ module Alula
9
9
  mimetype "image/jpeg", "image/png", "image/gif"
10
10
 
11
11
  def resize_image(opts)
12
- output = opts.delete(:output)
13
- width, height = opts.delete(:size)
12
+ output = opts[:output]
13
+ width, height = opts[:size]
14
14
 
15
15
  # Generate resized image
16
- resized = self.image.resize_to_fit(width, height)
16
+ resized = case self.site.config.attachments.image.thumbnail_mode
17
+ when :square
18
+ self.image.resize_to_fill(width, height)
19
+ else
20
+ self.image.resize_to_fit(width, height)
21
+ end
17
22
  # Make it progressive
18
23
  resized.interlace = ::Magick::PlaneInterlace
19
24
 
data/lib/alula/site.rb CHANGED
@@ -176,6 +176,7 @@ module Alula
176
176
  def banner
177
177
  puts ""
178
178
  puts "Alula #{Alula::VERSION}"
179
+ puts ""
179
180
  end
180
181
 
181
182
  def load_plugins
@@ -188,7 +189,6 @@ module Alula
188
189
  if @plugins
189
190
  puts "Plugins: " + @plugins.collect {|name, plugin| "#{name} #{plugin.version}"}.join(" ")
190
191
  end
191
- puts ""
192
192
  end
193
193
 
194
194
  def load_filters
@@ -209,8 +209,11 @@ module Alula
209
209
  @context = Alula::Context.new(site: self, storage: self.storage)
210
210
  @context.send(:extend, Helpers)
211
211
 
212
- @theme = Alula::Theme.load(site: self)
213
- puts "Theme: #{@theme.theme} #{@theme.version}"
212
+ # @theme = Alula::Theme.load(config.theme, site: self)
213
+ @theme = Alula::Theme.load(config.theme.to_a.last[0], config.theme.to_a.last[1])
214
+
215
+ puts " Theme: #{@theme.name} #{@theme.version}"
216
+ puts ""
214
217
 
215
218
  # Create our asset environment
216
219
  @environment = Environment.new
@@ -279,7 +282,8 @@ module Alula
279
282
 
280
283
  @@lock = Mutex.new
281
284
 
282
- Parallel.map(self.content.attachments, :in_threads => Parallel.processor_count) do |attachment|
285
+ # Parallel.map(self.content.attachments, :in_threads => Parallel.processor_count) do |attachment|
286
+ self.content.attachments.each do |attachment|
283
287
  if processor = attachments.get(attachment)
284
288
  processor.process
285
289
  end
@@ -303,7 +307,7 @@ module Alula
303
307
  io.puts "/*"
304
308
 
305
309
  # Theme style
306
- io.puts " *= require #{self.config.theme}"
310
+ io.puts " *= require #{@theme.name}"
307
311
 
308
312
  # Plugins
309
313
  @plugins.each do |name, plugin|
@@ -328,7 +332,7 @@ module Alula
328
332
  io.puts "/*"
329
333
 
330
334
  # Theme scripts
331
- io.puts " *= require #{self.config.theme}"
335
+ io.puts " *= require #{@theme.name}"
332
336
 
333
337
  # Plugins
334
338
  @plugins.each do |name, plugin|
data/lib/alula/theme.rb CHANGED
@@ -2,6 +2,19 @@ require 'alula/theme/layout'
2
2
 
3
3
  module Alula
4
4
  class Theme
5
+ def self.register(name, klass); themes[name.to_s] = klass; end
6
+ def self.themes; @@themes ||= {}; end
7
+ def themes; self.class.themes; end
8
+
9
+ def self.load(name, options)
10
+ if themes[name] and !(!!options == options and !options)
11
+ theme = themes[name]
12
+ return theme.new(options) if theme.install(options)
13
+ end
14
+ end
15
+
16
+ def self.install(options); true; end
17
+
5
18
  attr_reader :version
6
19
  attr_reader :site
7
20
  attr_reader :theme
@@ -9,35 +22,39 @@ module Alula
9
22
  attr_reader :layouts
10
23
  attr_reader :context
11
24
 
12
- def self.register(theme, path, version)
13
- @@themes ||= {}
14
- @@themes[theme.to_s] = ::File.join(path, theme.to_s)
15
-
16
- @@theme_versions ||= {}
17
- @@theme_versions[theme.to_s] = version
18
- end
25
+ # def self.register(theme, path, version)
26
+ # @@themes ||= {}
27
+ # @@themes[theme.to_s] = ::File.join(path, theme.to_s)
28
+ #
29
+ # @@theme_versions ||= {}
30
+ # @@theme_versions[theme.to_s] = version
31
+ # end
19
32
 
20
- def self.load(opts)
21
- return nil unless self.class_variable_defined?(:@@themes)
22
- site = opts[:site]
23
-
24
- theme_name = site.config.theme
25
- return self.new(theme_name, opts) if @@themes.has_key?(theme_name)
26
-
27
- return nil
28
- end
29
-
30
- def initialize(theme, opts)
31
- @site = opts.delete(:site)
32
- @theme = theme
33
- @path = @@themes[theme]
33
+ # def self.load(opts)
34
+ # return nil unless self.class_variable_defined?(:@@themes)
35
+ # site = opts[:site]
36
+ #
37
+ # theme_name = site.config.theme
38
+ # return self.new(theme_name, opts) if @@themes.has_key?(theme_name)
39
+ #
40
+ # return nil
41
+ # end
42
+ #
43
+ def initialize(opts)
44
+ @site = Site.instance
45
+ # @theme = theme
46
+ # @path = @@themes[theme]
34
47
 
35
48
  @context = @site.context
36
49
 
37
50
  @layouts = {}
38
51
  @views = {}
39
52
 
40
- @version = @@theme_versions[theme]
53
+ # @version = @@theme_versions[theme]
54
+ end
55
+
56
+ def name
57
+ themes.key(self.class)
41
58
  end
42
59
 
43
60
  def searchpath(type, name)
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.8
4
+ version: 0.4.9
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-07-29 00:00:00.000000000 Z
12
+ date: 2012-08-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: parallel
@@ -644,7 +644,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
644
644
  version: '0'
645
645
  segments:
646
646
  - 0
647
- hash: 3562643851070026928
647
+ hash: 2079066484659239768
648
648
  required_rubygems_version: !ruby/object:Gem::Requirement
649
649
  none: false
650
650
  requirements:
@@ -653,7 +653,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
653
653
  version: '0'
654
654
  segments:
655
655
  - 0
656
- hash: 3562643851070026928
656
+ hash: 2079066484659239768
657
657
  requirements: []
658
658
  rubyforge_project:
659
659
  rubygems_version: 1.8.23