middleman 0.9.20 → 0.9.21
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/middleman/base.rb +18 -14
- data/lib/middleman/fastimage.rb +282 -0
- data/lib/middleman/features/automatic_image_sizes.rb +29 -0
- data/lib/middleman/features/cache_buster.rb +2 -1
- data/lib/middleman/features/minify_css.rb +2 -6
- data/lib/middleman/features/minify_javascript.rb +2 -1
- data/lib/middleman/features/sprockets.rb +5 -0
- data/lib/middleman/sass.rb +40 -2
- data/middleman.gemspec +11 -4
- data/spec/auto_image_sizes.rb +23 -0
- data/spec/builder_spec.rb +1 -1
- data/spec/cache_buster_spec.rb +7 -4
- data/spec/fixtures/sample/init.rb +1 -1
- data/spec/fixtures/sample/public/images/blank.gif +0 -0
- data/spec/fixtures/sample/views/auto-image-sizes.html.haml +1 -0
- data/spec/fixtures/sample/views/stylesheets/relative_assets.css.sass +3 -0
- data/spec/relative_assets_spec.rb +23 -28
- metadata +10 -3
- data/lib/middleman/features/compass.rb +0 -18
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.21
|
data/lib/middleman/base.rb
CHANGED
@@ -33,6 +33,11 @@ module Middleman
|
|
33
33
|
super
|
34
34
|
end
|
35
35
|
|
36
|
+
@@afters = []
|
37
|
+
def self.after(&block)
|
38
|
+
@@afters << block
|
39
|
+
end
|
40
|
+
|
36
41
|
# Rack helper for adding mime-types during local preview
|
37
42
|
def self.mime(ext, type)
|
38
43
|
ext = ".#{ext}" unless ext.to_s[0] == ?.
|
@@ -80,10 +85,10 @@ end
|
|
80
85
|
# Haml is required & includes helpers
|
81
86
|
require "middleman/haml"
|
82
87
|
require "middleman/sass"
|
83
|
-
require
|
84
|
-
require
|
85
|
-
require
|
86
|
-
require
|
88
|
+
require "sinatra/content_for"
|
89
|
+
require "middleman/helpers"
|
90
|
+
require "middleman/rack/static"
|
91
|
+
require "middleman/rack/sprockets"
|
87
92
|
|
88
93
|
class Middleman::Base
|
89
94
|
helpers Sinatra::ContentFor
|
@@ -92,10 +97,6 @@ class Middleman::Base
|
|
92
97
|
use Middleman::Rack::Static
|
93
98
|
use Middleman::Rack::Sprockets
|
94
99
|
|
95
|
-
enable :compass
|
96
|
-
require "middleman/features/compass"
|
97
|
-
@@features -= [:compass]
|
98
|
-
|
99
100
|
# Features disabled by default
|
100
101
|
disable :slickmap
|
101
102
|
disable :cache_buster
|
@@ -104,6 +105,7 @@ class Middleman::Base
|
|
104
105
|
disable :relative_assets
|
105
106
|
disable :maruku
|
106
107
|
disable :smush_pngs
|
108
|
+
disable :automatic_image_sizes
|
107
109
|
|
108
110
|
# Default build features
|
109
111
|
configure :build do
|
@@ -118,19 +120,21 @@ class Middleman::Base
|
|
118
120
|
if File.exists? local_config
|
119
121
|
puts "== Reading: Local config" if logging?
|
120
122
|
class_eval File.read(local_config)
|
123
|
+
set :app_file, File.expand_path(local_config)
|
121
124
|
end
|
122
125
|
|
123
126
|
# loop over enabled feature
|
124
127
|
@@features.flatten.each do |feature_name|
|
125
128
|
next unless send(:"#{feature_name}?")
|
126
|
-
|
127
|
-
|
129
|
+
|
130
|
+
feature_path = "features/#{feature_name}"
|
131
|
+
if File.exists? File.join(File.dirname(__FILE__), "#{feature_path}.rb")
|
132
|
+
puts "== Enabling: #{feature_name.to_s.capitalize}" if logging?
|
133
|
+
require "middleman/#{feature_path}"
|
134
|
+
end
|
128
135
|
end
|
129
136
|
|
130
|
-
|
131
|
-
config.http_images_path = self.http_images_path rescue File.join(self.http_prefix, self.images_dir)
|
132
|
-
config.http_stylesheets_path = self.http_css_path rescue File.join(self.http_prefix, self.css_dir)
|
133
|
-
end
|
137
|
+
@@afters.each { |block| class_eval(&block) }
|
134
138
|
|
135
139
|
super
|
136
140
|
end
|
@@ -0,0 +1,282 @@
|
|
1
|
+
# FastImage finds the size or type of an image given its uri.
|
2
|
+
# It is careful to only fetch and parse as much of the image as is needed to determine the result.
|
3
|
+
# It does this by using a feature of Net::HTTP that yields strings from the resource being fetched
|
4
|
+
# as soon as the packets arrive.
|
5
|
+
#
|
6
|
+
# No external libraries such as ImageMagick are used here, this is a very lightweight solution to
|
7
|
+
# finding image information.
|
8
|
+
#
|
9
|
+
# FastImage knows about GIF, JPEG, BMP and PNG files.
|
10
|
+
#
|
11
|
+
# FastImage can also read files from the local filesystem by supplying the path instead of a uri.
|
12
|
+
# In this case FastImage uses the open-uri library to read the file in chunks of 256 bytes until
|
13
|
+
# it has enough. This is possibly a useful bandwidth-saving feature if the file is on a network
|
14
|
+
# attached disk rather than truly local.
|
15
|
+
#
|
16
|
+
# === Examples
|
17
|
+
# require 'fastimage'
|
18
|
+
#
|
19
|
+
# FastImage.size("http://stephensykes.com/images/ss.com_x.gif")
|
20
|
+
# => [266, 56]
|
21
|
+
# FastImage.type("http://stephensykes.com/images/pngimage")
|
22
|
+
# => :png
|
23
|
+
# FastImage.type("/some/local/file.gif")
|
24
|
+
# => :gif
|
25
|
+
#
|
26
|
+
# === References
|
27
|
+
# * http://snippets.dzone.com/posts/show/805
|
28
|
+
# * http://www.anttikupila.com/flash/getting-jpg-dimensions-with-as3-without-loading-the-entire-file/
|
29
|
+
# * http://pennysmalls.com/2008/08/19/find-jpeg-dimensions-fast-in-ruby/
|
30
|
+
# * http://imagesize.rubyforge.org/
|
31
|
+
#
|
32
|
+
require 'net/https'
|
33
|
+
require 'open-uri'
|
34
|
+
|
35
|
+
module Middleman
|
36
|
+
class FastImage
|
37
|
+
attr_reader :size, :type
|
38
|
+
|
39
|
+
class FastImageException < StandardError # :nodoc:
|
40
|
+
end
|
41
|
+
class MoreCharsNeeded < FastImageException # :nodoc:
|
42
|
+
end
|
43
|
+
class UnknownImageType < FastImageException # :nodoc:
|
44
|
+
end
|
45
|
+
class ImageFetchFailure < FastImageException # :nodoc:
|
46
|
+
end
|
47
|
+
class SizeNotFound < FastImageException # :nodoc:
|
48
|
+
end
|
49
|
+
|
50
|
+
DefaultTimeout = 2
|
51
|
+
|
52
|
+
LocalFileChunkSize = 256
|
53
|
+
|
54
|
+
# Returns an array containing the width and height of the image.
|
55
|
+
# It will return nil if the image could not be fetched, or if the image type was not recognised.
|
56
|
+
#
|
57
|
+
# By default there is a timeout of 2 seconds for opening and reading from a remote server.
|
58
|
+
# This can be changed by passing a :timeout => number_of_seconds in the options.
|
59
|
+
#
|
60
|
+
# If you wish FastImage to raise if it cannot size the image for any reason, then pass
|
61
|
+
# :raise_on_failure => true in the options.
|
62
|
+
#
|
63
|
+
# FastImage knows about GIF, JPEG, BMP and PNG files.
|
64
|
+
#
|
65
|
+
# === Example
|
66
|
+
#
|
67
|
+
# require 'fastimage'
|
68
|
+
#
|
69
|
+
# FastImage.size("http://stephensykes.com/images/ss.com_x.gif")
|
70
|
+
# => [266, 56]
|
71
|
+
# FastImage.size("http://stephensykes.com/images/pngimage")
|
72
|
+
# => [16, 16]
|
73
|
+
# FastImage.size("http://farm4.static.flickr.com/3023/3047236863_9dce98b836.jpg")
|
74
|
+
# => [500, 375]
|
75
|
+
# FastImage.size("http://www-ece.rice.edu/~wakin/images/lena512.bmp")
|
76
|
+
# => [512, 512]
|
77
|
+
# FastImage.size("test/fixtures/test.jpg")
|
78
|
+
# => [882, 470]
|
79
|
+
# FastImage.size("http://pennysmalls.com/does_not_exist")
|
80
|
+
# => nil
|
81
|
+
# FastImage.size("http://pennysmalls.com/does_not_exist", :raise_on_failure=>true)
|
82
|
+
# => raises FastImage::ImageFetchFailure
|
83
|
+
# FastImage.size("http://stephensykes.com/favicon.ico", :raise_on_failure=>true)
|
84
|
+
# => raises FastImage::UnknownImageType
|
85
|
+
# FastImage.size("http://stephensykes.com/favicon.ico", :raise_on_failure=>true, :timeout=>0.01)
|
86
|
+
# => raises FastImage::ImageFetchFailure
|
87
|
+
# FastImage.size("http://stephensykes.com/images/faulty.jpg", :raise_on_failure=>true)
|
88
|
+
# => raises FastImage::SizeNotFound
|
89
|
+
#
|
90
|
+
# === Supported options
|
91
|
+
# [:timeout]
|
92
|
+
# Overrides the default timeout of 2 seconds. Applies both to reading from and opening the http connection.
|
93
|
+
# [:raise_on_failure]
|
94
|
+
# If set to true causes an exception to be raised if the image size cannot be found for any reason.
|
95
|
+
#
|
96
|
+
def self.size(uri, options={})
|
97
|
+
new(uri, options).size
|
98
|
+
end
|
99
|
+
|
100
|
+
# Returns an symbol indicating the image type fetched from a uri.
|
101
|
+
# It will return nil if the image could not be fetched, or if the image type was not recognised.
|
102
|
+
#
|
103
|
+
# By default there is a timeout of 2 seconds for opening and reading from a remote server.
|
104
|
+
# This can be changed by passing a :timeout => number_of_seconds in the options.
|
105
|
+
#
|
106
|
+
# If you wish FastImage to raise if it cannot find the type of the image for any reason, then pass
|
107
|
+
# :raise_on_failure => true in the options.
|
108
|
+
#
|
109
|
+
# === Example
|
110
|
+
#
|
111
|
+
# require 'fastimage'
|
112
|
+
#
|
113
|
+
# FastImage.type("http://stephensykes.com/images/ss.com_x.gif")
|
114
|
+
# => :gif
|
115
|
+
# FastImage.type("http://stephensykes.com/images/pngimage")
|
116
|
+
# => :png
|
117
|
+
# FastImage.type("http://farm4.static.flickr.com/3023/3047236863_9dce98b836.jpg")
|
118
|
+
# => :jpeg
|
119
|
+
# FastImage.type("http://www-ece.rice.edu/~wakin/images/lena512.bmp")
|
120
|
+
# => :bmp
|
121
|
+
# FastImage.type("test/fixtures/test.jpg")
|
122
|
+
# => :jpeg
|
123
|
+
# FastImage.type("http://pennysmalls.com/does_not_exist")
|
124
|
+
# => nil
|
125
|
+
#
|
126
|
+
# === Supported options
|
127
|
+
# [:timeout]
|
128
|
+
# Overrides the default timeout of 2 seconds. Applies both to reading from and opening the http connection.
|
129
|
+
# [:raise_on_failure]
|
130
|
+
# If set to true causes an exception to be raised if the image type cannot be found for any reason.
|
131
|
+
#
|
132
|
+
def self.type(uri, options={})
|
133
|
+
new(uri, options.merge(:type_only=>true)).type
|
134
|
+
end
|
135
|
+
|
136
|
+
def initialize(uri, options={})
|
137
|
+
@property = options[:type_only] ? :type : :size
|
138
|
+
@timeout = options[:timeout] || DefaultTimeout
|
139
|
+
@uri = uri
|
140
|
+
@parsed_uri = URI.parse(uri.gsub(/\s/, "%20"))
|
141
|
+
if @parsed_uri.scheme == "http" || @parsed_uri.scheme == "https"
|
142
|
+
fetch_using_http
|
143
|
+
else
|
144
|
+
fetch_using_open_uri
|
145
|
+
end
|
146
|
+
raise SizeNotFound if options[:raise_on_failure] && @property == :size && !@size
|
147
|
+
rescue Timeout::Error, SocketError, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNRESET, ImageFetchFailure
|
148
|
+
raise ImageFetchFailure if options[:raise_on_failure]
|
149
|
+
rescue Errno::ENOENT
|
150
|
+
raise ImageFetchFailure if options[:raise_on_failure]
|
151
|
+
rescue UnknownImageType
|
152
|
+
raise UnknownImageType if options[:raise_on_failure]
|
153
|
+
end
|
154
|
+
|
155
|
+
private
|
156
|
+
|
157
|
+
def fetch_using_http
|
158
|
+
setup_http
|
159
|
+
@http.request_get(@parsed_uri.request_uri) do |res|
|
160
|
+
raise ImageFetchFailure unless res.is_a?(Net::HTTPSuccess)
|
161
|
+
res.read_body do |str|
|
162
|
+
break if parse_packet(str)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def setup_http
|
168
|
+
@http = Net::HTTP.new(@parsed_uri.host, @parsed_uri.port)
|
169
|
+
@http.use_ssl = (@parsed_uri.scheme == "https")
|
170
|
+
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
171
|
+
@http.open_timeout = @timeout
|
172
|
+
@http.read_timeout = @timeout
|
173
|
+
end
|
174
|
+
|
175
|
+
def fetch_using_open_uri
|
176
|
+
open(@uri) do |s|
|
177
|
+
while str = s.read(LocalFileChunkSize)
|
178
|
+
break if parse_packet(str)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
# returns true once result is achieved
|
184
|
+
#
|
185
|
+
def parse_packet(str)
|
186
|
+
@str = (@unused_str || "") + str
|
187
|
+
@strpos = 0
|
188
|
+
begin
|
189
|
+
result = send("parse_#{@property}")
|
190
|
+
if result
|
191
|
+
instance_variable_set("@#{@property}", result)
|
192
|
+
true
|
193
|
+
end
|
194
|
+
rescue MoreCharsNeeded
|
195
|
+
false
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def parse_size
|
200
|
+
@type = parse_type unless @type
|
201
|
+
send("parse_size_for_#{@type}")
|
202
|
+
end
|
203
|
+
|
204
|
+
def get_chars(n)
|
205
|
+
if @strpos + n - 1 >= @str.size
|
206
|
+
@unused_str = @str[@strpos..-1]
|
207
|
+
raise MoreCharsNeeded
|
208
|
+
else
|
209
|
+
result = @str[@strpos..(@strpos + n - 1)]
|
210
|
+
@strpos += n
|
211
|
+
result
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def get_byte
|
216
|
+
get_chars(1).unpack("C")[0]
|
217
|
+
end
|
218
|
+
|
219
|
+
def read_int(str)
|
220
|
+
size_bytes = str.unpack("CC")
|
221
|
+
(size_bytes[0] << 8) + size_bytes[1]
|
222
|
+
end
|
223
|
+
|
224
|
+
def parse_type
|
225
|
+
case get_chars(2)
|
226
|
+
when "BM"
|
227
|
+
:bmp
|
228
|
+
when "GI"
|
229
|
+
:gif
|
230
|
+
when 0xff.chr + 0xd8.chr
|
231
|
+
:jpeg
|
232
|
+
when 0x89.chr + "P"
|
233
|
+
:png
|
234
|
+
else
|
235
|
+
raise UnknownImageType
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
def parse_size_for_gif
|
240
|
+
get_chars(9)[4..8].unpack('SS')
|
241
|
+
end
|
242
|
+
|
243
|
+
def parse_size_for_png
|
244
|
+
get_chars(23)[14..22].unpack('NN')
|
245
|
+
end
|
246
|
+
|
247
|
+
def parse_size_for_jpeg
|
248
|
+
loop do
|
249
|
+
@state = case @state
|
250
|
+
when nil
|
251
|
+
get_chars(2)
|
252
|
+
:started
|
253
|
+
when :started
|
254
|
+
get_byte == 0xFF ? :sof : :started
|
255
|
+
when :sof
|
256
|
+
c = get_byte
|
257
|
+
if (0xe0..0xef).include?(c)
|
258
|
+
:skipframe
|
259
|
+
elsif [0xC0..0xC3, 0xC5..0xC7, 0xC9..0xCB, 0xCD..0xCF].detect {|r| r.include? c}
|
260
|
+
:readsize
|
261
|
+
else
|
262
|
+
:skipframe
|
263
|
+
end
|
264
|
+
when :skipframe
|
265
|
+
@skip_chars = read_int(get_chars(2)) - 2
|
266
|
+
:do_skip
|
267
|
+
when :do_skip
|
268
|
+
get_chars(@skip_chars)
|
269
|
+
:started
|
270
|
+
when :readsize
|
271
|
+
s = get_chars(7)
|
272
|
+
return [read_int(s[5..6]), read_int(s[3..4])]
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
def parse_size_for_bmp
|
278
|
+
d = get_chars(27)[12..26]
|
279
|
+
d[0] == 40 ? d[4..-1].unpack('LL') : d[4..8].unpack('SS')
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "middleman/fastimage"
|
2
|
+
|
3
|
+
class Middleman::Base
|
4
|
+
alias_method :pre_automatic_image_tag, :image_tag
|
5
|
+
helpers do
|
6
|
+
def image_tag(path, params={})
|
7
|
+
if (!params[:width] || !params[:height]) && !path.include?("://")
|
8
|
+
params[:alt] ||= ""
|
9
|
+
prefix = options.http_images_path rescue options.images_dir
|
10
|
+
|
11
|
+
begin
|
12
|
+
real_path = File.join(options.public, asset_url(path, prefix))
|
13
|
+
if File.exists? real_path
|
14
|
+
dimensions = Middleman::FastImage.size(real_path, :raise_on_failure => true)
|
15
|
+
params[:width] ||= dimensions[0]
|
16
|
+
params[:height] ||= dimensions[1]
|
17
|
+
end
|
18
|
+
rescue
|
19
|
+
end
|
20
|
+
|
21
|
+
params = params.merge(:src => asset_url(path, prefix))
|
22
|
+
params = params.map { |k,v| %Q{#{k}="#{v}"}}.join(' ')
|
23
|
+
"<img #{params} />"
|
24
|
+
else
|
25
|
+
pre_automatic_image_tag(path, params)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
|
-
class << Middleman::Base
|
1
|
+
class << Middleman::Base
|
2
2
|
alias_method :pre_cache_buster_asset_url, :asset_url
|
3
3
|
def asset_url(path, prefix="", request=nil)
|
4
4
|
http_path = pre_cache_buster_asset_url(path, prefix, request)
|
5
|
+
|
5
6
|
if http_path.include?("://") || !%w(.css .png .jpg .js .gif).include?(File.extname(http_path))
|
6
7
|
http_path
|
7
8
|
else
|
@@ -1,9 +1,5 @@
|
|
1
1
|
# Otherwise use YUI
|
2
2
|
# Fine a way to minify inline/css
|
3
|
-
|
4
|
-
|
5
|
-
::Compass.configuration do |config|
|
6
|
-
config.output_style = :compressed
|
7
|
-
end
|
8
|
-
end
|
3
|
+
::Compass.configuration do |config|
|
4
|
+
config.output_style = :compressed
|
9
5
|
end
|
data/lib/middleman/sass.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "sass"
|
2
|
-
require
|
2
|
+
require "compass"
|
3
3
|
|
4
4
|
module Middleman
|
5
5
|
module Sass
|
@@ -13,7 +13,7 @@ module Middleman
|
|
13
13
|
static_version = options.public + request.path_info
|
14
14
|
send_file(static_version) if File.exists? static_version
|
15
15
|
|
16
|
-
location_of_sass_file = options.environment == "build" ?
|
16
|
+
location_of_sass_file = options.environment == "build" ? options.build_dir : options.public
|
17
17
|
css_filename = File.join(Dir.pwd, location_of_sass_file) + request.path_info
|
18
18
|
sass(path.to_sym, ::Compass.sass_engine_options.merge({ :css_filename => css_filename }))
|
19
19
|
rescue Exception => e
|
@@ -67,4 +67,42 @@ end
|
|
67
67
|
|
68
68
|
class Middleman::Base
|
69
69
|
include Middleman::Sass
|
70
|
+
|
71
|
+
after do
|
72
|
+
::Compass.configuration do |config|
|
73
|
+
config.project_path = self.root
|
74
|
+
config.sass_dir = File.join(File.basename(self.views), self.css_dir)
|
75
|
+
config.output_style = :nested
|
76
|
+
config.css_dir = File.join(File.basename(self.public), self.css_dir)
|
77
|
+
config.images_dir = File.join(File.basename(self.public), self.images_dir)
|
78
|
+
|
79
|
+
config.add_import_path(config.sass_dir)
|
80
|
+
|
81
|
+
config.http_images_path = self.http_images_path rescue File.join(self.http_prefix, self.images_dir)
|
82
|
+
config.http_stylesheets_path = self.http_css_path rescue File.join(self.http_prefix, self.css_dir)
|
83
|
+
|
84
|
+
if self.cache_buster?
|
85
|
+
config.asset_cache_buster do |path, real_path|
|
86
|
+
if File.readable?(real_path)
|
87
|
+
File.mtime(real_path).strftime("%s")
|
88
|
+
else
|
89
|
+
$stderr.puts "WARNING: '#{File.basename(path)}' was not found (or cannot be read) in #{File.dirname(real_path)}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
else
|
93
|
+
config.asset_cache_buster do
|
94
|
+
false
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
configure :build do
|
100
|
+
::Compass.configuration do |config|
|
101
|
+
config.css_dir = File.join(File.basename(self.build_dir), self.css_dir)
|
102
|
+
config.images_dir = File.join(File.basename(self.build_dir), self.images_dir)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
::Compass.configure_sass_plugin!
|
107
|
+
end
|
70
108
|
end
|
data/middleman.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{middleman}
|
8
|
-
s.version = "0.9.
|
8
|
+
s.version = "0.9.21"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Thomas Reynolds"]
|
12
|
-
s.date = %q{2009-10-
|
12
|
+
s.date = %q{2009-10-28}
|
13
13
|
s.email = %q{tdreyno@gmail.com}
|
14
14
|
s.executables = ["mm-init", "mm-build", "mm-server"]
|
15
15
|
s.extra_rdoc_files = [
|
@@ -31,8 +31,9 @@ Gem::Specification.new do |s|
|
|
31
31
|
"lib/middleman/base.rb",
|
32
32
|
"lib/middleman/builder.rb",
|
33
33
|
"lib/middleman/config.ru",
|
34
|
+
"lib/middleman/fastimage.rb",
|
35
|
+
"lib/middleman/features/automatic_image_sizes.rb",
|
34
36
|
"lib/middleman/features/cache_buster.rb",
|
35
|
-
"lib/middleman/features/compass.rb",
|
36
37
|
"lib/middleman/features/growl.rb",
|
37
38
|
"lib/middleman/features/maruku.rb",
|
38
39
|
"lib/middleman/features/minify_css.rb",
|
@@ -40,6 +41,7 @@ Gem::Specification.new do |s|
|
|
40
41
|
"lib/middleman/features/relative_assets.rb",
|
41
42
|
"lib/middleman/features/slickmap.rb",
|
42
43
|
"lib/middleman/features/smush_pngs.rb",
|
44
|
+
"lib/middleman/features/sprockets.rb",
|
43
45
|
"lib/middleman/haml.rb",
|
44
46
|
"lib/middleman/helpers.rb",
|
45
47
|
"lib/middleman/rack/sprockets+ruby19.rb",
|
@@ -52,19 +54,23 @@ Gem::Specification.new do |s|
|
|
52
54
|
"lib/middleman/template/views/stylesheets/site.css.sass",
|
53
55
|
"lib/middleman/templater+dynamic_renderer.rb",
|
54
56
|
"middleman.gemspec",
|
57
|
+
"spec/auto_image_sizes.rb",
|
55
58
|
"spec/builder_spec.rb",
|
56
59
|
"spec/cache_buster_spec.rb",
|
57
60
|
"spec/fixtures/sample/init.rb",
|
61
|
+
"spec/fixtures/sample/public/images/blank.gif",
|
58
62
|
"spec/fixtures/sample/public/javascripts/to-be-included.js",
|
59
63
|
"spec/fixtures/sample/public/static.html",
|
60
64
|
"spec/fixtures/sample/public/stylesheets/static.css",
|
61
65
|
"spec/fixtures/sample/views/_partial.haml",
|
66
|
+
"spec/fixtures/sample/views/auto-image-sizes.html.haml",
|
62
67
|
"spec/fixtures/sample/views/index.html.haml",
|
63
68
|
"spec/fixtures/sample/views/inline-js.html.haml",
|
64
69
|
"spec/fixtures/sample/views/javascripts/empty-with-include.js",
|
65
70
|
"spec/fixtures/sample/views/layout.haml",
|
66
71
|
"spec/fixtures/sample/views/maruku.html.maruku",
|
67
72
|
"spec/fixtures/sample/views/services/index.html.haml",
|
73
|
+
"spec/fixtures/sample/views/stylesheets/relative_assets.css.sass",
|
68
74
|
"spec/fixtures/sample/views/stylesheets/site.css.sass",
|
69
75
|
"spec/generator_spec.rb",
|
70
76
|
"spec/relative_assets_spec.rb",
|
@@ -77,7 +83,8 @@ Gem::Specification.new do |s|
|
|
77
83
|
s.rubygems_version = %q{1.3.5}
|
78
84
|
s.summary = %q{A static site generator utilizing Haml, Sass and providing YUI compression and cache busting}
|
79
85
|
s.test_files = [
|
80
|
-
"spec/
|
86
|
+
"spec/auto_image_sizes.rb",
|
87
|
+
"spec/builder_spec.rb",
|
81
88
|
"spec/cache_buster_spec.rb",
|
82
89
|
"spec/fixtures/sample/init.rb",
|
83
90
|
"spec/generator_spec.rb",
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rack/test'
|
2
|
+
require File.join(File.dirname(__FILE__), "spec_helper")
|
3
|
+
|
4
|
+
base = ::Middleman::Base
|
5
|
+
base.set :root, File.join(File.dirname(__FILE__), "fixtures", "sample")
|
6
|
+
|
7
|
+
describe "Auto Image sizes Feature" do
|
8
|
+
it "should not append width and height if off" do
|
9
|
+
base.disable :automatic_image_sizes
|
10
|
+
browser = Rack::Test::Session.new(Rack::MockSession.new(base.new))
|
11
|
+
browser.get("/auto-image-sizes.html")
|
12
|
+
browser.last_response.body.should_not include("width=")
|
13
|
+
browser.last_response.body.should_not include("height=")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should append width and height if off" do
|
17
|
+
base.enable :automatic_image_sizes
|
18
|
+
browser = Rack::Test::Session.new(Rack::MockSession.new(base.new))
|
19
|
+
browser.get("/auto-image-sizes.html")
|
20
|
+
browser.last_response.body.should include("width=")
|
21
|
+
browser.last_response.body.should include("height=")
|
22
|
+
end
|
23
|
+
end
|
data/spec/builder_spec.rb
CHANGED
@@ -39,7 +39,7 @@ describe "Builder" do
|
|
39
39
|
|
40
40
|
it "should build sass files" do
|
41
41
|
File.exists?("#{@root_dir}/build/stylesheets/site.css").should be_true
|
42
|
-
File.read("#{@root_dir}/build/stylesheets/site.css").should include("html,body,div,span,applet,object,iframe")
|
42
|
+
File.read("#{@root_dir}/build/stylesheets/site.css").gsub(/\s/, "").should include("html,body,div,span,applet,object,iframe")
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should build static css files" do
|
data/spec/cache_buster_spec.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'rack/test'
|
1
2
|
require File.join(File.dirname(__FILE__), "spec_helper")
|
2
3
|
|
3
4
|
base = ::Middleman::Base
|
@@ -6,13 +7,15 @@ base.set :root, File.join(File.dirname(__FILE__), "fixtures", "sample")
|
|
6
7
|
describe "Cache Buster Feature" do
|
7
8
|
it "should not append query string if off" do
|
8
9
|
base.disable :cache_buster
|
9
|
-
base.new
|
10
|
-
|
10
|
+
browser = Rack::Test::Session.new(Rack::MockSession.new(base.new))
|
11
|
+
browser.get("/stylesheets/relative_assets.css")
|
12
|
+
browser.last_response.body.should_not include("?")
|
11
13
|
end
|
12
14
|
|
13
15
|
it "should append query string if on" do
|
14
16
|
base.enable :cache_buster
|
15
|
-
base.new
|
16
|
-
|
17
|
+
browser = Rack::Test::Session.new(Rack::MockSession.new(base.new))
|
18
|
+
browser.get("/stylesheets/relative_assets.css")
|
19
|
+
browser.last_response.body.should include("?")
|
17
20
|
end
|
18
21
|
end
|
@@ -1 +1 @@
|
|
1
|
-
enable :maruku
|
1
|
+
# enable :maruku
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
= image_tag "blank.gif"
|
@@ -1,28 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
#
|
25
|
-
# it "should contain ../ if on" do
|
26
|
-
# @app.asset_url("stylesheets/static.css").should include("?")
|
27
|
-
# end
|
28
|
-
# end
|
1
|
+
require 'rack/test'
|
2
|
+
require File.join(File.dirname(__FILE__), "spec_helper")
|
3
|
+
|
4
|
+
base = ::Middleman::Base
|
5
|
+
base.set :root, File.join(File.dirname(__FILE__), "fixtures", "sample")
|
6
|
+
|
7
|
+
describe "Relative Assets Feature" do
|
8
|
+
it "should not contain ../ if off" do
|
9
|
+
base.disable :relative_assets
|
10
|
+
browser = Rack::Test::Session.new(Rack::MockSession.new(base.new))
|
11
|
+
browser.get("/stylesheets/relative_assets.css")
|
12
|
+
browser.last_response.body.should_not include("../")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "Relative Assets Feature" do
|
17
|
+
it "should contain ../ if on" do
|
18
|
+
base.enable :relative_assets
|
19
|
+
browser = Rack::Test::Session.new(Rack::MockSession.new(base.new))
|
20
|
+
browser.get("/stylesheets/relative_assets.css")
|
21
|
+
browser.last_response.body.should include("../")
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Reynolds
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-28 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -158,8 +158,9 @@ files:
|
|
158
158
|
- lib/middleman/base.rb
|
159
159
|
- lib/middleman/builder.rb
|
160
160
|
- lib/middleman/config.ru
|
161
|
+
- lib/middleman/fastimage.rb
|
162
|
+
- lib/middleman/features/automatic_image_sizes.rb
|
161
163
|
- lib/middleman/features/cache_buster.rb
|
162
|
-
- lib/middleman/features/compass.rb
|
163
164
|
- lib/middleman/features/growl.rb
|
164
165
|
- lib/middleman/features/maruku.rb
|
165
166
|
- lib/middleman/features/minify_css.rb
|
@@ -167,6 +168,7 @@ files:
|
|
167
168
|
- lib/middleman/features/relative_assets.rb
|
168
169
|
- lib/middleman/features/slickmap.rb
|
169
170
|
- lib/middleman/features/smush_pngs.rb
|
171
|
+
- lib/middleman/features/sprockets.rb
|
170
172
|
- lib/middleman/haml.rb
|
171
173
|
- lib/middleman/helpers.rb
|
172
174
|
- lib/middleman/rack/sprockets+ruby19.rb
|
@@ -179,19 +181,23 @@ files:
|
|
179
181
|
- lib/middleman/template/views/stylesheets/site.css.sass
|
180
182
|
- lib/middleman/templater+dynamic_renderer.rb
|
181
183
|
- middleman.gemspec
|
184
|
+
- spec/auto_image_sizes.rb
|
182
185
|
- spec/builder_spec.rb
|
183
186
|
- spec/cache_buster_spec.rb
|
184
187
|
- spec/fixtures/sample/init.rb
|
188
|
+
- spec/fixtures/sample/public/images/blank.gif
|
185
189
|
- spec/fixtures/sample/public/javascripts/to-be-included.js
|
186
190
|
- spec/fixtures/sample/public/static.html
|
187
191
|
- spec/fixtures/sample/public/stylesheets/static.css
|
188
192
|
- spec/fixtures/sample/views/_partial.haml
|
193
|
+
- spec/fixtures/sample/views/auto-image-sizes.html.haml
|
189
194
|
- spec/fixtures/sample/views/index.html.haml
|
190
195
|
- spec/fixtures/sample/views/inline-js.html.haml
|
191
196
|
- spec/fixtures/sample/views/javascripts/empty-with-include.js
|
192
197
|
- spec/fixtures/sample/views/layout.haml
|
193
198
|
- spec/fixtures/sample/views/maruku.html.maruku
|
194
199
|
- spec/fixtures/sample/views/services/index.html.haml
|
200
|
+
- spec/fixtures/sample/views/stylesheets/relative_assets.css.sass
|
195
201
|
- spec/fixtures/sample/views/stylesheets/site.css.sass
|
196
202
|
- spec/generator_spec.rb
|
197
203
|
- spec/relative_assets_spec.rb
|
@@ -225,6 +231,7 @@ signing_key:
|
|
225
231
|
specification_version: 3
|
226
232
|
summary: A static site generator utilizing Haml, Sass and providing YUI compression and cache busting
|
227
233
|
test_files:
|
234
|
+
- spec/auto_image_sizes.rb
|
228
235
|
- spec/builder_spec.rb
|
229
236
|
- spec/cache_buster_spec.rb
|
230
237
|
- spec/fixtures/sample/init.rb
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class Middleman::Base
|
2
|
-
configure do
|
3
|
-
::Compass.configuration do |config|
|
4
|
-
images_location = (self.environment == "build") ? self.build_dir : self.public
|
5
|
-
|
6
|
-
config.project_path = Dir.pwd
|
7
|
-
config.sass_dir = File.join(File.basename(self.views), self.css_dir)
|
8
|
-
config.output_style = :nested
|
9
|
-
config.css_dir = File.join(File.basename(images_location), self.css_dir)
|
10
|
-
config.images_dir = File.join(File.basename(images_location), self.images_dir)
|
11
|
-
# File.expand_path(self.images_dir, self.public)
|
12
|
-
|
13
|
-
config.add_import_path(config.sass_dir)
|
14
|
-
end
|
15
|
-
|
16
|
-
::Compass.configure_sass_plugin!
|
17
|
-
end
|
18
|
-
end
|