middleman 0.13.2.pre → 0.14.0.pre2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -23,7 +23,7 @@ begin
23
23
  gem.add_dependency("sinatra-content-for")
24
24
  gem.add_dependency("rack-test")
25
25
  gem.add_dependency("yui-compressor")
26
- gem.add_dependency("haml", ">=3.0.0.beta.3")
26
+ gem.add_dependency("haml", ">=3.0.0.rc.1")
27
27
  gem.add_dependency("compass", ">=0.10.0.rc3")
28
28
  gem.add_dependency("fancy-buttons")
29
29
  gem.add_dependency("json_pure")
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.2.pre
1
+ 0.14.0.pre2
data/lib/middleman.rb CHANGED
@@ -2,4 +2,19 @@ libdir = File.dirname(__FILE__)
2
2
  $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
3
3
 
4
4
  require 'rubygems'
5
- require 'middleman/base'
5
+
6
+ module Middleman
7
+
8
+ module Rack
9
+ autoload :Sprockets, "middleman/rack/sprockets"
10
+ autoload :MinifyJavascript, "middleman/rack/minify_javascript"
11
+ autoload :MinifyCSS, "middleman/rack/minify_css"
12
+ end
13
+
14
+ autoload :Base, "middleman/base"
15
+ autoload :ERb, "middleman/erb"
16
+ autoload :Haml, "middleman/haml"
17
+ autoload :Sass, "middleman/sass"
18
+ autoload :Helpers, "middleman/helpers"
19
+
20
+ end
@@ -12,6 +12,7 @@ module Middleman
12
12
  set :app_file, __FILE__
13
13
  set :root, ENV["MM_DIR"] || Dir.pwd
14
14
  set :reload, false
15
+ set :sessions, false
15
16
  set :logging, false
16
17
  set :environment, ENV['MM_ENV'] || :development
17
18
  set :supported_formats, %w(erb)
@@ -23,7 +24,6 @@ module Middleman
23
24
  set :build_dir, "build"
24
25
  set :http_prefix, nil
25
26
 
26
- use ::Rack::ConditionalGet if environment == :development
27
27
  helpers Sinatra::ContentFor
28
28
 
29
29
  set :features, []
@@ -69,11 +69,8 @@ module Middleman
69
69
  # Base case renderer (do nothing), Should be over-ridden
70
70
  module StaticRender
71
71
  def render_path(path, layout)
72
- if template_exists?(path, :erb)
73
- erb(path.to_sym, :layout => layout)
74
- else
75
- false
76
- end
72
+ return false if !template_exists?(path, :erb)
73
+ erb(path.to_sym, :layout => layout)
77
74
  end
78
75
  end
79
76
  include StaticRender
@@ -95,11 +92,6 @@ module Middleman
95
92
  ensure
96
93
  @@layout = nil
97
94
  end
98
-
99
- # This will match all requests not overridden in the project's init.rb
100
- not_found do
101
- process_request
102
- end
103
95
 
104
96
  def self.enabled?(name)
105
97
  name = (name.to_s << "?").to_sym
@@ -110,6 +102,11 @@ module Middleman
110
102
  self.class.enabled?(name)
111
103
  end
112
104
 
105
+ # This will match all requests not overridden in the project's init.rb
106
+ not_found do
107
+ process_request
108
+ end
109
+
113
110
  private
114
111
  def process_request(layout = :layout)
115
112
  # Normalize the path and add index if we're looking at a directory
@@ -129,15 +126,10 @@ module Middleman
129
126
  end
130
127
  end
131
128
 
129
+ require "middleman/erb"
132
130
  # Haml is required & includes helpers
133
131
  require "middleman/haml"
134
132
  require "middleman/sass"
135
- require "middleman/helpers"
136
- require "middleman/rack/static"
137
- require "middleman/rack/sprockets"
138
- require "middleman/rack/minify_javascript"
139
- require "middleman/rack/minify_css"
140
- require "middleman/rack/downstream"
141
133
 
142
134
  class Middleman::Base
143
135
  helpers Middleman::Helpers
@@ -153,26 +145,21 @@ class Middleman::Base
153
145
  disable :automatic_image_sizes
154
146
  disable :relative_assets
155
147
  disable :cache_buster
148
+ disable :ugly_haml
156
149
 
157
150
  # Default build features
