middleman 0.3.5 → 0.3.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.3.5
1
+ 0.3.6
@@ -69,73 +69,37 @@ class Middleman < Sinatra::Base
69
69
  Compass.configure_sass_plugin!
70
70
  end
71
71
 
72
+ # CSS files
73
+ get %r{/(.*).css} do |path|
74
+ content_type 'text/css', :charset => 'utf-8'
75
+ begin
76
+ sass(path.to_sym, Compass.sass_engine_options)
77
+ rescue Exception => e
78
+ sass_exception_string(e)
79
+ end
80
+ end
81
+
72
82
  get /(.*)/ do |path|
73
83
  path << "index.html" if path.match(%r{/$})
74
84
  path.gsub!(%r{^/}, '')
85
+
75
86
  @template = path.gsub(File.extname(path), '').to_sym
76
87
  @full_request_path = path
77
88
 
78
89
  result = nil
79
-
80
- %w(haml erb builder maruku mab sass).each do |renderer|
81
- next if !File.exists?(File.join(options.views, "#{@template}.#{renderer}"))
82
-
83
- renderer = "markaby" if renderer == "mab"
84
- result = if renderer == "sass"
85
- content_type 'text/css', :charset => 'utf-8'
86
- begin
87
- sass(@template, Compass.sass_engine_options)
88
- rescue Exception => e
89
- sass_exception_string(e)
90
- end
91
- else
92
- send(renderer.to_sym, @template)
90
+ begin
91
+ %w(haml erb builder maruku mab).detect do |renderer|
92
+ next false if !File.exists?(File.join(options.views, "#{@template}.#{renderer}"))
93
+ renderer = "markaby" if renderer == "mab"
94
+ result = send(renderer.to_sym, @template)
93
95
  end
94
-
95
- break
96
+ rescue Haml::Error => e
97
+ result = "Haml Error: #{e}"
98
+ #result << "<pre>Backtrace: #{e.backtrace.join("\n")}</pre>"
96
99
  end
97
100
 
98
101
  result || pass
99
102
  end
100
-
101
- # Handle Sass errors
102
- def sass_exception_string(e)
103
- e_string = "#{e.class}: #{e.message}"
104
-
105
- if e.is_a? Sass::SyntaxError
106
- e_string << "\non line #{e.sass_line}"
107
-
108
- if e.sass_filename
109
- e_string << " of #{e.sass_filename}"
110
-
111
- if File.exists?(e.sass_filename)
112
- e_string << "\n\n"
113
-
114
- min = [e.sass_line - 5, 0].max
115
- begin
116
- File.read(e.sass_filename).rstrip.split("\n")[
117
- min .. e.sass_line + 5
118
- ].each_with_index do |line, i|
119
- e_string << "#{min + i + 1}: #{line}\n"
120
- end
121
- rescue
122
- e_string << "Couldn't read sass file: #{e.sass_filename}"
123
- end
124
- end
125
- end
126
- end
127
- <<END
128
- /*
129
- #{e_string}
130
-
131
- Backtrace:\n#{e.backtrace.join("\n")}
132
- */
133
- body:before {
134
- white-space: pre;
135
- font-family: monospace;
136
- content: "#{e_string.gsub('"', '\"').gsub("\n", '\\A ')}"; }
137
- END
138
- end
139
103
  end
140
104
 
141
105
  require File.join(File.dirname(__FILE__), 'middleman', 'helpers')
@@ -50,4 +50,43 @@ def stylesheet_link_tag(path, options={})
50
50
  capture_haml do
51
51
  haml_tag :link, options.merge(:href => asset_url(path), :type => "text/css")
52
52
  end
53
+ end
54
+
55
+ # Handle Sass errors
56
+ def sass_exception_string(e)
57
+ e_string = "#{e.class}: #{e.message}"
58
+
59
+ if e.is_a? Sass::SyntaxError
60
+ e_string << "\non line #{e.sass_line}"
61
+
62
+ if e.sass_filename
63
+ e_string << " of #{e.sass_filename}"
64
+
65
+ if File.exists?(e.sass_filename)
66
+ e_string << "\n\n"
67
+
68
+ min = [e.sass_line - 5, 0].max
69
+ begin
70
+ File.read(e.sass_filename).rstrip.split("\n")[
71
+ min .. e.sass_line + 5
72
+ ].each_with_index do |line, i|
73
+ e_string << "#{min + i + 1}: #{line}\n"
74
+ end
75
+ rescue
76
+ e_string << "Couldn't read sass file: #{e.sass_filename}"
77
+ end
78
+ end
79
+ end
80
+ end
81
+ <<END
82
+ /*
83
+ #{e_string}
84
+
85
+ Backtrace:\n#{e.backtrace.join("\n")}
86
+ */
87
+ body:before {
88
+ white-space: pre;
89
+ font-family: monospace;
90
+ content: "#{e_string.gsub('"', '\"').gsub("\n", '\\A ')}"; }
91
+ END
53
92
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{middleman}
8
- s.version = "0.3.5"
8
+ s.version = "0.3.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-08-08}
12
+ s.date = %q{2009-08-09}
13
13
  s.email = %q{tdreyno@gmail.com}
14
14
  s.executables = ["mm-init", "mm-build", "mm-server"]
15
15
  s.extra_rdoc_files = [
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.3.5
4
+ version: 0.3.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-08-08 00:00:00 -07:00
12
+ date: 2009-08-09 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency