middleman-core 3.3.6 → 3.3.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5edb6179e1b8db65a77a208907ba89912542d232
4
- data.tar.gz: eb2c10c41dae6b5cda0dc3d637ab3e72622243ee
3
+ metadata.gz: 58d1f92ae43159b3ae4a6096479f56e409ee540a
4
+ data.tar.gz: 6f6634ba7c4340dd2d5229f9222b8c1924a1b6a4
5
5
  SHA512:
6
- metadata.gz: 83ba70dcaafdd039ce05654b00800e5e1e3d54f820dfa23a062373d89214d18e8ebe675bc39f31289a7dc44ae22929b87ec8acac08cda3545b78d44d0bc91a46
7
- data.tar.gz: 6283466a1bb102a867a43c61651c11b7271b08f29557b065eebb2d8b156c9f8f9d3b4673e3ae375bca5c5b48387b39aefd2a5561c427908b1b4113e3bd08aec4
6
+ metadata.gz: a937e12df16c26ec28ef901feac136da3ed1534fff3d0a5bbad69f22e0e78721bc01f6ca158f2f4219a73b674581b3341496a5bed270d17473de7fc8692d0a47
7
+ data.tar.gz: 60aca4dc123e02ec8e906360e09cebad68bc0e98d53d6af7cddc995a60b986f2ff218c3696386dba6a59ee9f70941341dd38633b308c3a459b3e9be590e35963
@@ -1,5 +1,5 @@
1
1
  Feature: Assets get a file hash appended to their and references to them are updated
2
- Scenario: Hashed-asset files are produced, and HTML, CSS, and JavaScript gets rewritten to reference the new files
2
+ Scenario: Hashed-asset files are produced, and HTML, CSS, JSON and JavaScript gets rewritten to reference the new files
3
3
  Given a successfully built app at "asset-hash-app"
4
4
  When I cd to "build"
5
5
  Then the following files should exist:
@@ -14,6 +14,8 @@ Feature: Assets get a file hash appended to their and references to them are upd
14
14
  | index.html |
15
15
  | subdir/index.html |
16
16
  | other/index.html |
17
+ | api.json |
18
+ | subdir/api.json |
17
19
  And the following files should not exist:
18
20
  | images/100px.png |
19
21
  | images/100px.jpg |
@@ -33,6 +35,12 @@ Feature: Assets get a file hash appended to their and references to them are upd
33
35
  And the file "other/index.html" should contain 'href="../stylesheets/site-50eaa978.css"'
34
36
  And the file "other/index.html" should contain 'src="../javascripts/application-1d8d5276.js"'
35
37
  And the file "other/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
38
+ And the file "api.json" should contain 'images/100px-5fd6fb90.gif'
39
+ And the file "api.json" should contain 'images/100px-5fd6fb90.jpg'
40
+ And the file "api.json" should contain 'images/100px-1242c368.png'
41
+ And the file "subdir/api.json" should contain 'images/100px-5fd6fb90.gif'
42
+ And the file "subdir/api.json" should contain 'images/100px-5fd6fb90.jpg'
43
+ And the file "subdir/api.json" should contain 'images/100px-1242c368.png'
36
44
 
37
45
  Scenario: Hashed assets work in preview server
38
46
  Given the Server is running at "asset-hash-app"
@@ -53,6 +61,14 @@ Feature: Assets get a file hash appended to their and references to them are upd
53
61
  Then I should see "img.src = '/images/100px-5fd6fb90.jpg'"
54
62
  When I go to "/stylesheets/site-50eaa978.css"
55
63
  Then I should see "background-image: url('../images/100px-5fd6fb90.jpg')"
64
+ When I go to "/api.json"
65
+ Then I should see 'images/100px-5fd6fb90.gif'
66
+ And I should see 'images/100px-5fd6fb90.jpg'
67
+ And I should see 'images/100px-1242c368.png'
68
+ When I go to "/subdir/api.json"
69
+ Then I should see 'images/100px-5fd6fb90.gif'
70
+ And I should see 'images/100px-5fd6fb90.jpg'
71
+ And I should see 'images/100px-1242c368.png'
56
72
 
57
73
  Scenario: Enabling an asset host still produces hashed files and references
58
74
  Given the Server is running at "asset-hash-host-app"
@@ -127,6 +143,8 @@ Feature: Assets get a file hash appended to their and references to them are upd
127
143
  | index.html |
128
144
  | subdir/index.html |
129
145
  | other/index.html |
146
+ | api.json |
147
+ | subdir/api.json |
130
148
  And the following files should not exist:
131
149
  | images/100px-1242c368.png |
