middleman-core 4.1.11 → 4.1.12

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: 28e12dac8535ed4c817265c3aec998f827b74a78
4
- data.tar.gz: a938f8e9d0e39de8f453776e83338fac6c625b19
3
+ metadata.gz: a4aab7bb8206e390c3d846d576720599102373fe
4
+ data.tar.gz: 86f6c84290c31e0e3081cb50ff76b6017a3c7551
5
5
  SHA512:
6
- metadata.gz: ca37b7bed14ef6f64fbfb8ae3838e96ed73c748fee71706ee0ad1da6d4f6f6d88b45b0c9205721d767a3a748a637c58fb24e19f8fa3e6c948afaabebc0c3582f
7
- data.tar.gz: 8db10682e0568d35753d05c7e9dfd8cbf2a11e5760b0e0e7d57df1c6e97aa8f63d2ba3b1f1f4aec13119f987cd6fd8c799dff209bc1482012d9bb3383de1d056
6
+ metadata.gz: 5575cf0341f1f0d3c42d952dfe2f96475e52fb694c3f99f3b87cbff8dcce2f36b66705fbdc7a4d8bd739b9f78cfac8993dbec8560be7520b5f4ca657d8e382f5
7
+ data.tar.gz: 90cc5b0ee7f35335d54ca46b87d104408e8588423d8f35eea76764959781c242a935ef96d85857df3edea0d5fb95590d2e26a83d06278a403fecadc64e046441
@@ -3,14 +3,60 @@ Feature: Page IDs
3
3
  Scenario: link_to works with blocks (erb)
4
4
  Given the Server is running at "page-id-app"
5
5
  When I go to "/index.html"
6
- Then I should see "I am: index.html"
6
+ Then I should see "I am: index"
7
7
  And I should see "URL1: /fm.html"
8
8
  And I should see "URL2: /2.html"
9
9
  And I should see 'URL3: <a href="/3.html">Hi</a>'
10
10
  And I should see 'URL4: <a href="/overwrites/from-default.html">Sym</a>'
11
+ And I should see 'URL5: <a href="/implicit.html">Imp</a>'
12
+ And I should see 'URL6: <a href="/folder/foldern.html">Foldern</a>'
13
+ And I should see 'URL7: <a href="/feed.xml">Feed</a>'
11
14
 
12
15
  When I go to "/fm.html"
13
16
  Then I should see "I am: frontmatter"
17
+ When I go to "/implicit.html"
18
+ Then I should see "I am: implicit"
19
+ When I go to "/feed.xml"
20
+ Then I should see "I am: feed.xml"
21
+ When I go to "/folder/foldern.html"
22
+ Then I should see "I am: folder/foldern"
23
+
24
+ When I go to "/1.html"
25
+ Then I should see "I am: page1"
26
+ When I go to "/2.html"
27
+ Then I should see "I am: page2"
28
+ When I go to "/3.html"
29
+ Then I should see "I am: page3"
30
+
31
+ When I go to "/overwrites/from-default.html"
32
+ Then I should see "I am: something-else"
33
+
34
+ When I go to "/overwrites/from-frontmatter.html"
35
+ Then I should see "I am: from_frontmatter"
36
+
37
+ Scenario: Override page ID derivation with a proc
38
+ Given a fixture app "page-id-app"
39
+ And app "page-id-app" is using config "proc"
40
+ And the Server is running at "page-id-app"
41
+
42
+ When I go to "/index.html"
43
+ Then I should see "I am: index.html-foo"
44
+ And I should see "URL1: /fm.html"
45
+ And I should see "URL2: /2.html"
46
+ And I should see 'URL3: <a href="/3.html">Hi</a>'
47
+ And I should see 'URL4: <a href="/overwrites/from-default.html">Sym</a>'
48
+ And I should see 'URL8: <a href="/implicit.html">Imp</a>'
49
+ And I should see 'URL9: <a href="/folder/foldern.html">Foldern</a>'
50
+ And I should see 'URL10: <a href="/feed.xml">Feed</a>'
51
+
52
+ When I go to "/fm.html"
53
+ Then I should see "I am: frontmatter"
54
+ When I go to "/implicit.html"
55
+ Then I should see "I am: implicit.html-foo"
56
+ When I go to "/feed.xml"
57
+ Then I should see "I am: feed.xml-foo"
58
+ When I go to "/folder/foldern.html"
59
+ Then I should see "I am: folder/foldern.html-foo"
14
60
 
