middleman 2.0.0.rc5 → 2.0.0.rc6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  `mv public source`
4
- `ditto views source`
4
+ `cp -R views/* source/`
5
5
  `rm -rf views`
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require "rubygems"
3
4
  require "thor"
4
5
  require "thor/group"
5
6
 
@@ -0,0 +1,6 @@
1
+ Feature: Sinatra Routes
2
+
3
+ Scenario: Rendering html
4
+ Given the Server is running
5
+ When I go to "/sinatra_test"
6
+ Then I should see "Ratpack"
@@ -27,4 +27,8 @@ with_layout false do
27
27
  }.each do |path|
28
28
  page path
29
29
  end
30
+ end
31
+
32
+ get "/sinatra_test" do
33
+ "Ratpack"
30
34
  end
@@ -78,7 +78,7 @@ module Middleman::Base
78
78
  end
79
79
 
80
80
  # See if Tilt cannot handle this file
81
- app.before do
81
+ app.before_processing do
82
82
  if !settings.views.include?(settings.root)
83
83
  settings.set :views, File.join(settings.root, settings.views)
84
84
  end
@@ -92,12 +92,14 @@ module Middleman::Base
92
92
  content_type mime_type(File.extname(request.path_info)), :charset => 'utf-8'
93
93
  status 200
94
94
  send_file File.join(settings.views, request.path_info)
95
- request["already_sent"] = true
95
+ false
96
+ else
97
+ true
96
98
  end
97
99
  else
98
100
  $stderr.puts "File not found: #{request.path_info}"
99
101
  status 404
100
- request["already_sent"] = true
102
+ false
101
103
  end
102
104
  end
103
105
  end
@@ -115,6 +117,19 @@ module Middleman::Base
115
117
  super(option, value, &nil)
116
118
  end
117
119
 
120
+ def before_processing(&block)
121
+ @before_processes ||= []
122
+ @before_processes << block
123
+ end
124
+
125
+ def execute_before_processing!(inst)
126
+ @before_processes ||= []
127
+
128
+ @before_processes.all? do |block|
129
+ inst.instance_eval(&block)
130
+ end
131
+ end
132
+
118
133
  # Convenience method to check if we're in build mode
119
134
  def build?; environment == :build; end
120
135
  end
@@ -122,7 +137,7 @@ module Middleman::Base
122
137
  module InstanceMethods
123
138
  # Internal method to look for templates and evaluate them if found
124
139
  def process_request(options={})
125
- return if request["already_sent"]
140
+ return unless settings.execute_before_processing!(self)
126
141
 
127
142
  options.merge!(request['custom_options'] || {})
128
143
 
@@ -23,25 +23,27 @@ module Middleman::CoreExtensions::FrontMatter
23
23
  ::Tilt.prefer(HamlTemplate)
24
24
 
25
25
  app.after_feature_init do
26
- app.before do
26
+ app.before_processing do
27
27
  result = resolve_template(request.path_info, :raise_exceptions => false)
28
-
28
+
29
29
  if result && Tilt.mappings.has_key?(result[1].to_s)
30
30
  extensionless_path, template_engine = result
31
31
  full_file_path = "#{extensionless_path}.#{template_engine}"
32
32
  system_path = File.join(settings.views, full_file_path)
33
33
  data, content = app.parse_front_matter(File.read(system_path))
34
-
34
+
35
35
  request['custom_options'] = {}
36
36
  %w(layout layout_engine).each do |opt|
37
37
  if data.has_key?(opt)
38
38
  request['custom_options'][opt.to_sym] = data.delete(opt)
39
39
  end
40
40
  end
41
-
41
+
42
42
  # Forward remaining data to helpers
43
43
  app.data_content("page", data)
44
44
  end
45
+
46
+ true
45
47
  end
46
48
  end
47
49
  end
@@ -4,8 +4,9 @@ module Middleman::CoreExtensions::Routing
4
4
  app.extend ClassMethods
5
5
 
6
6
  # Normalize the path and add index if we're looking at a directory
7
- app.before do
7
+ app.before_processing do
8
8
  request.path_info = self.class.path_to_index(request.path)
9
+ true
9
10
  end
10
11
  end
11
12
  alias :included :registered
@@ -43,7 +44,7 @@ module Middleman::CoreExtensions::Routing
43
44
 
44
45
  paths = [url]
45
46
  paths << "#{url}/" if url.length > 1 && url.split("/").last.split('.').length <= 1
46
- paths << "#{path_to_index(url)}"
47
+ paths << "/#{path_to_index(url)}"
47
48
 
48
49
  options[:layout] = settings.layout if options[:layout].nil?
49
50
 
@@ -42,60 +42,61 @@ module Middleman
42
42
  end
43
43
 
44
44
  $stderr.puts "== Blog: #{app.settings.blog_permalink}"