158
151
  configure :build do
159
152
  end
160
153
 
161
- # Check for and evaluate local configuration
162
- local_config = File.join(self.root, "init.rb")
163
- if File.exists? local_config
164
- puts "== Reading: Local config" if logging?
165
- Middleman::Base.class_eval File.read(local_config)
166
- set :app_file, File.expand_path(local_config)
167
- end
168
-
169
- use Middleman::Rack::Static
170
- use Middleman::Rack::Sprockets
171
- use Middleman::Rack::MinifyJavascript
172
- use Middleman::Rack::MinifyCSS
173
- use Middleman::Rack::Downstream
174
-
175
154
  def self.new(*args, &block)
155
+ # Check for and evaluate local configuration
156
+ local_config = File.join(self.root, "init.rb")
157
+ if File.exists? local_config
158
+ puts "== Reading: Local config" if logging?
159
+ Middleman::Base.class_eval File.read(local_config)
160
+ set :app_file, File.expand_path(local_config)
161
+ end
162
+
176
163
  # loop over enabled feature
177
164
  features.flatten.each do |feature_name|
178
165
  next unless send(:"#{feature_name}?")
@@ -184,6 +171,15 @@ class Middleman::Base
184
171
  end
185
172
  end
186
173
 
174
+ use ::Rack::ConditionalGet if environment == :development
175
+ use Middleman::Rack::MinifyJavascript if minify_javascript?
176
+ use Middleman::Rack::MinifyCSS if minify_css?
177
+
178
+ # Built-in javascript combination
179
+ use Middleman::Rack::Sprockets, :root => Middleman::Base.root,
180
+ :load_path => [ File.join("public", Middleman::Base.js_dir),
181
+ File.join("views", Middleman::Base.js_dir) ]
182
+
187
183
  @@afters.each { |block| class_eval(&block) }
188
184
 
189
185
  super
@@ -0,0 +1,24 @@
1
+ require "erb"
2
+
3
+ module Middleman
4
+ module ERb
5
+ module Renderer
6
+ def self.included(base)
7
+ base.supported_formats << "erb"
8
+ end
9
+
10
+ def render_path(path, layout)
11
+ if template_exists?(path, :erb)
12
+ layout = false if File.extname(path) == ".xml"
13
+ erb(path.to_sym, :layout => layout)
14
+ else
15
+ super
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ class Middleman::Base
23
+ include Middleman::ERb::Renderer
24
+ end
@@ -13,7 +13,7 @@ module Middleman
13
13
  result = nil
14
14
  begin
15
15
  layout = false if File.extname(path) == ".xml"
16
- result = haml(path.to_sym, :layout => layout)
16
+ result = haml(path.to_sym, :layout => layout, :ugly => Middleman::Base.enabled?(:ugly_haml))
17
17
  rescue ::Haml::Error => e
18
18
  result = "Haml Error: #{e}"
19
19
  result << "<pre>Backtrace: #{e.backtrace.join("\n")}</pre>"
@@ -10,19 +10,16 @@ class Middleman::Rack::MinifyCSS
10
10
  end
11
11
 
12
12
  def call(env)
13
- if Middleman::Base.enabled?(:minify_css) &&
14
- env["DOWNSTREAM"] && env["PATH_INFO"].match(/\.css$/)
15
-
13
+ status, headers, response = @app.call(env)
14
+
15
+ if Middleman::Base.enabled?(:minify_css) && env["PATH_INFO"].match(/\.css$/)
16
16
  compressor = ::YUI::CssCompressor.new
17
-
18
- source = env["DOWNSTREAM"][2].is_a?(::Rack::File) ?
19
- File.read(env["DOWNSTREAM"][2].path) :
20
- env["DOWNSTREAM"][2]
21
-
22
- env["DOWNSTREAM"][2] = compressor.compress(source)
23
- env["DOWNSTREAM"][1]["Content-Length"] = ::Rack::Utils.bytesize(env["DOWNSTREAM"][2]).to_s
17
+
18
+ uncompressed_source = response.is_a?(::Rack::File) ? File.read(response.path) : response
19
+ response = compressor.compress(uncompressed_source)
20
+ headers["Content-Length"] = ::Rack::Utils.bytesize(response).to_s
24
21
  end
25
22
 