15
61
  When I go to "/1.html"
16
62
  Then I should see "I am: page1"
@@ -0,0 +1,7 @@
1
+ %w(1 2 3).each do |n|
2
+ proxy "/#{n}.html", "/index.html", id: "page#{n}"
3
+ end
4
+
5
+ page "/overwrites/*", id: :"something-else"
6
+
7
+ config[:page_id_generator] = ->(path){ path + "-foo" }
@@ -0,0 +1 @@
1
+ I am: <%= current_resource.page_id %>
@@ -0,0 +1 @@
1
+ I am: <%= current_resource.page_id %>
@@ -0,0 +1 @@
1
+ I am: <%= current_resource.page_id %>
@@ -4,3 +4,11 @@ URL1: <%= url_for "frontmatter" %>
4
4
  URL2: <%= url_for "page2" %>
5
5
  URL3: <%= link_to "Hi", "page3" %>
6
6
  URL4: <%= link_to "Sym", :"something-else" %>
7
+ URL5: <%= link_to "Imp", :implicit %>
8
+ URL6: <%= link_to "Foldern", "folder/foldern" %>
9
+ URL7: <%= link_to "Feed", "feed.xml" %>
10
+
11
+ <%# If custom proc %>
12
+ URL8: <%= link_to "Imp", "implicit.html-foo" %>
13
+ URL9: <%= link_to "Foldern", "folder/foldern.html-foo" %>
14
+ URL10: <%= link_to "Feed", "feed.xml-foo" %>
@@ -160,6 +160,9 @@ module Middleman
160
160
  path: root,
161
161
  only: match_against
162
162
 
163
+ # Hack around bower_components in root.
164
+ watcher.listener.ignore(/^bower_components/)
165
+
163
166
  # Hack around node_modules in root.
164
167
  watcher.listener.ignore(/^node_modules/)
165
168
 
@@ -74,7 +74,7 @@ module Middleman
74
74
  end
75
75
  end
76
76
 
77
- class BlockIgnoreDescriptor
77
+ class BlockIgnoreDescriptor < IgnoreDescriptor
78
78
  def ignored?(match_path)
79
79
  block.call(match_path)
80
80
  end
@@ -87,7 +87,7 @@ module Middleman
87
87
 
88
88
  Contract Or[Symbol, String, Fixnum]
89
89
  def page_id
90
- metadata[:page][:id] || destination_path
90
+ metadata[:page][:id] || make_implicit_page_id(destination_path)
91
91
  end
92
92
 
93
93
  # Merge in new metadata specific to this resource.
@@ -208,6 +208,30 @@ module Middleman
208
208
  "#<#{self.class} path=#{@path}>"
209
209
  end
210
210
  alias inspect to_s # Ruby 2.0 calls inspect for NoMethodError instead of to_s