132
150
  | images/100px-5fd6fb90.jpg |
@@ -16,4 +16,91 @@ Feature: Templates should be chainable
16
16
 
17
17
  And the file "index.html" should contain "Title</h1>"
18
18
  And the file "index.html" should contain "Subtitle</h2>"
19
- And the file "index.html" should contain "Sup</h3>"
19
+ And the file "index.html" should contain "Sup</h3>"
20
+
21
+ Scenario: Partials are parsed by multiple template engines: Outer template has .erb and inner .md.erb
22
+ Given a fixture app "partial-chained_templates-app"
23
+ And a template named "my_template.html.erb" with:
24
+ """
25
+ <h1>My Template</h1>
26
+
27
+ <%= partial 'my_partial' %>
28
+ """
29
+ And a template named "my_partial.html.md.erb" with:
30
+ """
31
+ ## My Partial
32
+
33
+ <%= 'hello world' %>
34
+ """
35
+ And the Server is running
36
+ When I go to "/my_template.html"
37
+ Then I should see:
38
+ """
39
+ <h1>My Template</h1>
40
+ """
41
+ Then I should see:
42
+ """
43
+ <h2 id="my-partial">My Partial</h2>
44
+ """
45
+ Then I should see:
46
+ """
47
+ <p>hello world</p>
48
+ """
49
+
50
+ Scenario: Partials are parsed by multiple template engines: Outer template has .md.erb and inner .md.erb
51
+ Given a fixture app "partial-chained_templates-app"
52
+ And a template named "my_template.html.md.erb" with:
53
+ """
54
+ # My Template
55
+
56
+ <%= partial 'my_partial' %>
57
+ """
58
+ And a template named "my_partial.html.md.erb" with:
59
+ """
60
+ ## My Partial
61
+
62
+ <%= 'hello world' %>
63
+ """
64
+ And the Server is running
65
+ When I go to "/my_template.html"
66
+ Then I should see:
67
+ """
68
+ <h1 id="my-template">My Template</h1>
69
+ """
70
+ Then I should see:
71
+ """
72
+ <h2 id="my-partial">My Partial</h2>
73
+ """
74
+ Then I should see:
75
+ """
76
+ <p>hello world</p>
77
+ """
78
+
79
+ Scenario: Partials are parsed by multiple template engines: Outer template has .md.erb, and inner .erb
80
+ Given a fixture app "partial-chained_templates-app"
81
+ And a template named "my_template.html.md.erb" with:
82
+ """
83
+ # My Template
84
+
85
+ <%= partial 'my_partial' %>
86
+ """
87
+ And a template named "my_partial.html.erb" with:
88
+ """
89
+ <h2>My Partial</h2>
90
+
91
+ <%= 'hello world' %>
92
+ """
93
+ And the Server is running
94
+ When I go to "/my_template.html"
95
+ Then I should see:
96
+ """
97
+ <h1 id="my-template">My Template</h1>
98
+ """
99
+ Then I should see:
100
+ """
101
+ <h2>My Partial</h2>
102
+ """
103
+ Then I should see:
104
+ """
105
+ <p>hello world</p>
106
+ """
@@ -0,0 +1,33 @@
1
+ Feature: Honour working directory
2
+ Honour the working directory during testing
3
+ In order to support helpers which work with the current directories
4
+
5
+ Scenario: Set working directory for helpers in tests
6
+ Given a fixture app "empty-app"
7
+ And a file named "source/index.erb" with:
8
+ """
9
+ <%= Dir.getwd %>
10
+ """
11
+ And the Server is running
12
+ When I go to "/index.html"
13
+ Then I should see:
14
+ """
15
+ aruba
16
+ """
17
+
18
+ Scenario: Set working directory for config.rb in tests
19
+ Given a fixture app "empty-app"
20
+ And a file named "config.rb" with:
21
+ """
22
+ set :my_working_directory, Dir.getwd
23
+ """
24
+ And a file named "source/index.erb" with:
25
+ """
26
+ <%= my_working_directory %>
27
+ """
28
+ And the Server is running
29
+ When I go to "/index.html"
30
+ Then I should see:
31
+ """
32
+ aruba
33
+ """
@@ -0,0 +1 @@
1
+ <%= {gif: image_path('100px.gif'), jpg: image_path('100px.jpg'), png: image_path('100px.png')}.to_json %>
@@ -0,0 +1 @@
1
+ <%= {gif: image_path('100px.gif'), jpg: image_path('100px.jpg'), png: image_path('100px.png')}.to_json %>
File without changes
@@ -146,18 +146,7 @@ module Middleman
146
146
  @current_locs = locs