26
- @app.call(env)
23
+ [status, headers, response]
27
24
  end
28
25
  end
@@ -10,19 +10,16 @@ class Middleman::Rack::MinifyJavascript
10
10
  end
11
11
 
12
12
  def call(env)
13
- if Middleman::Base.enabled?(:minify_javascript) &&
14
- env["DOWNSTREAM"] && env["PATH_INFO"].match(/\.js$/)
15
-
13
+ status, headers, response = @app.call(env)
14
+
15
+ if env["PATH_INFO"].match(/\.js$/)
16
16
  compressor = ::YUI::JavaScriptCompressor.new(:munge => true)
17
17
 
18
- source = env["DOWNSTREAM"][2].is_a?(::Rack::File) ?
19
- File.read(env["DOWNSTREAM"][2].path) :
20
- env["DOWNSTREAM"][2]
21
-
22
- env["DOWNSTREAM"][2] = compressor.compress(source)
23
- env["DOWNSTREAM"][1]["Content-Length"] = ::Rack::Utils.bytesize(env["DOWNSTREAM"][2]).to_s
18
+ uncompressed_source = response.is_a?(::Rack::File) ? File.read(response.path) : response
19
+ response = compressor.compress(uncompressed_source)
20
+ headers["Content-Length"] = ::Rack::Utils.bytesize(response).to_s
24
21
  end
25
22
 
26
- @app.call(env)
23
+ [status, headers, response]
27
24
  end
28
25
  end
@@ -1,34 +1,25 @@
1
- begin
2
- require 'sprockets'
3
- require 'middleman/rack/sprockets+ruby19' # Sprockets ruby 1.9 duckpunch
4
- rescue LoadError
5
- puts "Sprockets not available. Install it with: gem install sprockets"
6
- end
1
+ require 'sprockets'
7
2
 
8
3
  class Middleman::Rack::Sprockets
9
4
  def initialize(app, options={})
10
5
  @app = app
6
+ @options = options
11
7
  end
12
8
 
13
9
  def call(env)
14
- path = env["PATH_INFO"]
15
-
16
- if env["DOWNSTREAM"] && path.match(/\.js$/)
17
- source = "public" if File.exists?(File.join(Middleman::Base.views, path))
18
- source = "views" if File.exists?(File.join(Middleman::Base.views, path))
10
+ if env["PATH_INFO"].match(/\.js$/)
11
+ public_file_path = File.join(Middleman::Base.public, env["PATH_INFO"])
12
+ view_file_path = File.join(Middleman::Base.views, env["PATH_INFO"])
19
13
 
20
- if source
21
- source_file = env["DOWNSTREAM"][2].is_a?(::Rack::File) ?
22
- env["DOWNSTREAM"][2].path :
23
- env["DOWNSTREAM"][2]
14
+ source_file = Rack::File.new(Middleman::Base.public) if File.exists?(public_file_path)
15
+ source_file = Rack::File.new(Middleman::Base.views) if File.exists?(view_file_path)
24
16
 
25
- secretary = ::Sprockets::Secretary.new( :root => Middleman::Base.root,
26
- :source_files => [ source_file ],
27
- :load_path => [ File.join("public", Middleman::Base.js_dir),
28
- File.join("views", Middleman::Base.js_dir) ])
29
-
30
- env["DOWNSTREAM"][2] = secretary.concatenation.to_s
31
- env["DOWNSTREAM"][1]["Content-Length"] = ::Rack::Utils.bytesize(env["DOWNSTREAM"][2]).to_s
17
+ if source_file
18
+ status, headers, response = source_file.call(env)
19
+ secretary = ::Sprockets::Secretary.new(@options.merge( :source_files => [ response.path ] ))
20
+ response = secretary.concatenation.to_s
21
+ headers["Content-Length"] = ::Rack::Utils.bytesize(response).to_s
22
+ return [status, headers, response]
32
23
  end
33
24
  end
34
25
 
@@ -36,4 +27,35 @@ class Middleman::Rack::Sprockets
36
27
  end
37
28
  end
38
29
 
