middleman-core 3.3.12 → 3.4.0

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.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/cucumber.yml +2 -0
  4. data/features/asset_hash.feature +9 -0
  5. data/features/chained_templates.feature +4 -1
  6. data/features/cli/preview_server.feature +532 -0
  7. data/features/i18n_link_to.feature +209 -0
  8. data/features/javascript-testing.feature +18 -0
  9. data/features/redirects.feature +1 -0
  10. data/features/relative_assets.feature +11 -0
  11. data/features/support/env.rb +3 -0
  12. data/fixtures/asset-hash-app/source/fonts/fontawesome-webfont.woff +0 -0
  13. data/fixtures/asset-hash-app/source/fonts/fontawesome-webfont.woff2 +0 -0
  14. data/fixtures/asset-hash-app/source/stylesheets/uses_fonts.css +4 -0
  15. data/fixtures/chained-app/source/test.erb.combobreaker.str.erb +8 -0
  16. data/fixtures/javascript-app/config.rb +0 -0
  17. data/fixtures/javascript-app/source/index.html +17 -0
  18. data/fixtures/preview-server-app/bin/dns_server.rb +33 -0
  19. data/fixtures/preview-server-app/config-complications.rb +11 -0
  20. data/fixtures/preview-server-app/config-empty.rb +0 -0
  21. data/fixtures/preview-server-app/config.rb +11 -0
  22. data/fixtures/preview-server-app/source/index.html.erb +1 -0
  23. data/fixtures/preview-server-app/source/layout.erb +9 -0
  24. data/fixtures/preview-server-app/source/layouts/custom.erb +8 -0
  25. data/fixtures/preview-server-app/source/real.html +1 -0
  26. data/fixtures/preview-server-app/source/real/index.html.erb +5 -0
  27. data/fixtures/preview-server-app/source/should_be_ignored.html +1 -0
  28. data/fixtures/preview-server-app/source/should_be_ignored2.html +1 -0
  29. data/fixtures/preview-server-app/source/should_be_ignored3.html +1 -0
  30. data/fixtures/preview-server-app/source/static.html +1 -0
  31. data/fixtures/relative-assets-app/source/absolute_image_relative_css.html.erb +9 -0
  32. data/fixtures/relative-assets-app/source/javascripts/app.js +3 -0
  33. data/fixtures/relative-assets-app/source/relative_image.html.erb +1 -0
  34. data/fixtures/relative-assets-app/source/relative_image_absolute_css.html.erb +9 -0
  35. data/lib/middleman-core/application.rb +11 -5
  36. data/lib/middleman-core/cli/build.rb +3 -1
  37. data/lib/middleman-core/cli/bundler.rb +1 -1
  38. data/lib/middleman-core/cli/extension.rb +2 -2
  39. data/lib/middleman-core/cli/init.rb +3 -3
  40. data/lib/middleman-core/cli/server.rb +9 -1
  41. data/lib/middleman-core/configuration.rb +0 -2
  42. data/lib/middleman-core/core_extensions/data.rb +2 -2
  43. data/lib/middleman-core/core_extensions/external_helpers.rb +2 -1
  44. data/lib/middleman-core/core_extensions/file_watcher.rb +7 -0
  45. data/lib/middleman-core/core_extensions/front_matter.rb +13 -4
  46. data/lib/middleman-core/core_extensions/rendering.rb +20 -6
  47. data/lib/middleman-core/core_extensions/request.rb +2 -2
  48. data/lib/middleman-core/dns_resolver.rb +73 -0
  49. data/lib/middleman-core/dns_resolver/basic_network_resolver.rb +52 -0
  50. data/lib/middleman-core/dns_resolver/hosts_resolver.rb +63 -0
  51. data/lib/middleman-core/dns_resolver/local_link_resolver.rb +44 -0
  52. data/lib/middleman-core/dns_resolver/network_resolver.rb +42 -0
  53. data/lib/middleman-core/extension.rb +0 -1
  54. data/lib/middleman-core/meta_pages.rb +1 -1
  55. data/lib/middleman-core/preview_server.rb +94 -37
  56. data/lib/middleman-core/preview_server/checks.rb +81 -0
  57. data/lib/middleman-core/preview_server/information.rb +273 -0
  58. data/lib/middleman-core/preview_server/network_interface_inventory.rb +65 -0
  59. data/lib/middleman-core/preview_server/server_hostname.rb +39 -0
  60. data/lib/middleman-core/preview_server/server_information.rb +144 -0
  61. data/lib/middleman-core/preview_server/server_information_validator.rb +18 -0
  62. data/lib/middleman-core/preview_server/server_ip_address.rb +55 -0
  63. data/lib/middleman-core/preview_server/server_url.rb +50 -0
  64. data/lib/middleman-core/preview_server/tcp_port_prober.rb +29 -0
  65. data/lib/middleman-core/sitemap.rb +4 -4
  66. data/lib/middleman-core/sitemap/extensions/ignores.rb +5 -1
  67. data/lib/middleman-core/sitemap/extensions/proxies.rb +0 -1
  68. data/lib/middleman-core/sitemap/extensions/redirects.rb +2 -1
  69. data/lib/middleman-core/sitemap/queryable.rb +2 -1
  70. data/lib/middleman-core/sitemap/store.rb +3 -3
  71. data/lib/middleman-core/step_definitions.rb +1 -0
  72. data/lib/middleman-core/step_definitions/builder_steps.rb +7 -7
  73. data/lib/middleman-core/step_definitions/commandline_steps.rb +88 -0
  74. data/lib/middleman-core/step_definitions/server_steps.rb +25 -28
  75. data/lib/middleman-core/templates/extension/Gemfile +0 -1
  76. data/lib/middleman-core/templates/extension/Rakefile +1 -1
  77. data/lib/middleman-core/util.rb +24 -0
  78. data/lib/middleman-core/version.rb +1 -1
  79. data/lib/middleman-more/core_extensions/default_helpers.rb +49 -8
  80. data/lib/middleman-more/core_extensions/i18n.rb +101 -27
  81. data/lib/middleman-more/extensions/asset_hash.rb +1 -1
  82. data/lib/middleman-more/extensions/asset_host.rb +1 -1
  83. data/lib/middleman-more/extensions/automatic_image_sizes.rb +7 -0
  84. data/lib/middleman-more/extensions/cache_buster.rb +1 -1
  85. data/lib/middleman-more/extensions/lorem.rb +2 -2
  86. data/lib/middleman-more/extensions/minify_javascript.rb +6 -4
  87. data/lib/middleman-more/extensions/relative_assets.rb +4 -8
  88. data/middleman-core.gemspec +3 -3
  89. data/spec/middleman-core/dns_resolver_spec.rb +118 -0
  90. data/spec/middleman-core/preview_server/server_hostname_spec.rb +39 -0
  91. data/spec/middleman-core/preview_server/server_ip_address_spec.rb +43 -0
  92. data/spec/spec_helper.rb +26 -0
  93. metadata +81 -17