147
147
  @current_opts = opts
148
148
 
149
- # Keep rendering template until we've used up all extensions. This
150
- # handles cases like `style.css.sass.erb`
151
- content = nil
152
- while ::Tilt[path]
153
- begin
154
- opts[:template_body] = content if content
155
- content = render_individual_file(path, locs, opts, context)
156
- path = File.basename(path, File.extname(path))
157
- rescue LocalJumpError
158
- raise "Tried to render a layout (calls yield) at #{path} like it was a template. Non-default layouts need to be in #{source}/#{config[:layouts_dir]}."
159
- end
160
- end
149
+ content = _render_with_all_renderers(path, locs, context, opts)
161
150
 
162
151
  # If we need a layout and have a layout, use it
163
152
  if layout_path = fetch_layout(engine, opts)
@@ -175,6 +164,34 @@ module Middleman
175
164
  @current_opts = nil
176
165
  end
177
166
 
167
+ private
168
+
169
+ def _render_with_all_renderers(path, locs, context, opts, &block)
170
+ # Keep rendering template until we've used up all extensions. This
171
+ # handles cases like `style.css.sass.erb`
172
+ content = nil
173
+
174
+ while ::Tilt[path]
175
+ begin
176
+ opts[:template_body] = content if content
177
+
178
+ content = if block_given?
179
+ render_individual_file(path, locs, opts, context, &block)
180
+ else
181
+ render_individual_file(path, locs, opts, context)
182
+ end
183
+
184
+ path = File.basename(path, File.extname(path))
185
+ rescue LocalJumpError
186
+ raise "Tried to render a layout (calls yield) at #{path} like it was a template. Non-default layouts need to be in #{source}/#{config[:layouts_dir]}."
187
+ end
188
+ end
189
+
190
+ content
191
+ end
192
+
193
+ public
194
+
178
195
  # Sinatra/Padrino compatible render method signature referenced by some view
179
196
  # helpers. Especially partials.
180
197
  #
@@ -198,7 +215,7 @@ module Middleman
198
215
 
199
216
  if ::Tilt[found_partial]
200
217
  # Render the partial if found, otherwide throw exception
201
- render_individual_file(found_partial, locals, options, self, &block)
218
+ _render_with_all_renderers(found_partial, locals, self, options, &block)
202
219
  else
203
220
  File.read(found_partial)
204
221
  end
@@ -39,7 +39,7 @@ module Middleman
39
39
  build_path = 'Not built' if ignored?
40
40
  props['Build Path'] = build_path if @resource.path != build_path
41
41
  props['URL'] = content_tag(:a, @resource.url, href: @resource.url) unless ignored?