211
+
212
+ protected
213
+
214
+ # Makes a page id based on path (when not otherwise given)
215
+ #
216
+ # Removes .html extension and potential leading slashes or dots
217
+ # eg. "foo/bar/baz.foo.html" => "foo/bar/baz.foo"
218
+ Contract String => String
219
+ def make_implicit_page_id(path)
220
+ @id ||= begin
221
+ if prok = @app.config[:page_id_generator]
222
+ return prok.call(path)
223
+ end
224
+
225
+ basename = if ext == ".html"
226
+ File.basename(path, ext)
227
+ else
228
+ File.basename(path)
229
+ end
230
+
231
+ # Remove leading dot or slash if present
232
+ File.join(File.dirname(path), basename).gsub(/^\.?\//, '')
233
+ end
234
+ end
211
235
  end
212
236
 
213
237
  class StringResource < Resource
@@ -1,7 +1,7 @@
1
1
  # Core Pathname library used for traversal
2
2
  require 'pathname'
3
3
  require 'uri'
4
- require 'addressable'
4
+ require 'addressable/uri'
5
5
  require 'memoist'
6
6
  require 'tilt'
7
7
 
@@ -152,7 +152,8 @@ module Middleman
152
152
  def url_for(app, path_or_resource, options={})
153
153
  if path_or_resource.is_a?(String) || path_or_resource.is_a?(Symbol)
154
154
  r = app.sitemap.find_resource_by_page_id(path_or_resource)
155
- path_or_resource = r if r
155
+
156
+ path_or_resource = r ? r : path_or_resource.to_s
156
157
  end
157
158
 
158
159
  # Handle Resources and other things which define their own url method
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  # Current Version
3
3
  # @return [String]
4
- VERSION = '4.1.11'.freeze unless const_defined?(:VERSION)
4
+ VERSION = '4.1.12'.freeze unless const_defined?(:VERSION)
5
5
  end
@@ -220,7 +220,7 @@ describe Middleman::Util do
220
220
 
221
221
  it "does not loop infinitely when file name is a possible templating engine" do
222
222
  expect do
223
- Timeout::timeout(0.5) do
223
+ Timeout::timeout(3.0) do
224
224
  result = Middleman::Util.step_through_extensions("markdown.scss")
225
225
  expect(result).to eq "markdown"
226
226
  end
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: 4.1.11
4
+ version: 4.1.12
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: 2016-11-04 00:00:00.000000000 Z
13
+ date: 2016-11-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -1273,8 +1273,12 @@ files:
1273
1273
  - fixtures/page-helper-layout-block-app/source/layouts/layout.erb
1274
1274
  - fixtures/page-helper-layout-block-app/source/path/child.html.erb
1275
1275
  - fixtures/page-helper-layout-block-app/source/path/index.html.erb
1276
+ - fixtures/page-id-app/config-proc.rb
1276
1277
  - fixtures/page-id-app/config.rb
1278
+ - fixtures/page-id-app/source/feed.xml.erb
1277
1279
  - fixtures/page-id-app/source/fm.html.erb
1280
+ - fixtures/page-id-app/source/folder/foldern.html.erb
1281
+ - fixtures/page-id-app/source/implicit.html.erb
1278
1282
  - fixtures/page-id-app/source/index.html.erb
1279
1283
  - fixtures/page-id-app/source/overwrites/from-default.html.erb
1280
1284
  - fixtures/page-id-app/source/overwrites/from-frontmatter.html.erb
@@ -2479,8 +2483,12 @@ test_files:
2479
2483
  - fixtures/page-helper-layout-block-app/source/layouts/layout.erb
2480
2484
  - fixtures/page-helper-layout-block-app/source/path/child.html.erb
2481
2485
  - fixtures/page-helper-layout-block-app/source/path/index.html.erb
2486
+ - fixtures/page-id-app/config-proc.rb
2482
2487
  - fixtures/page-id-app/config.rb
2488
+ - fixtures/page-id-app/source/feed.xml.erb
2483
2489
  - fixtures/page-id-app/source/fm.html.erb
2490
+ - fixtures/page-id-app/source/folder/foldern.html.erb
2491
+ - fixtures/page-id-app/source/implicit.html.erb
2484
2492
  - fixtures/page-id-app/source/index.html.erb
2485
2493
  - fixtures/page-id-app/source/overwrites/from-default.html.erb
2486
2494
  - fixtures/page-id-app/source/overwrites/from-frontmatter.html.erb