middleman-more 3.0.0.rc.4 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -32,25 +32,25 @@ module Middleman
|
|
32
32
|
def image_tag(path, params={})
|
33
33
|
if !params.has_key?(:width) && !params.has_key?(:height) && !path.include?("://")
|
34
34
|
params[:alt] ||= ""
|
35
|
-
http_prefix = http_images_path rescue images_dir
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
params[:
|
36
|
+
real_path = path
|
37
|
+
real_path = File.join(images_dir, real_path) unless real_path =~ %r{^/}
|
38
|
+
full_path = File.join(source_dir, real_path)
|
39
|
+
|
40
|
+
if File.exists? full_path
|
41
|
+
begin
|
42
|
+
width, height = ::FastImage.size(full_path, :raise_on_failure => true)
|
43
|
+
params[:width] = width
|
44
|
+
params[:height] = height
|
45
|
+
rescue
|
46
|
+
warn "Couldn't determine dimensions for image #{path}: #{$!.message}"
|
45
47
|
end
|
46
|
-
rescue
|
47
|
-
# $stderr.puts params.inspect
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
super(path, params)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
56
|
-
end
|
56
|
+
end
|
@@ -19,14 +19,18 @@ module Middleman::Extensions
|
|
19
19
|
class << self
|
20
20
|
def registered(app, options={})
|
21
21
|
exts = options[:exts] || %w(.js .css .html .htm)
|
22
|
-
|
23
|
-
app.send :include, InstanceMethods
|
24
22
|
|
25
23
|
app.after_build do |builder|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
|
25
|
+
paths = ::Middleman::Util.all_files_under(self.class.inst.build_dir)
|
26
|
+
paths.each do |path|
|
27
|
+
next unless exts.include? path.extname
|
28
|
+
|
29
|
+
output_filename, old_size, new_size = Middleman::Extensions::Gzip.gzip_file(path.to_s)
|
30
|
+
|
31
|
+
if output_filename
|
32
|
+
size_change_word = (old_size - new_size) > 0 ? 'smaller' : 'larger'
|
33
|
+
builder.say_status :gzip, "#{output_filename} (#{number_to_human_size((old_size - new_size).abs)} #{size_change_word})"
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|
@@ -35,37 +39,33 @@ module Middleman::Extensions
|
|
35
39
|
alias :included :registered
|
36
40
|
end
|
37
41
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
input_file_time = File.mtime(path)
|
43
|
-
|
44
|
-
# Check if the right file's already there
|
45
|
-
if File.exist?(output_filename) && File.mtime(output_filename) == input_file_time
|
46
|
-
return
|
47
|
-
end
|
48
|
-
|
49
|
-
File.open(output_filename, 'w') do |f|
|
50
|
-
gz = Zlib::GzipWriter.new(f, Zlib::BEST_COMPRESSION)
|
51
|
-
gz.mtime = input_file_time.to_i
|
52
|
-
gz.write input_file
|
53
|
-
gz.close
|
54
|
-
end
|
42
|
+
def self.gzip_file(path)
|
43
|
+
input_file = File.open(path, 'r').read
|
44
|
+
output_filename = path + '.gz'
|
45
|
+
input_file_time = File.mtime(path)
|
55
46
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
File.utime(File.atime(output_filename), input_file_time, output_filename)
|
47
|
+
# Check if the right file's already there
|
48
|
+
if File.exist?(output_filename) && File.mtime(output_filename) == input_file_time
|
49
|
+
return
|
50
|
+
end
|
61
51
|
|
62
|
-
|
63
|
-
|
52
|
+
File.open(output_filename, 'w') do |f|
|
53
|
+
gz = Zlib::GzipWriter.new(f, Zlib::BEST_COMPRESSION)
|
54
|
+
gz.mtime = input_file_time.to_i
|
55
|
+
gz.write input_file
|
56
|
+
gz.close
|
57
|
+
end
|
64
58
|
|
65
|
-
|
59
|
+
# Make the file times match, both for Nginx's gzip_static extension
|
60
|
+
# and so we can ID existing files. Also, so even if the GZ files are
|
61
|
+
# wiped out by build --clean and recreated, we won't rsync them over
|
62
|
+
# again because they'll end up with the same mtime.
|
63
|
+
File.utime(File.atime(output_filename), input_file_time, output_filename)
|
66
64
|
|
67
|
-
|
68
|
-
|
65
|
+
old_size = File.size(path)
|
66
|
+
new_size = File.size(output_filename)
|
67
|
+
|
68
|
+
[output_filename, old_size, new_size]
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
data/middleman-more.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_dependency("compass", [">= 0.12.2"])
|
25
25
|
s.add_dependency("coffee-script", ["~> 2.2.0"])
|
26
26
|
s.add_dependency("coffee-script-source", ["~> 1.3.3"])
|
27
|
-
s.add_dependency("execjs", ["~> 1.
|
27
|
+
s.add_dependency("execjs", ["~> 1.4.0"])
|
28
28
|
s.add_dependency("maruku", ["~> 0.6.0"])
|
29
29
|
s.add_dependency("i18n", ["~> 0.6.0"])
|
30
30
|
s.add_dependency("padrino-helpers", ["0.10.7"])
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-more
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0
|
5
|
-
prerelease:
|
4
|
+
version: 3.0.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Thomas Reynolds
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-07-
|
13
|
+
date: 2012-07-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: middleman-core
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - '='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 3.0.0
|
22
|
+
version: 3.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
requirements:
|
28
28
|
- - '='
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: 3.0.0
|
30
|
+
version: 3.0.0
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
32
|
name: uglifier
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,7 +131,7 @@ dependencies:
|
|
131
131
|
requirements:
|
132
132
|
- - ~>
|
133
133
|
- !ruby/object:Gem::Version
|
134
|
-
version: 1.
|
134
|
+
version: 1.4.0
|
135
135
|
type: :runtime
|
136
136
|
prerelease: false
|
137
137
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -139,7 +139,7 @@ dependencies:
|
|
139
139
|
requirements:
|
140
140
|
- - ~>
|
141
141
|
- !ruby/object:Gem::Version
|
142
|
-
version: 1.
|
142
|
+
version: 1.4.0
|
143
143
|
- !ruby/object:Gem::Dependency
|
144
144
|
name: maruku
|
145
145
|
requirement: !ruby/object:Gem::Requirement
|
@@ -604,16 +604,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
604
604
|
version: '0'
|
605
605
|
segments:
|
606
606
|
- 0
|
607
|
-
hash:
|
607
|
+
hash: -34936377537429209
|
608
608
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
609
609
|
none: false
|
610
610
|
requirements:
|
611
|
-
- - ! '
|
611
|
+
- - ! '>='
|
612
612
|
- !ruby/object:Gem::Version
|
613
|
-
version:
|
613
|
+
version: '0'
|
614
|
+
segments:
|
615
|
+
- 0
|
616
|
+
hash: -34936377537429209
|
614
617
|
requirements: []
|
615
618
|
rubyforge_project:
|
616
|
-
rubygems_version: 1.8.
|
619
|
+
rubygems_version: 1.8.24
|
617
620
|
signing_key:
|
618
621
|
specification_version: 3
|
619
622
|
summary: Hand-crafted frontend development
|