42
- props['Source File'] = @resource.source_file.sub(/^#{Regexp.escape(ENV['MM_ROOT'] + '/')}/, '')
42
+ props['Source File'] = @resource.source_file ? @resource.source_file.sub(/^#{Regexp.escape(ENV['MM_ROOT'] + '/')}/, '') : 'Dynamic'
43
43
 
44
44
  data = @resource.data
45
45
  props['Data'] = data.inspect unless data.empty?
@@ -66,6 +66,10 @@ module Middleman
66
66
  super(store, path)
67
67
  end
68
68
 
69
+ def get_source_file
70
+ nil
71
+ end
72
+
69
73
  def template?
70
74
  true
71
75
  end
@@ -34,6 +34,7 @@ end
34
34
  Given /^the Server is running$/ do
35
35
  root_dir = File.expand_path(current_dir)
36
36
 
37
+
37
38
  if File.exists?(File.join(root_dir, 'source'))
38
39
  ENV['MM_SOURCE'] = 'source'
39
40
  else
@@ -48,9 +49,11 @@ Given /^the Server is running$/ do
48
49
  set :show_exceptions, false
49
50
  }
50
51
 
51
- @server_inst = Middleman::Application.server.inst do
52
- initialize_commands.each do |p|
53
- instance_exec(&p)
52
+ in_current_dir do
53
+ @server_inst = Middleman::Application.server.inst do
54
+ initialize_commands.each do |p|
55
+ instance_exec(&p)
56
+ end
54
57
  end
55
58
  end
56
59
 
@@ -63,42 +66,66 @@ Given /^the Server is running at "([^\"]*)"$/ do |app_path|
63
66
  step %Q{the Server is running}
64
67
  end
65
68
 
69
+ Given /^a template named "([^\"]*)" with:$/ do |name, string|
70
+ step %Q{a file named "source/#{name}" with:}, string
71
+ end
72
+
66
73
  When /^I go to "([^\"]*)"$/ do |url|
67
- @browser.get(URI.escape(url))
74
+ in_current_dir do
75
+ @browser.get(URI.escape(url))
76
+ end
68
77
  end
69
78
 
70
79
  Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
71
- expect{ @browser.get(URI.escape(url)) }.to_not raise_exception
80
+ in_current_dir do
81
+ expect{ @browser.get(URI.escape(url)) }.to_not raise_exception
82
+ end
72
83
  end
73
84
 
74
85
  Then /^the content type should be "([^\"]*)"$/ do |expected|
75
- expect(@browser.last_response.content_type).to start_with(expected)
86
+ in_current_dir do
87
+ expect(@browser.last_response.content_type).to start_with(expected)
88
+ end
76
89
  end
77
90
 
78
91
  Then /^I should see "([^\"]*)"$/ do |expected|
79
- expect(@browser.last_response.body).to include(expected)
92
+ in_current_dir do
93
+ expect(@browser.last_response.body).to include(expected)
94
+ end
80
95
  end
81
96
 
82
97
  Then /^I should see '([^\']*)'$/ do |expected|
83
- expect(@browser.last_response.body).to include(expected)
98
+ in_current_dir do
99
+ expect(@browser.last_response.body).to include(expected)
100
+ end
84
101
  end
85
102
 
86
103
  Then /^I should see:$/ do |expected|
87
- expect(@browser.last_response.body).to include(expected)
104
+ in_current_dir do
105
+ expect(@browser.last_response.body).to include(expected)
106
+ end
88
107
  end
89
108
 
90
109
  Then /^I should not see "([^\"]*)"$/ do |expected|
91
- expect(@browser.last_response.body).to_not include(expected)
110
+ in_current_dir do
111
+ expect(@browser.last_response.body).to_not include(expected)
112
+ end
92
113
  end
93
114
 
94
115
  Then /^I should not see:$/ do |expected|
95
- expect(@browser.last_response.body).to_not include(expected.chomp)
116
+ in_current_dir do
117
+ expect(@browser.last_response.body).to_not include(expected.chomp)
118
+ end
96
119
  end
97
120
 
98
121
  Then /^the status code should be "([^\"]*)"$/ do |expected|
99
- expect(@browser.last_response.status).to eq expected.to_i
122
+ in_current_dir do
123
+ expect(@browser.last_response.status).to eq expected.to_i
124
+ end
100
125
  end
101
126
 
102
127
  Then /^I should see "([^\"]*)" lines$/ do |lines|
103
- expect(@browser.last_response.body.chomp.split($/).length).to eq(lines.to_i)
128
+ in_current_dir do
129
+ expect(@browser.last_response.body.chomp.split($/).length).to eq(lines.to_i)
130
+ end
104
131
  end
@@ -1,6 +1,6 @@
1
- # If you have OpenSSL installed, we recommend updating
2
- # the following line to use "https"
3
- source 'http://rubygems.org'
1
+ # If you do not have OpenSSL installed, update
2
+ # the following line to use "http://" instead
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in <%= name %>.gemspec
6
6
  gemspec
@@ -1,6 +1,6 @@
1
- # If you have OpenSSL installed, we recommend updating
2
- # the following line to use "https"
3
- source 'http://rubygems.org'
1
+ # If you do not have OpenSSL installed, update
2
+ # the following line to use "http://" instead
3
+ source 'https://rubygems.org'
4
4
 
5
5
  gem "middleman", "~><%= Middleman::VERSION %>"
6
6
 
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  # Current Version
3
3
  # @return [String]
4
- VERSION = '3.3.6' unless const_defined?(:VERSION)
4
+ VERSION = '3.3.7' unless const_defined?(:VERSION)
5
5
  end
@@ -12,7 +12,7 @@ class Padrino::Helpers::OutputHelpers::ErbHandler
12
12
  raw = block.call(*args)
13
13
  captured = template.instance_variable_get(:@_out_buf)
14
14
  self.output_buffer = _buf_was
15
- engine_matches?(block) ? captured : raw
15
+ engine_matches?(block) && !captured.empty? ? captured : raw
16
16
  end
17
17
  end
18
18
 
@@ -75,7 +75,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
75
75
 
76
76
  path = ::Middleman::Util.full_path(env['PATH_INFO'], @middleman_app)
77
77
 
78
- if path =~ /(^\/$)|(\.(htm|html|php|css|js)$)/
78
+ if path =~ /(^\/$)|(\.(htm|html|php|css|js|json)$)/
79
79
  body = ::Middleman::Util.extract_response_text(response)
80
80
  if body
81
81
  status, headers, response = Rack::Response.new(rewrite_paths(body, path), status, headers).finish
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.6
4
+ version: 3.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Reynolds
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-09-15 00:00:00.000000000 Z
13
+ date: 2014-11-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -305,6 +305,7 @@ files:
305
305
  - features/v3_extensions.feature
306
306
  - features/v4_extension_callbacks.feature
307
307
  - features/wildcard_page_helper.feature
308
+ - features/working_directory.feature
308
309
  - fixtures/asciidoc-app/config.rb
309
310
  - fixtures/asciidoc-app/source/_include.adoc
310
311
  - fixtures/asciidoc-app/source/code.adoc
@@ -320,6 +321,7 @@ files:
320
321
  - fixtures/asciidoc-app/source/master.adoc
321
322
  - fixtures/asset-hash-app/config.rb
322
323
  - fixtures/asset-hash-app/lib/middleware.rb
324
+ - fixtures/asset-hash-app/source/api.json.erb
323
325
  - fixtures/asset-hash-app/source/apple-touch-icon.png
324
326
  - fixtures/asset-hash-app/source/favicon.ico
325
327
  - fixtures/asset-hash-app/source/images/100px.gif
@@ -333,6 +335,7 @@ files:
333
335
  - fixtures/asset-hash-app/source/stylesheets/_partial.sass
334
336
  - fixtures/asset-hash-app/source/stylesheets/site.css.scss
335
337
  - fixtures/asset-hash-app/source/stylesheets/uses_partials.css.sass
338
+ - fixtures/asset-hash-app/source/subdir/api.json.erb
336
339
  - fixtures/asset-hash-app/source/subdir/index.html.erb
337
340
  - fixtures/asset-hash-host-app/config.rb
338
341
  - fixtures/asset-hash-host-app/source/images/100px.gif
@@ -830,6 +833,7 @@ files:
830
833
  - fixtures/page-helper-layout-block-app/source/layouts/layout.erb
831
834
  - fixtures/page-helper-layout-block-app/source/path/child.html.erb
832
835
  - fixtures/page-helper-layout-block-app/source/path/index.html.erb
836
+ - fixtures/partial-chained_templates-app/config.rb
833
837
  - fixtures/partials-app/config.rb
834
838
  - fixtures/partials-app/source/_code_snippet.html
835
839
  - fixtures/partials-app/source/_locals.erb
@@ -1370,6 +1374,7 @@ test_files:
1370
1374
  - features/v3_extensions.feature
1371
1375
  - features/v4_extension_callbacks.feature
1372
1376
  - features/wildcard_page_helper.feature
1377
+ - features/working_directory.feature
1373
1378
  - fixtures/asciidoc-app/config.rb
1374
1379
  - fixtures/asciidoc-app/source/_include.adoc
1375
1380
  - fixtures/asciidoc-app/source/code.adoc
@@ -1385,6 +1390,7 @@ test_files:
1385
1390
  - fixtures/asciidoc-app/source/master.adoc
1386
1391
  - fixtures/asset-hash-app/config.rb
1387
1392
  - fixtures/asset-hash-app/lib/middleware.rb
1393
+ - fixtures/asset-hash-app/source/api.json.erb
1388
1394
  - fixtures/asset-hash-app/source/apple-touch-icon.png
1389
1395
  - fixtures/asset-hash-app/source/favicon.ico
1390
1396
  - fixtures/asset-hash-app/source/images/100px.gif
@@ -1398,6 +1404,7 @@ test_files:
1398
1404
  - fixtures/asset-hash-app/source/stylesheets/_partial.sass
1399
1405
  - fixtures/asset-hash-app/source/stylesheets/site.css.scss
1400
1406
  - fixtures/asset-hash-app/source/stylesheets/uses_partials.css.sass
1407
+ - fixtures/asset-hash-app/source/subdir/api.json.erb
1401
1408
  - fixtures/asset-hash-app/source/subdir/index.html.erb
1402
1409
  - fixtures/asset-hash-host-app/config.rb
1403
1410
  - fixtures/asset-hash-host-app/source/images/100px.gif
@@ -1895,6 +1902,7 @@ test_files:
1895
1902
  - fixtures/page-helper-layout-block-app/source/layouts/layout.erb
1896
1903
  - fixtures/page-helper-layout-block-app/source/path/child.html.erb
1897
1904
  - fixtures/page-helper-layout-block-app/source/path/index.html.erb
1905
+ - fixtures/partial-chained_templates-app/config.rb
1898
1906
  - fixtures/partials-app/config.rb
1899
1907
  - fixtures/partials-app/source/_code_snippet.html
1900
1908
  - fixtures/partials-app/source/_locals.erb