middleman 2.0.0.beta5 → 2.0.0.beta6
Sign up to get free protection for your applications and to get access to all the features.
- data/features/scss-support.feature +5 -0
- data/fixtures/test-app/source/stylesheets/layout.css.sass +2 -0
- data/lib/middleman.rb +2 -0
- data/lib/middleman/builder.rb +3 -5
- data/lib/middleman/features/blog.rb +79 -29
- data/lib/middleman/features/front_matter.rb +3 -24
- data/lib/middleman/renderers/coffee_script.rb +12 -0
- data/lib/middleman/renderers/markdown.rb +12 -0
- data/lib/middleman/server.rb +8 -2
- data/lib/middleman/version.rb +1 -1
- metadata +6 -2
@@ -4,4 +4,9 @@ Feature: Support SCSS Syntax
|
|
4
4
|
Scenario: Rendering scss
|
5
5
|
Given the Server is running
|
6
6
|
When I go to "/stylesheets/site_scss.css"
|
7
|
+
Then I should see "html"
|
8
|
+
|
9
|
+
Scenario: Rendering scss
|
10
|
+
Given the Server is running
|
11
|
+
When I go to "/stylesheets/layout.css"
|
7
12
|
Then I should see "html"
|
data/lib/middleman.rb
CHANGED
@@ -68,6 +68,8 @@ module Middleman
|
|
68
68
|
autoload :Haml, "middleman/renderers/haml"
|
69
69
|
autoload :Sass, "middleman/renderers/sass"
|
70
70
|
autoload :Slim, "middleman/renderers/slim"
|
71
|
+
autoload :Markdown, "middleman/renderers/markdown"
|
72
|
+
autoload :CoffeeScript, "middleman/renderers/coffee_script"
|
71
73
|
end
|
72
74
|
|
73
75
|
# Features API
|
data/lib/middleman/builder.rb
CHANGED
@@ -85,10 +85,8 @@ module Middleman
|
|
85
85
|
lookup = File.join(lookup, '*')
|
86
86
|
|
87
87
|
results = Dir[lookup].sort do |a, b|
|
88
|
-
simple_a = a.gsub(Middleman::Server.root + "/", '')
|
89
|
-
|
90
|
-
simple_b = b.gsub(Middleman::Server.root + "/", '')
|
91
|
-
.gsub(Middleman::Server.views + "/", '')
|
88
|
+
simple_a = a.gsub(Middleman::Server.root + "/", '').gsub(Middleman::Server.views + "/", '')
|
89
|
+
simple_b = b.gsub(Middleman::Server.root + "/", '').gsub(Middleman::Server.views + "/", '')
|
92
90
|
|
93
91
|
a_dir = simple_a.split("/").first
|
94
92
|
b_dir = simple_b.split("/").first
|
@@ -108,7 +106,7 @@ module Middleman
|
|
108
106
|
next
|
109
107
|
end
|
110
108
|
|
111
|
-
next if file_source.include?('layout')
|
109
|
+
next if file_source.include?('layout') && !file_source.include?('.css')
|
112
110
|
|
113
111
|
# Skip partials prefixed with an underscore
|
114
112
|
next unless file_source.gsub(Middleman::Server.root, '').split('/').select { |p| p[0,1] == '_' }.empty?
|
@@ -4,23 +4,27 @@ module Middleman
|
|
4
4
|
module Features
|
5
5
|
module Blog
|
6
6
|
class << self
|
7
|
-
def registered(app)
|
7
|
+
def registered(app)
|
8
8
|
# Include helpers
|
9
9
|
app.helpers Middleman::Features::Blog::Helpers
|
10
|
-
|
10
|
+
|
11
11
|
app.after_feature_init do
|
12
12
|
if !app.settings.respond_to? :blog_permalink
|
13
13
|
app.set :blog_permalink, "/:year/:month/:day/:title.html"
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
|
+
if !app.settings.respond_to? :blog_taglink
|
17
|
+
app.set :blog_taglink, "/tags/:tag.html"
|
18
|
+
end
|
19
|
+
|
16
20
|
if !app.settings.respond_to? :blog_layout
|
17
21
|
app.set :blog_layout, "layout"
|
18
22
|
end
|
19
|
-
|
23
|
+
|
20
24
|
if !app.settings.respond_to? :blog_summary_separator
|
21
25
|
app.set :blog_summary_separator, /READMORE/
|
22
26
|
end
|
23
|
-
|
27
|
+
|
24
28
|
if !app.settings.respond_to? :blog_summary_length
|
25
29
|
app.set :blog_summary_length, 250
|
26
30
|
end
|
@@ -32,44 +36,60 @@ module Middleman
|
|
32
36
|
if !app.settings.respond_to? :blog_index_template
|
33
37
|
app.set :blog_index_template, "index_template"
|
34
38
|
end
|
35
|
-
|
39
|
+
|
36
40
|
if !app.settings.respond_to? :blog_article_template
|
37
41
|
app.set :blog_article_template, "article_template"
|
38
42
|
end
|
39
|
-
|
43
|
+
|
40
44
|
$stderr.puts "== Blog: #{app.settings.blog_permalink}"
|
41
|
-
|
45
|
+
|
42
46
|
articles_glob = File.join(app.views, app.settings.blog_permalink.gsub(/(:\w+)/, "*") + ".*")
|
43
|
-
|
47
|
+
|
44
48
|
articles = Dir[articles_glob].map do |article|
|
45
49
|
template_content = File.read(article)
|
46
50
|
data, content = parse_front_matter(template_content)
|
47
51
|
data["date"] = Date.parse(data["date"])
|
48
|
-
|
52
|
+
|
49
53
|
yaml_regex = /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
50
54
|
data["raw"] = template_content.split(yaml_regex).last
|
51
55
|
data["url"] = article.gsub(app.views, "").split(".html").first + ".html"
|
52
|
-
|
53
|
-
all_content = Tilt.new(article).render
|
56
|
+
|
57
|
+
all_content = Tilt.new(article).render
|
54
58
|
data["body"] = all_content.gsub!(app.settings.blog_summary_separator, "")
|
55
|
-
|
59
|
+
|
56
60
|
sum = if data["raw"] =~ app.settings.blog_summary_separator
|
57
61
|
data["raw"].split(app.settings.blog_summary_separator).first
|
58
|
-
else
|
62
|
+
else
|
63
|
+
data["raw"].match(/(.{1,#{app.settings.blog_summary_length}}.*?)(\n|\Z)/m).to_s
|
59
64
|
end
|
60
|
-
|
65
|
+
|
61
66
|
engine = RDiscount.new(sum)
|
62
67
|
data["summary"] = engine.to_html
|
63
68
|
data
|
64
|
-
end.sort { |a, b| b["date"] <=> a["date"] }
|
65
|
-
|
66
|
-
|
67
|
-
|
69
|
+
end.sort { |a, b| b["date"] <=> a["date"] }
|
70
|
+
|
71
|
+
tags = {}
|
72
|
+
articles.each do |article|
|
73
|
+
article["tags"] ||= ""
|
74
|
+
if !article["tags"].empty?
|
75
|
+
tags_array = article["tags"].split(',').map{|t| t.strip}
|
76
|
+
tags_array.each do |tag_title|
|
77
|
+
tag_key = tag_title.parameterize
|
78
|
+
tag_path = blog_taglink.gsub(/(:\w+)/, tag_key)
|
79
|
+
(tags[tag_path] ||= {})["title"] = tag_title
|
80
|
+
tags[tag_path]["ident"] = tag_key
|
81
|
+
(tags[tag_path]["pages"] ||= {})[article["title"]] = article["url"]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
app.data_content("blog", { :articles => articles, :tags => tags })
|
87
|
+
|
68
88
|
app.get(app.settings.blog_permalink) do
|
69
89
|
options = {}
|
70
90
|
options[:layout] = settings.blog_layout
|
71
91
|
options[:layout_engine] = settings.blog_layout_engine
|
72
|
-
|
92
|
+
|
73
93
|
extensionless_path, template_engine = resolve_template(request.path)
|
74
94
|
|
75
95
|
full_file_path = "#{extensionless_path}.#{template_engine}"
|
@@ -78,40 +98,70 @@ module Middleman
|
|
78
98
|
|
79
99
|
# Forward remaining data to helpers
|
80
100
|
self.class.data_content("page", data)
|
81
|
-
|
101
|
+
|
82
102
|
output = render(request.path, options)
|
83
|
-
|
103
|
+
|
84
104
|
# No need for separator on permalink page
|
85
105
|
output.gsub!(settings.blog_summary_separator, "")
|
86
|
-
|
106
|
+
|
87
107
|
status 200
|
88
108
|
output
|
89
109
|
end
|
110
|
+
|
90
111
|
end
|
91
|
-
|
92
112
|
end
|
93
113
|
alias :included :registered
|
94
114
|
end
|
95
|
-
|
115
|
+
|
96
116
|
module Helpers
|
97
117
|
def is_blog_article?
|
98
118
|
!current_article_title.blank?
|
99
119
|
end
|
100
|
-
|
120
|
+
|
101
121
|
def blog_title
|
102
122
|
end
|
103
|
-
|
123
|
+
|
104
124
|
def current_article_date
|
105
125
|
DateTime.parse(current_article_metadata.date)
|
106
126
|
end
|
107
|
-
|
127
|
+
|
108
128
|
def current_article_title
|
109
129
|
current_article_metadata.title
|
110
130
|
end
|
111
|
-
|
131
|
+
|
112
132
|
def current_article_metadata
|
113
133
|
data.page
|
114
134
|
end
|
135
|
+
|
136
|
+
def current_article_tags
|
137
|
+
article_tags_hash = {}
|
138
|
+
if is_blog_article? && current_article_metadata.tags
|
139
|
+
article_tags = current_article_metadata.tags.split(',').map{|t| t.strip}
|
140
|
+
article_tags.each do |tag_title|
|
141
|
+
article_tags_hash[tag_title] = self.class.blog_taglink.gsub(/(:\w+)/, tag_title.parameterize)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
article_tags_hash
|
145
|
+
end
|
146
|
+
|
147
|
+
def blog_tags
|
148
|
+
data.blog.tags
|
149
|
+
end
|
150
|
+
|
151
|
+
def current_tag_data
|
152
|
+
data.blog.tags[request.path]
|
153
|
+
end
|
154
|
+
|
155
|
+
def current_tag_articles
|
156
|
+
data.blog.articles.map do |article|
|
157
|
+
article if current_tag_data.pages.has_value?(article.url)
|
158
|
+
end.compact
|
159
|
+
end
|
160
|
+
|
161
|
+
def current_tag_title
|
162
|
+
current_tag_data[:title]
|
163
|
+
end
|
164
|
+
|
115
165
|
end
|
116
166
|
end
|
117
167
|
end
|
@@ -6,15 +6,10 @@ module Middleman::Features::FrontMatter
|
|
6
6
|
def registered(app)
|
7
7
|
app.extend ClassMethods
|
8
8
|
|
9
|
-
::Tilt::register MarukuTemplate, 'markdown', 'mkd', 'md'
|
10
|
-
::Tilt::register MarukuTemplate, 'markdown', 'mkd', 'md'
|
11
|
-
::Tilt::register KramdownTemplate, 'markdown', 'mkd', 'md'
|
12
|
-
::Tilt::register BlueClothTemplate, 'markdown', 'mkd', 'md'
|
13
|
-
::Tilt::register RedcarpetTemplate, 'markdown', 'mkd', 'md'
|
14
9
|
::Tilt::register RDiscountTemplate, 'markdown', 'mkd', 'md'
|
15
|
-
::Tilt::register RedClothTemplate,
|
16
|
-
::Tilt::register ERBTemplate,
|
17
|
-
::Tilt::register ErubisTemplate,
|
10
|
+
::Tilt::register RedClothTemplate, 'textile'
|
11
|
+
::Tilt::register ERBTemplate, 'erb', 'rhtml'
|
12
|
+
::Tilt::register ErubisTemplate, 'erb', 'rhtml', 'erubis'
|
18
13
|
end
|
19
14
|
alias :included :registered
|
20
15
|
end
|
@@ -45,22 +40,6 @@ module Middleman::Features::FrontMatter
|
|
45
40
|
end
|
46
41
|
|
47
42
|
# MARKDOWN
|
48
|
-
class MarukuTemplate < ::Tilt::MarukuTemplate
|
49
|
-
include Middleman::Features::FrontMatter::YamlAware
|
50
|
-
end
|
51
|
-
|
52
|
-
class KramdownTemplate < ::Tilt::KramdownTemplate
|
53
|
-
include Middleman::Features::FrontMatter::YamlAware
|
54
|
-
end
|
55
|
-
|
56
|
-
class BlueClothTemplate < ::Tilt::BlueClothTemplate
|
57
|
-
include Middleman::Features::FrontMatter::YamlAware
|
58
|
-
end
|
59
|
-
|
60
|
-
class RedcarpetTemplate < ::Tilt::RedcarpetTemplate
|
61
|
-
include Middleman::Features::FrontMatter::YamlAware
|
62
|
-
end
|
63
|
-
|
64
43
|
class RDiscountTemplate < ::Tilt::RDiscountTemplate
|
65
44
|
include Middleman::Features::FrontMatter::YamlAware
|
66
45
|
end
|
data/lib/middleman/server.rb
CHANGED
@@ -78,6 +78,8 @@ module Middleman
|
|
78
78
|
register Middleman::Renderers::Slim
|
79
79
|
register Middleman::Renderers::Haml
|
80
80
|
register Middleman::Renderers::Sass
|
81
|
+
register Middleman::Renderers::Markdown
|
82
|
+
register Middleman::Renderers::CoffeeScript
|
81
83
|
|
82
84
|
# Rack helper for adding mime-types during local preview
|
83
85
|
def self.mime(ext, type)
|
@@ -186,8 +188,12 @@ module Middleman
|
|
186
188
|
|
187
189
|
status 404
|
188
190
|
rescue Padrino::Rendering::TemplateNotFound
|
189
|
-
|
190
|
-
|
191
|
+
if settings.environment == :development
|
192
|
+
raise $!
|
193
|
+
else
|
194
|
+
$stderr.puts "File not found: #{request.path}"
|
195
|
+
status 404
|
196
|
+
end
|
191
197
|
end
|
192
198
|
end
|
193
199
|
end
|
data/lib/middleman/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: middleman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 2.0.0.
|
5
|
+
version: 2.0.0.beta6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Thomas Reynolds
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-07-01 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -335,6 +335,7 @@ files:
|
|
335
335
|
- fixtures/test-app/source/stylesheets/auto-css/auto-css.css
|
336
336
|
- fixtures/test-app/source/stylesheets/auto-css/index.css
|
337
337
|
- fixtures/test-app/source/stylesheets/auto-css/sub/auto-css.css
|
338
|
+
- fixtures/test-app/source/stylesheets/layout.css.sass
|
338
339
|
- fixtures/test-app/source/stylesheets/relative_assets.css.sass
|
339
340
|
- fixtures/test-app/source/stylesheets/site.css.sass
|
340
341
|
- fixtures/test-app/source/stylesheets/site_scss.css.scss
|
@@ -363,7 +364,9 @@ files:
|
|
363
364
|
- lib/middleman/features/relative_assets.rb
|
364
365
|
- lib/middleman/features/tiny_src.rb
|
365
366
|
- lib/middleman/features/ugly_haml.rb
|
367
|
+
- lib/middleman/renderers/coffee_script.rb
|
366
368
|
- lib/middleman/renderers/haml.rb
|
369
|
+
- lib/middleman/renderers/markdown.rb
|
367
370
|
- lib/middleman/renderers/sass.rb
|
368
371
|
- lib/middleman/renderers/slim.rb
|
369
372
|
- lib/middleman/server.rb
|
@@ -489,6 +492,7 @@ test_files:
|
|
489
492
|
- fixtures/test-app/source/stylesheets/auto-css/auto-css.css
|
490
493
|
- fixtures/test-app/source/stylesheets/auto-css/index.css
|
491
494
|
- fixtures/test-app/source/stylesheets/auto-css/sub/auto-css.css
|
495
|
+
- fixtures/test-app/source/stylesheets/layout.css.sass
|
492
496
|
- fixtures/test-app/source/stylesheets/relative_assets.css.sass
|
493
497
|
- fixtures/test-app/source/stylesheets/site.css.sass
|
494
498
|
- fixtures/test-app/source/stylesheets/site_scss.css.scss
|