45
-
46
- app.before do
47
- articles_glob = File.join(app.views, app.settings.blog_permalink.gsub(/(:\w+)/, "*") + ".*")
48
-
49
- articles = Dir[articles_glob].map do |article|
50
- template_content = File.read(article)
51
- data, content = app.parse_front_matter(template_content)
52
- data["date"] = Date.parse(data["date"])
53
-
54
- data["raw"] = content
55
- data["url"] = article.gsub(app.views, "").split(".html").first + ".html"
56
-
57
- all_content = Tilt.new(article).render
58
- data["body"] = all_content.gsub!(app.settings.blog_summary_separator, "")
59
-
60
- sum = if data["raw"] =~ app.settings.blog_summary_separator
61
- data["raw"].split(app.settings.blog_summary_separator).first
62
- else
63
- data["raw"].match(/(.{1,#{app.settings.blog_summary_length}}.*?)(\n|\Z)/m).to_s
64
- end
65
-
66
- engine = app.settings.markdown_engine.new { sum }
67
- data["summary"] = engine.render
68
- data
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
- end
88
45
 
89
46
  app.get(app.settings.blog_permalink) do
90
47
  process_request({
91
48
  :layout => settings.blog_layout,
92
49
  :layout_engine => settings.blog_layout_engine
93
50
  })
94
-
51
+
95
52
  # No need for separator on permalink page
96
53
  body body.gsub!(settings.blog_summary_separator, "")
97
54
  end
98
55
  end
56
+
57
+ app.before_processing do
58
+ articles_glob = File.join(app.views, app.settings.blog_permalink.gsub(/(:\w+)/, "*") + ".*")
59
+
60
+ articles = Dir[articles_glob].map do |article|
61
+ template_content = File.read(article)
62
+ data, content = app.parse_front_matter(template_content)
63
+ data["date"] = Date.parse(data["date"])
64
+
65
+ data["raw"] = content
66
+ data["url"] = article.gsub(app.views, "").split(".html").first + ".html"
67
+
68
+ all_content = Tilt.new(article).render
69
+ data["body"] = all_content.gsub!(app.settings.blog_summary_separator, "")
70
+
71
+ sum = if data["raw"] =~ app.settings.blog_summary_separator
72
+ data["raw"].split(app.settings.blog_summary_separator).first
73
+ else
74
+ data["raw"].match(/(.{1,#{app.settings.blog_summary_length}}.*?)(\n|\Z)/m).to_s
75
+ end
76
+
77
+ engine = app.settings.markdown_engine.new { sum }
78
+ data["summary"] = engine.render
79
+ data
80
+ end.sort { |a, b| b["date"] <=> a["date"] }
81
+
82
+ tags = {}
83
+ articles.each do |article|
84
+ article["tags"] ||= ""
85
+ if !article["tags"].empty?
86
+ tags_array = article["tags"].split(',').map{|t| t.strip}
87
+ tags_array.each do |tag_title|
88
+ tag_key = tag_title.parameterize
89
+ tag_path = blog_taglink.gsub(/(:\w+)/, tag_key)
90
+ (tags[tag_path] ||= {})["title"] = tag_title
91
+ tags[tag_path]["ident"] = tag_key
92
+ (tags[tag_path]["pages"] ||= {})[article["title"]] = article["url"]
93
+ end
94
+ end
95
+ end
96
+
97
+ app.data_content("blog", { :articles => articles, :tags => tags })
98
+ true
99
+ end
99
100
  end
100
101
  alias :included :registered
101
102
  end
@@ -23,7 +23,7 @@ module Middleman::Guard
23
23
 
24
24
  guardfile_contents << %Q{
25
25
  guard 'livereload'#{livereload_options_hash} do
26
- watch(%r{^source/(.*)$})
26
+ watch(%r{^source/^[^\.](.*)$})
27
27
  end
28
28
  }
29
29
  end
@@ -1,3 +1,3 @@
1
1
  module Middleman
2
- VERSION = "2.0.0.rc5"
2
+ VERSION = "2.0.0.rc6"
3
3
  end
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.rc5
5
+ version: 2.0.0.rc6
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-07-13 00:00:00 -07:00
13
+ date: 2011-07-14 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -309,6 +309,7 @@ files:
309
309
  - features/page_alias_and_layouts.feature
310
310
  - features/relative_assets.feature
311
311
  - features/scss-support.feature
312
+ - features/sinatra.feature
312
313
  - features/slim.feature
313
314
  - features/sprockets.feature
314
315
  - features/step_definitions/asset_host_steps.rb
@@ -483,6 +484,7 @@ test_files:
483
484
  - features/page_alias_and_layouts.feature
484
485
  - features/relative_assets.feature
485
486
  - features/scss-support.feature
487
+ - features/sinatra.feature
486
488
  - features/slim.feature
487
489
  - features/sprockets.feature
488
490
  - features/step_definitions/asset_host_steps.rb