tdreyno-middleman 0.3.4 → 0.3.7
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/VERSION +1 -1
- data/lib/middleman/helpers.rb +39 -0
- data/lib/middleman.rb +19 -12
- data/middleman.gemspec +5 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.7
|
data/lib/middleman/helpers.rb
CHANGED
@@ -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
|
data/lib/middleman.rb
CHANGED
@@ -69,26 +69,33 @@ 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
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
result = if renderer == "sass"
|
85
|
-
content_type 'text/css', :charset => 'utf-8'
|
86
|
-
sass(@template, Compass.sass_engine_options)
|
87
|
-
else
|
88
|
-
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)
|
89
95
|
end
|
90
|
-
|
91
|
-
|
96
|
+
rescue Haml::Error => e
|
97
|
+
result = "Haml Error: #{e}"
|
98
|
+
#result << "<pre>Backtrace: #{e.backtrace.join("\n")}</pre>"
|
92
99
|
end
|
93
100
|
|
94
101
|
result || pass
|
data/middleman.gemspec
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
1
4
|
# -*- encoding: utf-8 -*-
|
2
5
|
|
3
6
|
Gem::Specification.new do |s|
|
4
7
|
s.name = %q{middleman}
|
5
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.7"
|
6
9
|
|
7
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
11
|
s.authors = ["Thomas Reynolds"]
|
9
|
-
s.date = %q{2009-08-
|
12
|
+
s.date = %q{2009-08-09}
|
10
13
|
s.email = %q{tdreyno@gmail.com}
|
11
14
|
s.executables = ["mm-init", "mm-build", "mm-server"]
|
12
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdreyno-middleman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
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-
|
12
|
+
date: 2009-08-09 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|