middleman 0.10.5 → 0.10.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.5
1
+ 0.10.6
@@ -7,17 +7,33 @@ module Middleman
7
7
  end
8
8
 
9
9
  module Helpers
10
- def page_classes(*additional)
11
- path = request.path_info
10
+ def haml_partial(name, options = {})
11
+ haml name.to_sym, options.merge(:layout => false)
12
+ end
13
+
14
+ def auto_stylesheet_link_tag
15
+ path = request.path_info.dup
16
+ path << self.class.index_file if path.match(%r{/$})
17
+ path = path.gsub(%r{^/}, '')
18
+ path = path.gsub(File.extname(path), '')
19
+ path = path.gsub('/', '-')
20
+
21
+ css_file = File.join(File.basename(self.class.public), self.class.css_dir, "#{path}.css")
22
+ sass_file = File.join(File.basename(self.class.views), self.class.css_dir, "#{path}.css.sass")
23
+ if File.exists?(css_file) || File.exists?(sass_file)
24
+ stylesheet_link_tag "#{path}.css"
25
+ end
26
+ end
27
+
28
+ def page_classes
29
+ path = request.path_info.dup
12
30
  path << options.index_file if path.match(%r{/$})
13
- path.gsub!(%r{^/}, '')
31
+ path = path.gsub(%r{^/}, '')
14
32
 
15
33
  classes = []
16
34
  parts = path.split('.')[0].split('/')
17
35
  parts.each_with_index { |path, i| classes << parts.first(i+1).join('_') }
18
-
19
- classes << "index" if classes.empty?
20
- classes += additional unless additional.empty?
36
+
21
37
  classes.join(' ')
22
38
  end
23
39
 
@@ -4,6 +4,6 @@
4
4
  = stylesheet_link_tag "site.css"
5
5
  = yield_content :head
6
6
 
7
- %body
7
+ %body{ :class => page_classes }
8
8
  #frame
9
9
  = yield
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{middleman}
8
- s.version = "0.10.5"
8
+ s.version = "0.10.6"
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-11-02}
12
+ s.date = %q{2009-11-03}
13
13
  s.email = %q{tdreyno@gmail.com}
14
14
  s.executables = ["mm-init", "mm-build", "mm-server"]
15
15
  s.extra_rdoc_files = [
@@ -73,6 +73,7 @@ Gem::Specification.new do |s|
73
73
  "spec/fixtures/sample/views/stylesheets/relative_assets.css.sass",
74
74
  "spec/fixtures/sample/views/stylesheets/site.css.sass",
75
75
  "spec/generator_spec.rb",
76
+ "spec/minify_javascript_spec.rb",
76
77
  "spec/relative_assets_spec.rb",
77
78
  "spec/spec_helper.rb"
78
79
  ]
@@ -88,6 +89,7 @@ Gem::Specification.new do |s|
88
89
  "spec/cache_buster_spec.rb",
89
90
  "spec/fixtures/sample/init.rb",
90
91
  "spec/generator_spec.rb",
92
+ "spec/minify_javascript_spec.rb",
91
93
  "spec/relative_assets_spec.rb",
92
94
  "spec/spec_helper.rb"
93
95
  ]
@@ -49,10 +49,6 @@ describe "Builder" do
49
49
  it "should not build partial files" do
50
50
  File.exists?("#{@root_dir}/build/_partial.html").should be_false
51
51
  end
52
-
53
- it "should minify inline javascript" do
54
- File.readlines("#{@root_dir}/build/inline-js.html").length.should == 9
55
- end
56
52
 
57
53
  it "should combine javascript" do
58
54
  File.read("#{@root_dir}/build/javascripts/empty-with-include.js").should include("combo")
@@ -1 +1,4 @@
1
- # enable :maruku
1
+ # enable :maruku
2
+ get "/inline-js.html" do
3
+ haml :"inline-js.html", :layout => false
4
+ end
@@ -0,0 +1,21 @@
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 "Minify Javascript Feature" do
8
+ it "should not minify inline js if off" do
9
+ base.disable :minify_javascript
10
+ browser = Rack::Test::Session.new(Rack::MockSession.new(base.new))
11
+ browser.get("/inline-js.html")
12
+ browser.last_response.body.chomp.split($/).length.should == 10
13
+ end
14
+
15
+ it "should minify inline js if on" do
16
+ base.enable :minify_javascript
17
+ browser = Rack::Test::Session.new(Rack::MockSession.new(base.new))
18
+ browser.get("/inline-js.html")
19
+ browser.last_response.body.chomp.split($/).length.should == 1
20
+ end
21
+ end
@@ -11,9 +11,7 @@ describe "Relative Assets Feature" do
11
11
  browser.get("/stylesheets/relative_assets.css")
12
12
  browser.last_response.body.should_not include("../")
13
13
  end
14
- end
15
-
16
- describe "Relative Assets Feature" do
14
+
17
15
  it "should contain ../ if on" do
18
16
  base.enable :relative_assets
19
17
  browser = Rack::Test::Session.new(Rack::MockSession.new(base.new))
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.10.5
4
+ version: 0.10.6
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-11-02 00:00:00 -08:00
12
+ date: 2009-11-03 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -200,6 +200,7 @@ files:
200
200
  - spec/fixtures/sample/views/stylesheets/relative_assets.css.sass
201
201
  - spec/fixtures/sample/views/stylesheets/site.css.sass
202
202
  - spec/generator_spec.rb
203
+ - spec/minify_javascript_spec.rb
203
204
  - spec/relative_assets_spec.rb
204
205
  - spec/spec_helper.rb
205
206
  has_rdoc: true
@@ -236,5 +237,6 @@ test_files:
236
237
  - spec/cache_buster_spec.rb
237
238
  - spec/fixtures/sample/init.rb
238
239
  - spec/generator_spec.rb
240
+ - spec/minify_javascript_spec.rb
239
241
  - spec/relative_assets_spec.rb
240
242
  - spec/spec_helper.rb