middleman-core 3.0.7 → 3.0.8.pre.1

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.
@@ -11,6 +11,16 @@ Feature: YAML Front Matter
11
11
  Then I should see "<?php"
12
12
  Then I should not see "---"
13
13
 
14
+ Scenario: Rendering raw (template-less) (yaml)
15
+ Given the Server is running at "frontmatter-app"
16
+ When I go to "/raw-front-matter.html"
17
+ Then I should see "<h1><%= data.page.title %></h1>"
18
+ Then I should not see "---"
19
+ When I go to "/raw-front-matter.php"
20
+ Then I should see '<?php echo "sup"; ?>'
21
+ Then I should see "<?php"
22
+ Then I should not see "---"
23
+
14
24
  Scenario: YAML not on first line, no encoding
15
25
  Given the Server is running at "frontmatter-app"
16
26
  When I go to "/front-matter-line-2.html"
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: false
3
+ title: This is the title
4
+ ---
5
+
6
+ <h1><%= data.page.title %></h1>
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: false
3
+ title: This is the title
4
+ ---
5
+
6
+ <?php echo "sup"; ?>
@@ -117,16 +117,20 @@ module Middleman::Cli
117
117
  build_dir = self.class.shared_instance.build_dir
118
118
  output_file = File.join(build_dir, resource.destination_path)
119
119
 
120
- begin
121
- response = self.class.shared_rack.get(URI.escape(resource.destination_path))
122
-
123
- if response.status == 200
124
- create_file(output_file, response.body)
125
- else
126
- handle_error(output_file, response.body)
120
+ if resource.binary?
121
+ copy_file(resource.source_file, output_file)
122
+ else
123
+ begin
124
+ response = self.class.shared_rack.get(URI.escape(resource.destination_path))
125
+
126
+ if response.status == 200
127
+ create_file(output_file, response.body)
128
+ else
129
+ handle_error(output_file, response.body)
130
+ end
131
+ rescue => e
132
+ handle_error(output_file, "#{e}\n#{e.backtrace.join("\n")}", e)
127
133
  end
128
- rescue => e
129
- handle_error(output_file, "#{e}\n#{e.backtrace.join("\n")}", e)
130
134
  end
131
135
 
132
136
  output_file
@@ -88,6 +88,7 @@ module Middleman
88
88
  # @param [Pathname] path The file that changed
89
89
  # @return [void]
90
90
  def did_change(path)
91
+ path = Pathname(path)
91
92
  return if ignored?(path)
92
93
  logger.debug "== File Change: #{path}"
93
94
  @known_paths << path
@@ -99,6 +100,7 @@ module Middleman
99
100
  # @param [Pathname] path The file that was deleted
100
101
  # @return [void]
101
102
  def did_delete(path)
103
+ path = Pathname(path)
102
104
  return if ignored?(path)
103
105
  logger.debug "== File Deletion: #{path}"
104
106
  @known_paths.delete(path)
@@ -242,10 +242,10 @@ module Middleman
242
242
  # Return 404 if not in sitemap
243
243
  return not_found(res, request_path) unless resource && !resource.ignored?
244
244
 
245
- current_path = resource.destination_path
245
+ # If this path is a binary file, send it immediately
246
+ return send_file(resource.source_file, env, res) if resource.binary?
246
247
 
247
- # If this path is a static file, send it immediately
248
- return send_file(resource.source_file, env, res) unless resource.template?
248
+ current_path = resource.destination_path
249
249
 
250
250
  # Set a HTTP content type based on the request's extensions
251
251
  content_type(res, resource.mime_type)
@@ -111,7 +111,9 @@ module Middleman
111
111
  # Render this resource
112
112
  # @return [String]
113
113
  def render(opts={}, locs={}, &block)
114
- return File.open(source_file).read unless template?
114
+ if !template?
115
+ return app.template_data_for_file(source_file)
116
+ end
115
117
 
116
118
  relative_source = Pathname(source_file).relative_path_from(Pathname(app.root))
117
119
 
@@ -144,6 +146,14 @@ module Middleman
144
146
  end
145
147
  File.join(app.respond_to?(:http_prefix) ? app.http_prefix : '/', url_path)
146
148
  end
149
+
150
+ # Whether the source file is binary.
151
+ #
152
+ # @retrun [Boolean]
153
+ def binary?
154
+ s = (File.read(source_file, File.stat(source_file).blksize) || "").split(//)
155
+ ((s.size - s.grep(" ".."~").size) / s.size.to_f) > 0.30
156
+ end
147
157
  end
148
158
  end
149
159
  end
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  # Current Version
3
3
  # @return [String]
4
- VERSION = '3.0.7' unless const_defined?(:VERSION)
4
+ VERSION = '3.0.8.pre.1' unless const_defined?(:VERSION)
5
5
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.7
5
- prerelease:
4
+ version: 3.0.8.pre.1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Thomas Reynolds
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-17 00:00:00.000000000 Z
13
+ date: 2013-01-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -295,6 +295,8 @@ files:
295
295
  - fixtures/frontmatter-app/source/json-front-matter-encoding.html.erb
296
296
  - fixtures/frontmatter-app/source/json-front-matter-line-2.html.erb
297
297
  - fixtures/frontmatter-app/source/json-front-matter.html.erb
298
+ - fixtures/frontmatter-app/source/raw-front-matter.html
299
+ - fixtures/frontmatter-app/source/raw-front-matter.php
298
300
  - fixtures/frontmatter-settings-app/config.rb
299
301
  - fixtures/frontmatter-settings-app/source/alternate_layout.html.erb
300
302
  - fixtures/frontmatter-settings-app/source/ignored.html.erb
@@ -597,16 +599,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
597
599
  version: '0'
598
600
  segments:
599
601
  - 0
600
- hash: 1408914751343926382
602
+ hash: -677048081599026784
601
603
  required_rubygems_version: !ruby/object:Gem::Requirement
602
604
  none: false
603
605
  requirements:
604
- - - ! '>='
606
+ - - ! '>'
605
607
  - !ruby/object:Gem::Version
606
- version: '0'
607
- segments:
608
- - 0
609
- hash: 1408914751343926382
608
+ version: 1.3.1
610
609
  requirements: []
611
610
  rubyforge_project:
612
611
  rubygems_version: 1.8.24
@@ -737,6 +736,8 @@ test_files:
737
736
  - fixtures/frontmatter-app/source/json-front-matter-encoding.html.erb
738
737
  - fixtures/frontmatter-app/source/json-front-matter-line-2.html.erb
739
738
  - fixtures/frontmatter-app/source/json-front-matter.html.erb
739
+ - fixtures/frontmatter-app/source/raw-front-matter.html
740
+ - fixtures/frontmatter-app/source/raw-front-matter.php
740
741
  - fixtures/frontmatter-settings-app/config.rb
741
742
  - fixtures/frontmatter-settings-app/source/alternate_layout.html.erb
742
743
  - fixtures/frontmatter-settings-app/source/ignored.html.erb