39
- Middleman::Base.supported_formats << "js"
30
+ Middleman::Base.supported_formats << "js"
31
+
32
+ # Sprockets ruby 1.9 duckpunch
33
+ module Sprockets
34
+ class SourceFile
35
+ def source_lines
36
+ @lines ||= begin
37
+ lines = []
38
+
39
+ comments = []
40
+ File.open(pathname.absolute_location, 'rb') do |file|
41
+ file.each do |line|
42
+ lines << line = SourceLine.new(self, line, file.lineno)
43
+
44
+ if line.begins_pdoc_comment? || comments.any?
45
+ comments << line
46
+ end
47
+
48
+ if line.ends_multiline_comment?
49
+ if line.ends_pdoc_comment?
50
+ comments.each { |l| l.comment! }
51
+ end
52
+ comments.clear
53
+ end
54
+ end
55
+ end
56
+
57
+ lines
58
+ end
59
+ end
60
+ end
61
+ end
@@ -9,7 +9,7 @@ rescue LoadError
9
9
  puts "YUI-Compressor not available. Install it with: gem install yui-compressor"
10
10
  end
11
11
 
12
- module Middleman::Sass
12
+ module Middleman::Sass
13
13
  def self.included(base)
14
14
  base.supported_formats << "sass"
15
15
  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.13.2.pre"
