alula 0.1.4 → 0.2.0a

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.2.0a
data/alula.gemspec CHANGED
@@ -29,5 +29,4 @@ Gem::Specification.new do |gem|
29
29
  gem.add_dependency 'ruby-progressbar', '~> 0.0.10'
30
30
 
31
31
  gem.add_development_dependency 'version', '~> 1.0.0'
32
- gem.add_development_dependency 'pry', '~> 0.9.8.4'
33
32
  end
data/bin/alula CHANGED
@@ -4,9 +4,14 @@ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
4
4
 
5
5
  # Are we in Alula blog
6
6
  if File.exists?("Gemfile") and File.read("Gemfile") =~ /alula/
7
- require 'bundler/setup'
8
- Bundler.require(:default)
9
- end
7
+ # Restart tool from bundle if facing load error (usually older alula already loaded)
8
+ require 'bundler'
9
+ begin
10
+ Bundler.require(:default)
11
+ rescue LoadError
12
+ exec "bundle", "exec", "alula", *ARGV
13
+ end
14
+ end
10
15
 
11
16
  require 'alula/cli'
12
17
  Alula::CLI.start
data/lib/alula/cli.rb CHANGED
@@ -11,7 +11,7 @@ module Alula
11
11
  desc "init [PATH]", "Creates a new aLula blog in given path or current directory"
12
12
  def init(path = ".")
13
13
  # Create directory structure
14
- %w{attachments attachments/_originals attachments/_thumbnails posts}.each do |dir|
14
+ %w{attachments attachments/_originals attachments/_thumbnails posts pages}.each do |dir|
15
15
  empty_directory File.join(path, dir)
16
16
  end
17
17
 
@@ -30,7 +30,7 @@ module Alula
30
30
  method_option :development, :type => :boolean, :default => true,
31
31
  :desc => "Generate site using development settings. Keeps all assets and HTML uncompressed."
32
32
  method_option :production, :type => :boolean, :default => false,
33
- :desc => "Generate site suing production settings. Compresses all assets and HTML."
33
+ :desc => "Generate site using production settings. Compresses all assets and HTML."
34
34
  def generate
35
35
  site = Alula::Site.new("asset_compress" => (!options["development"] or options["production"]))
36
36
  site.generate
@@ -52,9 +52,10 @@ module Alula
52
52
  site.asset_attach(post, assets)
53
53
  end
54
54
 
55
- desc "hello"
56
- def hello
57
- say "Hello world."
55
+ desc "clean", "Clean up all generated content"
56
+ def clean
57
+ site = Alula::Site.new
58
+ site.clean
58
59
  end
59
60
  end
60
61
  end
data/lib/alula/site.rb CHANGED
@@ -29,18 +29,14 @@ module Alula
29
29
  Alula::Theme.register("themes")
30
30
 
31
31
  # Initialize Jekyll