@@ -0,0 +1,209 @@
1
+ Feature: i18n Paths
2
+
3
+ Scenario: link_to is i18n aware
4
+ Given a fixture app "empty-app"
5
+ And a file named "data/pages.yml" with:
6
+ """
7
+ - hello.html
8
+ """
9
+ And a file named "locales/en.yml" with:
10
+ """
11
+ ---
12
+ en:
13
+ msg: Hello
14
+ home: Home
15
+ """
16
+ And a file named "locales/es.yml" with:
17
+ """
18
+ ---
19
+ es:
20
+ paths:
21
+ hello: "hola"
22
+ msg: Hola
23
+ home: Casa
24
+ """
25
+ And a file named "source/localizable/index.html.erb" with:
26
+ """
27
+ Page: <%= t(:hom) %>
28
+ """
29
+ And a file named "source/localizable/hello.html.erb" with:
30
+ """
31
+ Page: <%= t(:msg) %>
32
+
33
+ <%= link_to "Current Home", "/index.html", class: 'current' %>
34
+ <%= link_to "Other Home", "/index.html", title: "Other Home", locale: ::I18n.locale == :en ? :es : :en %>
35
+ <% link_to "/index.html", class: 'current' do %><span>Home: Current Block</span><% end %>
36
+ <% link_to "/index.html", title: "Other Home", locale: ::I18n.locale == :en ? :es : :en do %><span>Home: Other Block</span><% end %>
37
+
38
+ <% data.pages.each_with_index do |p, i| %>
39
+ <%= link_to "Current #{p}", "/#{p}", class: 'current' %>
40
+ <%= link_to "Other #{p}", "/#{p}", title: "Other #{p}", locale: ::I18n.locale == :en ? :es : :en %>
41
+ <% link_to "/#{p}", class: 'current' do %><span>Current Block</span><% end %>
42
+ <% link_to "/#{p}", title: "Other #{p}", locale: ::I18n.locale == :en ? :es : :en do %><span>Other Block</span><% end %>
43
+ <% end %>
44
+ """
45
+ And a file named "config.rb" with:
46
+ """
47
+ set :strip_index_file, false
48
+ activate :i18n, mount_at_root: :en
49
+ """
50
+ Given the Server is running at "empty-app"
51
+ When I go to "/hello.html"
52
+ Then I should see "Page: Hello"
53
+ Then I should see '<a class="current" href="/index.html">Current Home</a>'
54
+ Then I should see '<a title="Other Home" href="/es/index.html">Other Home</a>'
55
+ Then I should see '<a class="current" href="/index.html"><span>Home: Current Block</span></a>'
56
+ Then I should see '<a title="Other Home" href="/es/index.html"><span>Home: Other Block</span></a>'
57
+ Then I should see '<a class="current" href="/hello.html">Current hello.html</a>'
58
+ Then I should see '<a title="Other hello.html" href="/es/hola.html">Other hello.html</a>'
59
+ Then I should see '<a class="current" href="/hello.html"><span>Current Block</span></a>'
60
+ Then I should see '<a title="Other hello.html" href="/es/hola.html"><span>Other Block</span></a>'
61
+ When I go to "/es/hola.html"
62
+ Then I should see "Page: Hola"
63
+ Then I should see '<a class="current" href="/es/index.html">Current Home</a>'
64
+ Then I should see '<a title="Other Home" href="/index.html">Other Home</a>'
65
+ Then I should see '<a class="current" href="/es/index.html"><span>Home: Current Block</span></a>'
66
+ Then I should see '<a title="Other Home" href="/index.html"><span>Home: Other Block</span></a>'
67
+ Then I should see '<a class="current" href="/es/hola.html">Current hello.html</a>'
68
+ Then I should see '<a title="Other hello.html" href="/hello.html">Other hello.html</a>'
69
+ Then I should see '<a class="current" href="/es/hola.html"><span>Current Block</span></a>'
70
+ Then I should see '<a title="Other hello.html" href="/hello.html"><span>Other Block</span></a>'
71
+
72
+ Scenario: link_to is i18n aware and supports relative_links
73
+ Given a fixture app "empty-app"
74
+ And a file named "locales/en.yml" with:
75
+ """
76
+ ---
77
+ en:
78
+ msg: Hello
79
+ home: Home
80
+ """
81
+ And a file named "locales/es.yml" with:
82
+ """
83
+ ---
84
+ es:
85
+ paths:
86
+ hello: "hola"
87
+ msg: Hola
88
+ home: Casa
89
+ """
90
+ And a file named "source/assets/css/main.css.scss" with:
91
+ """
92
+ $color: red;
93
+ body { background: $color; }
94
+ """
95
+ And a file named "source/localizable/index.html.erb" with:
96
+ """
97
+ Page: <%= t(:home) %>
98
+ <%= stylesheet_link_tag :main %>
99
+ """
100
+ And a file named "source/localizable/hello.html.erb" with:
101
+ """
102
+ Page: <%= t(:msg) %>
103
+
104
+ <%= link_to "Current Home", "/index.html", class: 'current' %>
105
+ <%= link_to "Other Home", "/index.html", title: "Other Home", locale: ::I18n.locale == :en ? :es : :en %>
106
+ <% link_to "/index.html", class: 'current' do %><span>Home: Current Block</span><% end %>
107
+ <% link_to "/index.html", title: "Other Home", locale: ::I18n.locale == :en ? :es : :en do %><span>Home: Other Block</span><% end %>
108
+
109
+ <%= link_to "Current hello.html", "/hello.html", class: 'current' %>
110
+ <%= link_to "Other hello.html", "/hello.html", title: "Other hello.html", locale: ::I18n.locale == :en ? :es : :en %>
111
+ <% link_to "/hello.html", class: 'current' do %><span>Current Block</span><% end %>
112
+ <% link_to "/hello.html", title: "Other hello.html", locale: ::I18n.locale == :en ? :es : :en do %><span>Other Block</span><% end %>
113
+ """
114
+ And a file named "config.rb" with:
115
+ """
116
+ set :css_dir, 'assets/css'
117
+ set :relative_links, true
118
+ set :strip_index_file, false
119
+ activate :i18n, mount_at_root: :en
120
+ activate :relative_assets
121
+ """
122
+ Given the Server is running at "empty-app"
123
+ When I go to "/index.html"
124
+ Then I should see "assets/css/main.css"
125
+ When I go to "/hello.html"
126
+ Then I should see "Page: Hello"
127
+ Then I should see '<a class="current" href="index.html">Current Home</a>'
128
+ Then I should see '<a title="Other Home" href="es/index.html">Other Home</a>'
129
+ Then I should see '<a class="current" href="index.html"><span>Home: Current Block</span></a>'
130
+ Then I should see '<a title="Other Home" href="es/index.html"><span>Home: Other Block</span></a>'
131
+ Then I should see '<a class="current" href="hello.html">Current hello.html</a>'
132
+ Then I should see '<a title="Other hello.html" href="es/hola.html">Other hello.html</a>'
133
+ Then I should see '<a class="current" href="hello.html"><span>Current Block</span></a>'
134
+ Then I should see '<a title="Other hello.html" href="es/hola.html"><span>Other Block</span></a>'
135
+ When I go to "/es/hola.html"
136
+ Then I should see "Page: Hola"
137
+ Then I should see '<a class="current" href="index.html">Current Home</a>'
138
+ Then I should see '<a title="Other Home" href="../index.html">Other Home</a>'
139
+ Then I should see '<a class="current" href="index.html"><span>Home: Current Block</span></a>'
140
+ Then I should see '<a title="Other Home" href="../index.html"><span>Home: Other Block</span></a>'
141
+ Then I should see '<a class="current" href="hola.html">Current hello.html</a>'
142
+ Then I should see '<a title="Other hello.html" href="../hello.html">Other hello.html</a>'
143
+ Then I should see '<a class="current" href="hola.html"><span>Current Block</span></a>'
144
+ Then I should see '<a title="Other hello.html" href="../hello.html"><span>Other Block</span></a>'
145
+
146
+ Scenario: url_for is i18n aware
147
+ Given a fixture app "empty-app"
148
+ And a file named "data/pages.yml" with:
149
+ """
150
+ - hello.html
151
+ - article.html
152
+ """
153
+ And a file named "locales/en.yml" with:
154
+ """
155
+ ---
156
+ en:
157
+ msg: Hello
158
+ """
159
+ And a file named "locales/es.yml" with:
160
+ """
161
+ ---
162
+ es:
163
+ paths:
164
+ hello: "hola"
165
+ msg: Hola
166
+ """
167
+ And a file named "source/localizable/hello.html.erb" with:
168
+ """
169
+ Page: <%= t(:msg) %>
170
+ <% data.pages.each_with_index do |p, i| %>
171
+ Current: <%= url_for "/#{p}" %>
172
+ Other: <%= url_for "/#{p}", locale: ::I18n.locale == :en ? :es : :en %>
173
+ <% end %>
174
+ """
175
+ And a file named "source/localizable/article.html.erb" with:
176
+ """
177
+ Page Lang: Default
178
+
179
+ Current: <%= url_for "/article.html" %>
180
+ Other: <%= url_for "/article.html", locale: ::I18n.locale == :en ? :es : :en %>
181
+ """
182
+ And a file named "source/localizable/article.es.html.erb" with:
183
+ """
184
+ Page Lang: Spanish
185
+
186
+ Current: <%= url_for "/article.html" %>
187
+ Other: <%= url_for "/article.html", locale: :en %>
188
+ """
189
+ And a file named "config.rb" with:
190
+ """
191
+ activate :i18n, mount_at_root: :en
192
+ """
193
+ Given the Server is running at "empty-app"
194
+ When I go to "/hello.html"
195
+ Then I should see "Page: Hello"
196
+ Then I should see 'Current: /hello.html'
197
+ Then I should see 'Other: /es/hola.html'
198
+ When I go to "/es/hola.html"
199
+ Then I should see "Page: Hola"
200
+ Then I should see 'Current: /es/hola.html'
201
+ Then I should see 'Other: /hello.html'
202
+ When I go to "/article.html"
203
+ Then I should see "Page Lang: Default"
204
+ Then I should see 'Current: /article.html'
205
+ Then I should see 'Other: /es/article.html'
206
+ When I go to "/es/article.html"
207
+ Then I should see "Page Lang: Spanish"
208
+ Then I should see 'Current: /es/article.html'
209
+ Then I should see 'Other: /article.html'
@@ -0,0 +1,18 @@
1
+ Feature: Test a site with javascript included
2
+
3
+ As a software developer
4
+ I want to develop a site using javascript
5
+ I would like to have a server step rendering javascript correctly in order to test it
6
+
7
+ @javascript
8
+ Scenario: Existing app with javascript
9
+ Given the Server is running at "javascript-app"
10
+ When I go to "/index.html"
11
+ Then I should see:
12
+ """
13
+ Local Hour
14
+ """
15
+ And I should see:
16
+ """
17
+ Local Minutes
18
+ """
@@ -8,6 +8,7 @@ Feature: Meta redirects
8
8
  """
9
9
  And the Server is running at "large-build-app"
10
10
  When I go to "/hello.html"
11
+ Then I should see '<link rel="canonical" href="world.html"'
11
12
  Then I should see '<meta http-equiv=refresh content="0; url=world.html"'
12
13
 
13
14
  Scenario: Redirect to external site
@@ -21,6 +21,12 @@ Feature: Relative Assets
21
21
  Given "relative_assets" feature is "disabled"
22
22
  And the Server is running at "relative-assets-app"
23
23
  When I go to "/relative_image.html"
24
+ Then I should see '"/stylesheets/relative_assets.css"'
25
+ Then I should see '"/javascripts/app.js"'
26
+ Then I should see "/images/blank.gif"
27
+ When I go to "/absolute_image_relative_css.html"
28
+ Then I should see '"stylesheets/relative_assets.css"'
29
+ Then I should see '"javascripts/app.js"'
24
30
  Then I should see "/images/blank.gif"
25
31
 
26
32
  Scenario: Rendering css with the feature enabled
@@ -54,6 +60,11 @@ Feature: Relative Assets
54
60
  Given "relative_assets" feature is "enabled"
55
61
  And the Server is running at "relative-assets-app"
56
62
  When I go to "/relative_image.html"
63
+ Then I should see '"stylesheets/relative_assets.css"'
64
+ Then I should see '"javascripts/app.js"'
65
+ When I go to "/relative_image_absolute_css.html"
66
+ Then I should see '"/stylesheets/relative_assets.css"'
67
+ Then I should see '"/javascripts/app.js"'
57
68
  Then I should not see "/images/blank.gif"
58
69
  And I should see "images/blank.gif"
59
70
 
@@ -4,6 +4,9 @@ ENV["AUTOLOAD_SPROCKETS"] = "false"
4
4
  require 'simplecov'
5
5
  SimpleCov.root(File.expand_path(File.dirname(__FILE__) + '/../..'))
6
6
 
7
+ require 'capybara/poltergeist'
8
+ Capybara.javascript_driver = :poltergeist
9
+
7
10
  require 'coveralls'
8
11
  Coveralls.wear!
9
12
 
@@ -0,0 +1,4 @@
1
+ @font-face {
2
+ font-family: 'FontAwesome';
3
+ src: url('../fonts/fontawesome-webfont.woff2') format('woff2'), url('../fonts/fontawesome-webfont.woff') format('woff');
4
+ }
@@ -0,0 +1,8 @@
1
+ ---
2
+ layout: false
3
+ sup: "Sup"
4
+ ---
5
+
6
+ <h1>#{"<%= data.article.title %>"}</h1>
7
+ <h2>#{"<%= data.article.subtitle %>"}</h2>
8
+ <h3>#{"<%= current_page.data.sup %>"}</h3>
File without changes
@@ -0,0 +1,17 @@
1
+ <html>
2
+ <head>
3
+ <title>
4
+ Title
5
+ </title>
6
+ </head>
7
+ <body>
8
+ <script type="text/javascript" language="JavaScript">
9
+ <!--
10
+ current_date = new Date();
11
+ document.write('Now: ');
12
+ document.write(current_date.getHours() + " Local H" + "our");
13
+ document.write(current_date.getMinutes() + " Local M" + "inutes");
14
+ //-->
15
+ </script>
16
+ </body>
17
+ </html>
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubydns'
4
+ require 'psych'
5
+
6
+ db_file = ARGV[0]
7
+ port = ARGV[1] || 5300
8
+
9
+ db = if File.file? db_file
10
+ $stderr.puts 'Found dns db'
11
+ Psych.load_file(db_file)
12
+ else
13
+ $stderr.puts 'Found no dns db. Use default db.'
14
+
15
+ {
16
+ /www\.example\.org/ => '1.1.1.1'
17
+ }
18
+ end
19
+
20
+ interfaces = [
21
+ [:udp, "127.0.0.1", port],
22
+ [:tcp, "127.0.0.1", port]
23
+ ]
24
+
25
+
26
+ # Start the RubyDNS server
27
+ RubyDNS::run_server(:listen => interfaces) do
28
+ db.each do |matcher, result|
29
+ match(matcher, Resolv::DNS::Resource::IN::A) do |transaction|
30
+ transaction.respond!(result)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,11 @@
1
+ page "/fake.html", :proxy => "/real.html", :layout => false
2
+
3
+ ignore "/should_be_ignored.html"
4
+ page "/should_be_ignored2.html", :ignore => true
5
+ page "/target_ignore.html", :proxy => "/should_be_ignored3.html", :ignore => true
6
+
7
+ %w(one two).each do |num|
8
+ page "/fake/#{num}.html", :proxy => "/real/index.html" do
9
+ @num = num
10
+ end
11
+ end
File without changes
@@ -0,0 +1,11 @@
1
+ page "/fake.html", :proxy => "/real.html", :layout => false
2
+
3
+ ignore "/should_be_ignored.html"
4
+ page "/should_be_ignored2.html", :ignore => true
5
+ page "/target_ignore.html", :proxy => "/should_be_ignored3.html", :ignore => true
6
+
7
+ %w(one two).each do |num|
8
+ page "/fake/#{num}.html", :proxy => "/real/index.html" do
9
+ @num = num
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ <h1>Welcome</h1>
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <head>
3
+ <title>My Sample Site</title>
4
+ <!-- Comment in layout -->
5
+ </head>
6
+ <body>
7
+ <%= yield %>
8
+ </body>
9
+ </html>
@@ -0,0 +1,8 @@
1
+ <html>
2
+ <head>
3
+ <title>Custom Layout</title>
4
+ </head>
5
+ <body>
6
+ <%= yield %>
7
+ </body>
8
+ </html>
@@ -0,0 +1 @@
1
+ I am real
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: false
3
+ ---
4
+
5
+ I am real: <%= @num %>
@@ -0,0 +1 @@
1
+ <h1>Ignore me!</h1>
@@ -0,0 +1 @@
1
+ <h1>Ignore me! 2</h1>
@@ -0,0 +1 @@
1
+ <h1>Ignore me! 3</h1>
@@ -0,0 +1 @@
1
+ Static, no code!
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <head>
3
+ <%= stylesheet_link_tag :relative_assets, relative: true %>
4
+ <%= javascript_include_tag :app, relative: true %>
5
+ </head>
6
+ <body>
7
+ <%= image_tag "blank.gif" %>
8
+ </body>
9
+ </html>
@@ -0,0 +1,3 @@
1
+ function hello() {
2
+ console.log('world');
3
+ }