8
+ s.version = "0.14.0.pre2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Thomas Reynolds"]
12
- s.date = %q{2010-04-18}
12
+ s.date = %q{2010-04-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 = [
@@ -43,6 +43,7 @@ Gem::Specification.new do |s|
43
43
  "lib/middleman/base.rb",
44
44
  "lib/middleman/builder.rb",
45
45
  "lib/middleman/config.ru",
46
+ "lib/middleman/erb.rb",
46
47
  "lib/middleman/fastimage.rb",
47
48
  "lib/middleman/features/asset_host.rb",
48
49
  "lib/middleman/features/automatic_image_sizes.rb",
@@ -54,12 +55,9 @@ Gem::Specification.new do |s|
54
55
  "lib/middleman/features/smush_pngs.rb",
55
56
  "lib/middleman/haml.rb",
56
57
  "lib/middleman/helpers.rb",
57
- "lib/middleman/rack/downstream.rb",
58
58
  "lib/middleman/rack/minify_css.rb",
59
59
  "lib/middleman/rack/minify_javascript.rb",
60
- "lib/middleman/rack/sprockets+ruby19.rb",
61
60
  "lib/middleman/rack/sprockets.rb",
62
- "lib/middleman/rack/static.rb",
63
61
  "lib/middleman/sass.rb",
64
62
  "lib/middleman/template/init.rbt",
65
63
  "lib/middleman/template/views/index.html.haml",
@@ -124,7 +122,7 @@ Gem::Specification.new do |s|
124
122
  s.add_runtime_dependency(%q<sinatra-content-for>, [">= 0"])
125
123
  s.add_runtime_dependency(%q<rack-test>, [">= 0"])
126
124
  s.add_runtime_dependency(%q<yui-compressor>, [">= 0"])
127
- s.add_runtime_dependency(%q<haml>, [">= 3.0.0.beta.3"])
125
+ s.add_runtime_dependency(%q<haml>, [">= 3.0.0.rc.1"])
128
126
  s.add_runtime_dependency(%q<compass>, [">= 0.10.0.rc3"])
129
127
  s.add_runtime_dependency(%q<fancy-buttons>, [">= 0"])
130
128
  s.add_runtime_dependency(%q<json_pure>, [">= 0"])
@@ -143,7 +141,7 @@ Gem::Specification.new do |s|
143
141
  s.add_dependency(%q<sinatra-content-for>, [">= 0"])
144
142
  s.add_dependency(%q<rack-test>, [">= 0"])
145
143
  s.add_dependency(%q<yui-compressor>, [">= 0"])
146
- s.add_dependency(%q<haml>, [">= 3.0.0.beta.3"])
144
+ s.add_dependency(%q<haml>, [">= 3.0.0.rc.1"])
147
145
  s.add_dependency(%q<compass>, [">= 0.10.0.rc3"])
148
146
  s.add_dependency(%q<fancy-buttons>, [">= 0"])
149
147
  s.add_dependency(%q<json_pure>, [">= 0"])
@@ -163,7 +161,7 @@ Gem::Specification.new do |s|
163
161
  s.add_dependency(%q<sinatra-content-for>, [">= 0"])
164
162
  s.add_dependency(%q<rack-test>, [">= 0"])
165
163
  s.add_dependency(%q<yui-compressor>, [">= 0"])
166
- s.add_dependency(%q<haml>, [">= 3.0.0.beta.3"])
164
+ s.add_dependency(%q<haml>, [">= 3.0.0.rc.1"])
167
165
  s.add_dependency(%q<compass>, [">= 0.10.0.rc3"])
168
166
  s.add_dependency(%q<fancy-buttons>, [">= 0"])
169
167
  s.add_dependency(%q<json_pure>, [">= 0"])
metadata CHANGED
@@ -4,10 +4,10 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: true
5
5
  segments:
6
6
  - 0
7
- - 13
8
- - 2
9
- - pre
10
- version: 0.13.2.pre
7
+ - 14
8
+ - 0
9
+ - pre2
10
+ version: 0.14.0.pre2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Thomas Reynolds
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-04-18 00:00:00 -07:00
18
+ date: 2010-04-28 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -138,9 +138,9 @@ dependencies:
138
138
  - 3
139
139
  - 0
140
140
  - 0
141
- - beta
142
- - 3
143
- version: 3.0.0.beta.3
141
+ - rc
142
+ - 1
143
+ version: 3.0.0.rc.1
144
144
  type: :runtime
145
145
  version_requirements: *id010
146
146
  - !ruby/object:Gem::Dependency
@@ -280,6 +280,7 @@ files:
280
280
  - lib/middleman/base.rb
281
281
  - lib/middleman/builder.rb
282
282
  - lib/middleman/config.ru
283
+ - lib/middleman/erb.rb
283
284
  - lib/middleman/fastimage.rb
284
285
  - lib/middleman/features/asset_host.rb
285
286
  - lib/middleman/features/automatic_image_sizes.rb
@@ -291,12 +292,9 @@ files:
291
292
  - lib/middleman/features/smush_pngs.rb
292
293
  - lib/middleman/haml.rb
293
294
  - lib/middleman/helpers.rb
294
- - lib/middleman/rack/downstream.rb
295
295
  - lib/middleman/rack/minify_css.rb
296
296
  - lib/middleman/rack/minify_javascript.rb
297
- - lib/middleman/rack/sprockets+ruby19.rb
298
297
  - lib/middleman/rack/sprockets.rb
299
- - lib/middleman/rack/static.rb
300
298
  - lib/middleman/sass.rb
301
299
  - lib/middleman/template/init.rbt
302
300
  - lib/middleman/template/views/index.html.haml
@@ -1,9 +0,0 @@
1
- class Middleman::Rack::Downstream
2
- def initialize(app, options={})
3
- @app = app
4
- end
5
-
6
- def call(env)
7
- env["DOWNSTREAM"] || @app.call(env)
8
- end
9
- end
@@ -1,29 +0,0 @@
1
- module Sprockets
2
- class SourceFile
3
- def source_lines
4
- @lines ||= begin
5
- lines = []
6
-
7
- comments = []
8
- File.open(pathname.absolute_location, 'rb') do |file|
9
- file.each do |line|
10
- lines << line = SourceLine.new(self, line, file.lineno)
11
-
12
- if line.begins_pdoc_comment? || comments.any?
13
- comments << line
14
- end
15
-
16
- if line.ends_multiline_comment?
17
- if line.ends_pdoc_comment?
18
- comments.each { |l| l.comment! }
19
- end
20
- comments.clear
21
- end
22
- end
23
- end
24
-
25
- lines
26
- end
27
- end
28
- end
29
- end
@@ -1,18 +0,0 @@
1
- class Middleman::Rack::Static
2
- def initialize(app, options={})
3
- @app = app
4
- end
5
-
6
- def call(env)
7
- public_file_path = File.join(Middleman::Base.public, env["PATH_INFO"])
8
- view_file_path = File.join(Middleman::Base.views, env["PATH_INFO"])
9
-
10
- if File.exists?(public_file_path) && !File.directory?(public_file_path)
11
- env["DOWNSTREAM"] = ::Rack::File.new(Middleman::Base.public).call(env)
12
- elsif File.exists?(view_file_path) && !File.directory?(view_file_path)
13
- env["DOWNSTREAM"] = ::Rack::File.new(Middleman::Base.views).call(env)
14
- end
15
-
16
- @app.call(env)
17
- end
18
- end