32
- options = Jekyll::DEFAULTS.deep_merge({
33
- 'source' => '_tmp',
34
- 'destination' => 'public',
35
- 'markdown' => 'kramdown',
36
-
32
+ options = Alula::DEFAULTS.deep_merge({
37
33
  # Site options
38
34
  'title' => @config["title"],
39
35
  'tagline' => @config["tagline"],
40
36
  'author' => @config["author"],
41
37
  'root' => @config["root"],
42
- 'asset_path' => "#{@config["root"]}assets",
43
- 'permalinks' => @config["permalinks"],
38
+ 'asset_path' => File.join(@config["root"], "assets"),
39
+ 'permalink' => @config["permalink"],
44
40
  'paginate' => @config["paginate"],
45
41
  'pagination_dir' => @config["pagination_dir"],
46
42
  'excerpt_link' => @config["excerpt_link"],
@@ -136,13 +132,15 @@ module Alula
136
132
  t.join()
137
133
  end
138
134
 
139
- def asset_attach(post, assets)
135
+ def asset_attach(a_post, assets)
140
136
  # Find the post
141
- post = find_post(post)
142
- post =~ /(?<date>(\d{4}-\d{2}-\d{2}))/
137
+ post = find_post(a_post) or raise "Cannot find post #{a_post}"
138
+
139
+ /(?<date>(\d{4}-\d{2}-\d{2}))/ =~ post
140
+ # require 'pry';binding.pry
143
141
  date = Time.parse(date)
144
142
 
145
- width, height = @config["images"].split("x").collect {|i| i.to_i }
143
+ width, height = @config["images"]["size"].split("x").collect {|i| i.to_i }
146
144
  asset_path = File.join(%w{%Y %m %d}.collect{|f| date.strftime(f) })
147
145
  file_path = File.join("attachments", "_originals", asset_path)
148
146
  FileUtils.mkdir_p(file_path)
@@ -156,34 +154,41 @@ module Alula
156
154
  assets.each do |asset|
157
155
  asset_ext = File.extname(asset).downcase
158
156
  asset_base = File.basename(asset).downcase
159
- asset_plain = File.basename(asset, asset_ext)
157
+ asset_plain = File.basename(asset, asset_ext).to_url
160
158
 
161
159
  if image_types.include?(asset_ext)
162
160
  img = Magick::Image.read(asset).first
161
+ orig_w, orig_h = img.columns, img.rows
162
+
163
163
  img_normal = img.resize_to_fit(width, height)
164
- img_normal.write(File.join(file_path, asset_base))
164
+ img_normal.write(File.join(file_path, "#{asset_plain}#{asset_ext}"))
165
165
  img_normal = nil
166
166
 
167
- img_retina = img.resize_to_fit(width * 2, height * 2)
168
- retina_fname = File.join(file_path, "#{asset_plain}_2x#{asset_ext}")
169
- img_retina.write(retina_fname)
170
- img_retina = nil
167
+ if (@config["images"]["retina"] and (orig_w > width * 2) or (orig_h > height * 2))
168
+ img_retina = img.resize_to_fit(width * 2, height * 2)
169
+ retina_fname = File.join(file_path, "#{asset_plain}_2x#{asset_ext}")
170
+ img_retina.write(retina_fname)
171
+ img_retina = nil
172
+ end
171
173
 
172
174
  processed << File.join(asset_path, asset_base)
173
175
 
174
176
  if @config["plugins"].keys.include?("lightbox")
175
- post_io.puts "{% lightbox #{File.join(asset_path, asset_base)} %}"
177
+ post_io.puts "{% lightbox #{File.join(asset_path, "#{asset_plain}#{asset_ext}")} %}"
176
178
  else
177
- post_io.puts "{% image #{File.join("_originals", asset_path, asset_base)} %}"
179
+ post_io.puts "{% image #{File.join("_originals", asset_path, "#{asset_plain}#{asset_ext}")} %}"
178
180
  end
179
-
180
- puts "Asset generated: #{asset_base} (normal, retina)"
181
181
  end
182
182
  end
183
183
 
184
184
  post_io.close
185
185
  end
186
186
 
187
+ def clean
188
+ cleanup
189
+ FileUtils.rm_rf(Dir[File.join("attachments", "_thumbnails", "*")])
190
+ end
191
+
187
192
  private
188
193
  def find_post(post)
189
194
  if File.exists?(post)
@@ -193,7 +198,7 @@ module Alula
193
198
  else
194
199
  # Try to find by title
195
200
  title = post.to_url
196
- posts = Dir[File.join("posts", "*")].select { |p| p =~ /title/ }
201
+ posts = Dir[File.join("posts", "*")].select { |p| p =~ /#{title}/ }
197
202
  if posts.count == 1
198
203
  return posts.first
199
204
  end
@@ -222,13 +227,16 @@ module Alula
222
227
  FileUtils.mkdir_p File.join("_tmp", "_posts")
223
228
  FileUtils.cp_r Dir[File.join("posts", "*")], File.join("_tmp", "_posts")
224
229
 
230
+ # Copy pages
231
+ FileUtils.cp_r Dir[File.join("pages", "**", "*")], File.join("_tmp")
232
+
225
233
  FileUtils.mkdir_p File.join("_tmp", "assets")
226
234
  end
227
235
 
228
236
  def assetgen
229
237
  puts "==> Generating assets"
230
238
 
231
- width, height = @config["thumbnails"].split("x").collect {|i| i.to_i }
239
+ width, height = @config["images"]["thumbnails"].split("x").collect {|i| i.to_i }
232
240
 
233
241
  # Get all attachements
234
242
  originals_path = File.join("attachments", "_originals")
@@ -320,4 +328,12 @@ module Alula
320
328
  FileUtils.rm_rf "_tmp"
321
329
  end
322
330
  end
331
+
332
+ DEFAULTS = Jekyll::DEFAULTS.deep_merge({
333
+ 'source' => '_tmp',
334
+ 'destination' => 'public',
335
+ 'markdown' => 'kramdown',
336
+
337
+ 'pagination_dir' => '/page/',
338
+ })
323
339
  end
@@ -12,14 +12,17 @@ tagline: BLOG TAGLINE
12
12
  # Chosed theme
13
13
  theme: minimal
14
14
 
15
- # Thumbnail size (width x height)
16
- thumbnails: 300x300
15
+ # Options for image settings
16
+ images:
17
+ size: 800x600 # Resize photos to this size
18
+ thumbnails: 300x300 # # Thumbnail size (width x height)
19
+ retina: true # Generate photos for retina displays
17
20
 
18
21
  # Root URL, if you host blog in directory, fix this according
19
22
  root: /
20
23
 
21
24
  # Permalinks style
22
- permalinks: /:year/:month/:title
25
+ permalink: /:year/:month/:title
23
26
 
24
27
  # Posts per page on the blog index
25
28
  paginate: 10
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alula
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
5
- prerelease:
4
+ version: 0.2.0a
5
+ prerelease: 5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mikko Kokkonen
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-06 00:00:00.000000000 Z
12
+ date: 2012-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jekyll
16
- requirement: &70331726160920 !ruby/object:Gem::Requirement
16
+ requirement: &70182215769900 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.11.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70331726160920
24
+ version_requirements: *70182215769900
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sprockets
27
- requirement: &70331726160440 !ruby/object:Gem::Requirement
27
+ requirement: &70182215769320 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.4.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70331726160440
35
+ version_requirements: *70182215769320
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: thor
38
- requirement: &70331726176320 !ruby/object:Gem::Requirement
38
+ requirement: &70182215768740 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.14.6
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70331726176320
46
+ version_requirements: *70182215768740
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rmagick
49
- requirement: &70331726175840 !ruby/object:Gem::Requirement
49
+ requirement: &70182215784460 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.13.1
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70331726175840
57
+ version_requirements: *70182215784460
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: sass
60
- requirement: &70331726175360 !ruby/object:Gem::Requirement
60
+ requirement: &70182215783720 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 3.1.15
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70331726175360
68
+ version_requirements: *70182215783720
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: coffee-script
71
- requirement: &70331726174880 !ruby/object:Gem::Requirement
71
+ requirement: &70182215783040 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 2.2.0
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70331726174880
79
+ version_requirements: *70182215783040
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: uglifier
82
- requirement: &70331726174360 !ruby/object:Gem::Requirement
82
+ requirement: &70182215782320 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 1.2.4
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70331726174360
90
+ version_requirements: *70182215782320
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: front-compiler
93
- requirement: &70331726173900 !ruby/object:Gem::Requirement
93
+ requirement: &70182215781660 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 1.1.0
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70331726173900
101
+ version_requirements: *70182215781660
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: activesupport
104
- requirement: &70331726173440 !ruby/object:Gem::Requirement
104
+ requirement: &70182215780960 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 3.2.3
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *70331726173440
112
+ version_requirements: *70182215780960
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: stringex
115
- requirement: &70331726172960 !ruby/object:Gem::Requirement
115
+ requirement: &70182215780280 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: 1.3.2
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *70331726172960
123
+ version_requirements: *70182215780280
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: ruby-progressbar
126
- requirement: &70331726172460 !ruby/object:Gem::Requirement
126
+ requirement: &70182215779320 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ~>
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: 0.0.10
132
132
  type: :runtime
133
133
  prerelease: false
134
- version_requirements: *70331726172460
134
+ version_requirements: *70182215779320
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: version
137
- requirement: &70331726171940 !ruby/object:Gem::Requirement
137
+ requirement: &70182215778200 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ~>
@@ -142,18 +142,7 @@ dependencies:
142
142
  version: 1.0.0
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *70331726171940
146
- - !ruby/object:Gem::Dependency
147
- name: pry
148
- requirement: &70331726171460 !ruby/object:Gem::Requirement
149
- none: false
150
- requirements:
151
- - - ~>
152
- - !ruby/object:Gem::Version
153
- version: 0.9.8.4
154
- type: :development
155
- prerelease: false
156
- version_requirements: *70331726171460
145
+ version_requirements: *70182215778200
157
146
  description: Alula is a simple tool for creating fast, static blogs easily.
158
147
  email:
159
148
  - mikko@owlforestry.com
@@ -198,9 +187,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
198
187
  required_rubygems_version: !ruby/object:Gem::Requirement
199
188
  none: false
200
189
  requirements:
201
- - - ! '>='
190
+ - - ! '>'
202
191
  - !ruby/object:Gem::Version
203
- version: '0'
192
+ version: 1.3.1
204
193
  requirements: []
205
194
  rubyforge_project:
206
195
  rubygems_version: 1.8.17