ace 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1 -0
- data/ace.gemspec +0 -1
- data/lib/ace/filters/image_thumbnailer.rb +41 -19
- data/lib/ace/version.rb +1 -1
- data/project_generator/content/Gemfile +1 -0
- data/project_generator/content/boot.rb +2 -4
- metadata +6 -4
data/CHANGELOG
CHANGED
data/ace.gemspec
CHANGED
@@ -11,7 +11,6 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "http://github.com/botanicus/ace"
|
12
12
|
s.summary = "Ace is highly flexible static pages generator with template inheritance."
|
13
13
|
s.description = "" # TODO: long description
|
14
|
-
s.cert_chain = nil
|
15
14
|
s.email = Base64.decode64("c3Rhc3RueUAxMDFpZGVhcy5jeg==\n")
|
16
15
|
s.has_rdoc = true
|
17
16
|
|
@@ -3,37 +3,59 @@
|
|
3
3
|
require "ace/filters"
|
4
4
|
require "nokogiri"
|
5
5
|
|
6
|
+
# <thumbnail src="assets/img/motivation-sheet.jpg" />
|
7
|
+
# <thumbnail src="assets/img/motivation-sheet.jpg" size="550" />
|
8
|
+
# <thumbnail src="assets/img/motivation-sheet.jpg" size="550x20" />
|
9
|
+
|
10
|
+
# TODO:
|
11
|
+
# class Post < Ace::Item
|
12
|
+
# before Ace::ImageThumbnailerFilter, default_thumb_size: 550
|
13
|
+
# end
|
6
14
|
module Ace
|
7
15
|
class ImageThumbnailerFilter < Filter
|
8
|
-
def
|
9
|
-
|
16
|
+
def thumb_path(file_name)
|
17
|
+
@file_name ||= file_name
|
18
|
+
@thumb_path ||= file_name.gsub(/\.([^\.]*)$/, '_thumb.\1')
|
19
|
+
end
|
20
|
+
|
21
|
+
def thumb_server_path
|
22
|
+
@thumb_path.sub("content", "")
|
10
23
|
end
|
11
24
|
|
12
|
-
def
|
13
|
-
|
14
|
-
img = Nokogiri::XML::Node.new 'img', doc
|
15
|
-
a.set_attribute('href', filename)
|
16
|
-
img.set_attribute('src', thumb_name(filename))
|
17
|
-
img.parent = a
|
18
|
-
a
|
25
|
+
def original_image_server_path
|
26
|
+
@file_name.sub("content", "")
|
19
27
|
end
|
20
|
-
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
28
|
+
|
29
|
+
def thumbnail_nodeset(file_name, doc)
|
30
|
+
link = Nokogiri::XML::Node.new("a", doc)
|
31
|
+
image = Nokogiri::XML::Node.new("img", doc)
|
32
|
+
link.set_attribute("href", original_image_server_path)
|
33
|
+
image.set_attribute("src", thumb_server_path)
|
34
|
+
image.parent = link
|
35
|
+
return link
|
27
36
|
end
|
28
37
|
|
29
38
|
def call(item, content)
|
30
|
-
puts item.
|
39
|
+
puts "~ [THUMB] #{item.original_path}"
|
31
40
|
doc = Nokogiri::HTML(content)
|
32
41
|
doc.css("thumbnail").each do |thumb|
|
33
|
-
|
34
|
-
|
42
|
+
original_file = "content/#{thumb[:src]}"
|
43
|
+
generate_thumbnail(original_file, thumb[:size] || 550)
|
44
|
+
thumb.replace(thumbnail_nodeset(original_file, doc))
|
35
45
|
end
|
36
46
|
doc.to_s
|
37
47
|
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def generate_thumbnail(file_name, size)
|
51
|
+
unless File.exist?(thumb_path(file_name))
|
52
|
+
command = "convert #{file_name} -resize #{size} #{thumb_path(file_name)}"
|
53
|
+
warn "~ $ #{command}"
|
54
|
+
system(command)
|
55
|
+
raise "Error when converting image '#{file_name}'" if $?.to_i != 0
|
56
|
+
else
|
57
|
+
warn "~ File #{thumb_path(file_name)} already exists."
|
58
|
+
end
|
59
|
+
end
|
38
60
|
end
|
39
61
|
end
|
data/lib/ace/version.rb
CHANGED
@@ -8,10 +8,8 @@ Encoding.default_external = "utf-8"
|
|
8
8
|
require "bundler/setup"
|
9
9
|
|
10
10
|
# Custom setup.
|
11
|
-
require "pupu/adapters/ace"
|
12
|
-
Pupu.media_prefix = "/assets"
|
13
|
-
|
14
|
-
require "helpers"
|
11
|
+
# require "pupu/adapters/ace"
|
12
|
+
# Pupu.media_prefix = "/assets"
|
15
13
|
|
16
14
|
# Load the app.
|
17
15
|
Dir["app/**/*.rb"].each do |file|
|
metadata
CHANGED
@@ -2,14 +2,15 @@
|
|
2
2
|
name: ace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.4.
|
5
|
+
version: 0.4.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- "Jakub \xC5\xA0\xC5\xA5astn\xC3\xBD aka Botanicus"
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
|
-
cert_chain:
|
12
|
-
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-06-30 00:00:00 +02:00
|
13
14
|
default_executable: ace
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
@@ -121,7 +122,8 @@ has_rdoc: true
|
|
121
122
|
homepage: http://github.com/botanicus/ace
|
122
123
|
licenses: []
|
123
124
|
|
124
|
-
post_install_message: "[\e[32mVersion 0.4\e[0m] Added project generator (ace-gen).\n
|
125
|
+
post_install_message: "[\e[32mVersion 0.4\e[0m] Added project generator (ace-gen).\n\
|
126
|
+
[\e[32mVersion 0.4\e[0m] Fixed filter for image thumbnails.\n"
|
125
127
|
rdoc_options: []
|
126
128
|
|
127
129
|
require_paths:
|