middleman-core 4.1.0.rc.1 → 4.1.0.rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/features/asset_hash.feature +44 -6
  4. data/features/asset_host.feature +1 -0
  5. data/features/automatic_image_sizes.feature +18 -5
  6. data/fixtures/asset-hash-host-app/source/index.html.erb +1 -1
  7. data/fixtures/asset-host-app/config.rb +1 -0
  8. data/fixtures/asset-host-app/source/asset_host.html.erb +9 -0
  9. data/fixtures/automatic-image-size-app/source/markdown-sizes.html.markdown +1 -0
  10. data/lib/middleman-core/application.rb +68 -58
  11. data/lib/middleman-core/builder.rb +24 -18
  12. data/lib/middleman-core/callback_manager.rb +8 -1
  13. data/lib/middleman-core/contracts.rb +13 -102
  14. data/lib/middleman-core/core_extensions.rb +6 -0
  15. data/lib/middleman-core/core_extensions/collections/lazy_step.rb +1 -1
  16. data/lib/middleman-core/core_extensions/data.rb +3 -2
  17. data/lib/middleman-core/core_extensions/default_helpers.rb +5 -5
  18. data/lib/middleman-core/core_extensions/external_helpers.rb +6 -11
  19. data/lib/middleman-core/core_extensions/file_watcher.rb +1 -1
  20. data/lib/middleman-core/core_extensions/front_matter.rb +1 -0
  21. data/lib/middleman-core/core_extensions/i18n.rb +4 -4
  22. data/lib/middleman-core/core_extensions/inline_url_rewriter.rb +150 -0
  23. data/lib/middleman-core/core_extensions/routing.rb +22 -28
  24. data/lib/middleman-core/core_extensions/show_exceptions.rb +1 -7
  25. data/lib/middleman-core/extension.rb +19 -2
  26. data/lib/middleman-core/extension_manager.rb +2 -0
  27. data/lib/middleman-core/extensions.rb +12 -0
  28. data/lib/middleman-core/extensions/asset_hash.rb +21 -20
  29. data/lib/middleman-core/extensions/asset_host.rb +9 -10
  30. data/lib/middleman-core/extensions/automatic_image_sizes.rb +1 -1
  31. data/lib/middleman-core/extensions/cache_buster.rb +6 -12
  32. data/lib/middleman-core/extensions/gzip.rb +2 -2
  33. data/lib/middleman-core/extensions/lorem.rb +1 -1
  34. data/lib/middleman-core/extensions/minify_css.rb +2 -2
  35. data/lib/middleman-core/extensions/minify_javascript.rb +2 -2
  36. data/lib/middleman-core/extensions/relative_assets.rb +6 -12
  37. data/lib/middleman-core/preview_server.rb +11 -9
  38. data/lib/middleman-core/preview_server/server_hostname.rb +2 -2
  39. data/lib/middleman-core/rack.rb +1 -1
  40. data/lib/middleman-core/renderers/kramdown.rb +1 -1
  41. data/lib/middleman-core/renderers/less.rb +3 -4
  42. data/lib/middleman-core/renderers/markdown.rb +2 -8
  43. data/lib/middleman-core/renderers/redcarpet.rb +1 -1
  44. data/lib/middleman-core/renderers/sass.rb +8 -11
  45. data/lib/middleman-core/renderers/stylus.rb +1 -5
  46. data/lib/middleman-core/sitemap/extensions/ignores.rb +5 -4
  47. data/lib/middleman-core/sitemap/extensions/import.rb +12 -15
  48. data/lib/middleman-core/sitemap/extensions/move_file.rb +3 -3
  49. data/lib/middleman-core/sitemap/extensions/proxies.rb +4 -4
  50. data/lib/middleman-core/sitemap/extensions/redirects.rb +16 -28
  51. data/lib/middleman-core/sitemap/extensions/request_endpoints.rb +17 -35
  52. data/lib/middleman-core/sitemap/extensions/traversal.rb +5 -5
  53. data/lib/middleman-core/sitemap/resource.rb +16 -16
  54. data/lib/middleman-core/sitemap/store.rb +42 -31
  55. data/lib/middleman-core/sources.rb +9 -9
  56. data/lib/middleman-core/sources/source_watcher.rb +14 -10
  57. data/lib/middleman-core/step_definitions/server_steps.rb +12 -4
  58. data/lib/middleman-core/template_context.rb +1 -1
  59. data/lib/middleman-core/template_renderer.rb +74 -75
  60. data/lib/middleman-core/util.rb +19 -16
  61. data/lib/middleman-core/util/data.rb +86 -82
  62. data/lib/middleman-core/version.rb +1 -1
  63. data/middleman-core.gemspec +1 -0
  64. metadata +19 -39
  65. data/features/cli/preview_server-hook.feature +0 -17
  66. data/features/cli/preview_server.feature +0 -536
  67. data/features/cli_extension.feature +0 -14
  68. data/features/cli_init.feature +0 -89
  69. data/fixtures/asset-hash-host-app/config.rb +0 -4
  70. data/fixtures/preview-server-app/bin/dns_server.rb +0 -33
  71. data/fixtures/preview-server-app/config.rb +0 -0
  72. data/fixtures/preview-server-app/source/index.html.erb +0 -1
  73. data/fixtures/preview-server-app/source/layout.erb +0 -9
  74. data/fixtures/preview-server-app/source/layouts/custom.erb +0 -8
  75. data/fixtures/preview-server-app/source/real.html +0 -1
  76. data/fixtures/preview-server-app/source/real/index.html.erb +0 -5
  77. data/fixtures/preview-server-app/source/should_be_ignored.html +0 -1
  78. data/fixtures/preview-server-app/source/should_be_ignored2.html +0 -1
  79. data/fixtures/preview-server-app/source/should_be_ignored3.html +0 -1
  80. data/fixtures/preview-server-app/source/static.html +0 -1
  81. data/fixtures/preview-server-hook-app/config.rb +0 -19
  82. data/fixtures/preview-server-hook-app/source/index.html.erb +0 -9
  83. data/lib/middleman-core/middleware/inline_url_rewriter.rb +0 -109
@@ -1,17 +0,0 @@
1
- Feature: Run preview server before hook
2
-
3
- Scenario: When run
4
- Given a fixture app "preview-server-hook-app"
5
- And the default aruba timeout is 30 seconds
6
- When I run `middleman server --server-name localhost --bind-address 127.0.0.1` interactively
7
- And I stop middleman if the output contains:
8
- """
9
- ### END ###
10
- """
11
- Then the output should contain:
12
- """
13
- /// 127.0.0.1:4567 ///
14
- /// 4567 ///
15
- /// localhost ///
16
- /// http://localhost:4567 ///
17
- """
@@ -1,536 +0,0 @@
1
- Feature: Run the preview server
2
-
3
- As a software developer
4
- I want to start the preview server
5
- In order to view my changes immediately in the browser
6
-
7
- Background:
8
- Given a fixture app "preview-server-app"
9
- And the default aruba timeout is 30 seconds
10
-
11
- Scenario: Start the server with defaults
12
- When I run `middleman server` interactively
13
- And I stop middleman if the output contains:
14
- """
15
- Inspect your site configuration
16
- """
17
- And the output should contain:
18
- """
19
- View your site at "http://
20
- """
21
- And the output should contain:
22
- """
23
- Inspect your site configuration at "http://
24
- """
25
-
26
- Scenario: Start the server with defaults in verbose mode
27
- When I run `middleman server --verbose` interactively
28
- And I stop middleman if the output contains:
29
- """
30
- Inspect your site configuration
31
- """
32
- Then the output should contain:
33
- """
34
- The Middleman preview server is bound to ":::4567", "0.0.0.0:4567"
35
- """
36
- And the output should contain:
37
- """
38
- View your site at "http://
39
- """
40
- And the output should contain:
41
- """
42
- Inspect your site configuration at "http://
43
- """
44
-
45
- @wip
46
- Scenario: Start the server with defaults in verbose mode, when a local mdns server resolves the local hostname
47
- Given I start a mdns server for the local hostname
48
- When I run `middleman server --verbose` interactively
49
- And I stop middleman if the output contains:
50
- """
51
- Inspect your site configuration
52
- """
53
- Then the output should contain:
54
- """
55
- The Middleman preview server is bound to ":::4567", "0.0.0.0:4567"
56
- """
57
- And the output should contain:
58
- """
59
- View your site at "http://
60
- """
61
- And the output should contain:
62
- """
63
- Inspect your site configuration at "http://
64
- """
65
-
66
- Scenario: Start the server with bind address 127.0.0.1
67
- Given I have a local hosts file with:
68
- """
69
- # <ip-address> <hostname.domain.org> <hostname>
70
- 127.0.0.1 localhost.localdomain localhost
71
- """
72
- When I run `middleman server --verbose --bind-address 127.0.0.1` interactively
73
- And I stop middleman if the output contains:
74
- """
75
- Inspect your site configuration
76
- """
77
- Then the output should contain:
78
- """
79
- The Middleman preview server is bound to "127.0.0.1:4567"
80
- """
81
- And the output should contain:
82
- """
83
- View your site at "http://127.0.0.1:4567"
84
- """
85
- And the output should contain:
86
- """
87
- Inspect your site configuration at "http://127.0.0.1:4567/__middleman"
88
- """
89
-
90
- Scenario: Start the server with bind address 127.0.0.1 configured via config.rb
91
- Given I have a local hosts file with:
92
- """
93
- # <ip-address> <hostname.domain.org> <hostname>
94
- 127.0.0.1 localhost.localdomain localhost
95
- """
96
- And a file named "config.rb" with:
97
- """
98
- set :bind_address, '127.0.0.1'
99
- """
100
- When I run `middleman server --verbose` interactively
101
- And I stop middleman if the output contains:
102
- """
103
- Inspect your site configuration
104
- """
105
- Then the output should contain:
106
- """
107
- The Middleman preview server is bound to "127.0.0.1:4567"
108
- """
109
- And the output should contain:
110
- """
111
- View your site at "http://127.0.0.1:4567"
112
- """
113
- And the output should contain:
114
- """
115
- Inspect your site configuration at "http://127.0.0.1:4567/__middleman"
116
- """
117
-
118
- @wip
119
- Scenario: Start the server with bind address 127.0.0.5
120
-
121
- This will have no hostname attached because the hosts file, the DNS server
122
- and the MDNS-server do not know anything about 127.0.0.5
123
-
124
- When I run `middleman server --verbose --bind-address 127.0.0.5` interactively
125
- And I stop middleman if the output contains:
126
- """
127
- Inspect your site configuration
128
- """
129
- Then the output should contain:
130
- """
131
- The Middleman preview server is bound to "127.0.0.5:4567"
132
- """
133
- And the output should contain:
134
- """
135
- View your site at "http://127.0.0.5:4567"
136
- """
137
- And the output should contain:
138
- """
139
- Inspect your site configuration at "http://127.0.0.5:4567/__middleman"
140
- """
141
-
142
- Scenario: Start the server with bind address ::1
143
- Given a file named ".hosts" with:
144
- """
145
- # <ip-address> <hostname.domain.org> <hostname>
146
- ::1 localhost.localdomain localhost
147
- """
148
- When I run `middleman server --verbose --bind-address ::1` interactively
149
- And I stop middleman if the output contains:
150
- """
151
- Inspect your site configuration
152
- """
153
- Then the output should contain:
154
- """
155
- The Middleman preview server is bound to "::1:4567"
156
- """
157
- And the output should contain:
158
- """
159
- View your site at "http://[::1]:4567"
160
- """
161
- And the output should contain:
162
- """
163
- Inspect your site configuration at "http://[::1]:4567/__middleman"
164
- """
165
-
166
- Scenario: Start the server with bind address 0.0.0.0
167
- When I run `middleman server --verbose --bind-address 0.0.0.0` interactively
168
- And I stop middleman if the output contains:
169
- """
170
- Inspect your site configuration
171
- """
172
- Then the output should contain:
173
- """
174
- The Middleman preview server is bound to "0.0.0.0:4567"
175
- """
176
- And the output should contain:
177
- """
178
- View your site at "http://
179
- """
180
- And the output should contain:
181
- """
182
- Inspect your site configuration at "http://
183
- """
184
-
185
- Scenario: Start the server with bind address ::
186
- When I run `middleman server --verbose --bind-address ::` interactively
187
- And I stop middleman if the output contains:
188
- """
189
- Inspect your site configuration
190
- """
191
- Then the output should contain:
192
- """
193
- The Middleman preview server is bound to ":::4567"
194
- """
195
- And the output should contain:
196
- """
197
- View your site at "http://
198
- """
199
- And the output should contain:
200
- """
201
- Inspect your site configuration at "http://
202
- """
203
-
204
- Scenario: Start the server with server name "localhost"
205
- Given I have a local hosts file with:
206
- """
207
- # <ip-address> <hostname.domain.org> <hostname>
208
- 127.0.0.1 localhost.localdomain localhost
209
- """
210
- When I run `middleman server --verbose --server-name localhost` interactively
211
- And I stop middleman if the output contains:
212
- """
213
- Inspect your site configuration
214
- """
215
- Then the output should contain:
216
- """
217
- The Middleman preview server is bound to "127.0.0.1:4567"
218
- """
219
- And the output should contain:
220
- """
221
- View your site at "http://localhost:4567", "http://127.0.0.1:4567"
222
- """
223
- And the output should contain:
224
- """
225
- Inspect your site configuration at "http://localhost:4567/__middleman", "http://127.0.0.1:4567/__middleman"
226
- """
227
-
228
- Scenario: Start the server with server name "localhost" configured via config.rb
229
- Given I have a local hosts file with:
230
- """
231
- # <ip-address> <hostname.domain.org> <hostname>
232
- 127.0.0.1 localhost.localdomain localhost
233
- """
234
- And a file named "config.rb" with:
235
- """
236
- set :server_name, 'localhost'
237
- """
238
- When I run `middleman server --verbose` interactively
239
- And I stop middleman if the output contains:
240
- """
241
- Inspect your site configuration
242
- """
243
- Then the output should contain:
244
- """
245
- The Middleman preview server is bound to "127.0.0.1:4567"
246
- """
247
- And the output should contain:
248
- """
249
- View your site at "http://localhost:4567", "http://127.0.0.1:4567"
250
- """
251
- And the output should contain:
252
- """
253
- Inspect your site configuration at "http://localhost:4567/__middleman", "http://127.0.0.1:4567/__middleman"
254
- """
255
-
256
- Scenario: Start the server with server name "localhost" and bind address "127.0.0.1"
257
- Given I have a local hosts file with:
258
- """
259
- # <ip-address> <hostname.domain.org> <hostname>
260
- 127.0.0.1 localhost.localdomain localhost
261
- """
262
- When I run `middleman server --verbose --server-name localhost --bind-address 127.0.0.1` interactively
263
- And I stop middleman if the output contains:
264
- """
265
- Inspect your site configuration
266
- """
267
- Then the output should contain:
268
- """
269
- The Middleman preview server is bound to "127.0.0.1:4567"
270
- """
271
- And the output should contain:
272
- """
273
- View your site at "http://localhost:4567", "http://127.0.0.1:4567"
274
- """
275
- And the output should contain:
276
- """
277
- Inspect your site configuration at "http://localhost:4567/__middleman", "http://127.0.0.1:4567/__middleman"
278
- """
279
-
280
- Scenario: Start the server with server name "127.0.0.1"
281
- When I run `middleman server --verbose --server-name 127.0.0.1` interactively
282
- And I stop middleman if the output contains:
283
- """
284
- Inspect your site configuration
285
- """
286
- Then the output should contain:
287
- """
288
- The Middleman preview server is bound to "127.0.0.1:4567"
289
- """
290
- And the output should contain:
291
- """
292
- View your site at "http://127.0.0.1:4567"
293
- """
294
- And the output should contain:
295
- """
296
- Inspect your site configuration at "http://127.0.0.1:4567/__middleman"
297
- """
298
-
299
- Scenario: Start the server with server name "::1"
300
- When I run `middleman server --verbose --server-name ::1` interactively
301
- And I stop middleman if the output contains:
302
- """
303
- Inspect your site configuration
304
- """
305
- Then the output should contain:
306
- """
307
- The Middleman preview server is bound to "::1:4567"
308
- """
309
- And the output should contain:
310
- """
311
- View your site at "http://[::1]:4567"
312
- """
313
- And the output should contain:
314
- """
315
- Inspect your site configuration at "http://[::1]:4567/__middleman"
316
- """
317
-
318
- Scenario: Start the server with https
319
- When I run `middleman server --verbose --https` interactively
320
- And I stop middleman if the output contains:
321
- """
322
- Inspect your site configuration
323
- """
324
- Then the output should contain:
325
- """
326
- The Middleman preview server is bound to ":::4567", "0.0.0.0:4567"
327
- """
328
- And the output should contain:
329
- """
330
- View your site at "https://
331
- """
332
- And the output should contain:
333
- """
334
- Inspect your site configuration at "https://
335
- """
336
-
337
- Scenario: Start the server with port 65432
338
- When I run `middleman server --verbose --port 65432` interactively
339
- And I stop middleman if the output contains:
340
- """
341
- Inspect your site configuration
342
- """
343
- Then the output should contain:
344
- """
345
- The Middleman preview server is bound to ":::65432", "0.0.0.0:65432"
346
- """
347
-
348
- Scenario: Start the server with port 65432 configured via config.rb
349
- Given a file named "config.rb" with:
350
- """
351
- set :port, 65432
352
- """
353
- When I run `middleman server --verbose` interactively
354
- And I stop middleman if the output contains:
355
- """
356
- Inspect your site configuration
357
- """
358
- Then the output should contain:
359
- """
360
- The Middleman preview server is bound to ":::65432", "0.0.0.0:65432"
361
- """
362
-
363
- @wip
364
- Scenario: Start the server when port is blocked by other middleman instance
365
- Given `middleman server` is running in background
366
- When I run `middleman server --verbose` interactively
367
- And I stop all commands if the output of the last command contains:
368
- """
369
- Inspect your site configuration
370
- """
371
- Then the output should contain:
372
- """
373
- The Middleman uses a different port
374
- """
375
-
376
- Scenario: Start the server with bind address 1.1.1.1
377
-
378
- This should fail, because "1.1.1.1" is not an interface available on this computer.
379
-
380
- Given a file named ".hosts" with:
381
- """
382
- 1.1.1.1 www.example.com www
383
- """
384
- When I run `middleman server --verbose --bind-address 1.1.1.1` interactively
385
- And I stop middleman if the output contains:
386
- """
387
- Running Middleman failed:
388
- """
389
- Then the output should contain:
390
- """
391
- Bind address "1.1.1.1" is not available on your system
392
- """
393
-
394
- Scenario: Start the server with server name www.example.com and bind address 0.0.0.0
395
-
396
- This should fail, because the user can just use `--server-name`. It does
397
- not make sense for `middleman` to only listen on `0.0.0.0` (IPv4 all
398
- interfaces), but not on `::` (IPv6 all interfaces). There are other tools
399
- like `iptables` (Linux-only) or better some `kernel`-configurations to make
400
- this possible.
401
-
402
- When I run `middleman server --verbose --server-name www.example.com --bind-address 0.0.0.0` interactively
403
- And I stop middleman if the output contains:
404
- """
405
- Running Middleman failed:
406
- """
407
- Then the output should contain:
408
- """
409
- Undefined combination of options "--server-name" and "--bind-address".
410
- """
411
-
412
- Scenario: Start the server with server name "www.example.com" and bind address "127.0.0.1"
413
-
414
- This should fail because the server name does not resolve to the ip address.
415
-
416
- Given a file named ".hosts" with:
417
- """
418
- 1.1.1.1 www.example.com www
419
- """
420
- When I run `middleman server --verbose --server-name www.example.com --bind-address 127.0.0.1` interactively
421
- And I stop middleman if the output contains:
422
- """
423
- Running Middleman failed:
424
- """
425
- Then the output should contain:
426
- """
427
- Server name "www.example.com" does not resolve to bind address "127.0.0.1". Please fix that and try again.
428
- """
429
-
430
- Scenario: Start the server with server name "garbage.example.com"
431
- When I run `middleman server --verbose --server-name garbage.example.com` interactively
432
- And I stop middleman if the output contains:
433
- """
434
- Running Middleman failed:
435
- """
436
- Then the output should contain:
437
- """
438
- Server name "garbage.example.com" does not resolve to an ip address. Please fix that and try again.
439
- """
440
-
441
- Scenario: Start the server with server name "www.example.com" and the network name server is used to resolve the server name
442
- Given I have a local hosts file with:
443
- """
444
- # empty
445
- """
446
- And I start a mdns server with:
447
- """
448
- # empty
449
- """
450
- And I start a dns server with:
451
- """
452
- www.example.com: 127.0.0.1
453
- """
454
- When I run `middleman server --verbose --server-name www.example.com` interactively
455
- And I stop middleman if the output contains:
456
- """
457
- Inspect your site configuration
458
- """
459
- Then the output should contain:
460
- """
461
- The Middleman preview server is bound to "127.0.0.1:4567"
462
- """
463
- And the output should contain:
464
- """
465
- View your site at "http://www.example.com:4567", "http://127.0.0.1:4567"
466
- """
467
- And the output should contain:
468
- """
469
- Inspect your site configuration at "http://www.example.com:4567/__middleman", "http://127.0.0.1:4567/__middleman"
470
- """
471
-
472
- @ruby-2.1
473
- @wip
474
- Scenario: Start the server with server name "host.local" and the link local name server is used to resolve the server name
475
-
476
- To make the mdns resolver resolve a name, it needs to end with ".local".
477
- Otherwise the resolver returns [].
478
-
479
- Given I have a local hosts file with:
480
- """
481
- # empty
482
- """
483
- And I start a mdns server with:
484
- """
485
- host.local: 127.0.0.1
486
- """
487
- When I run `middleman server --verbose --server-name host.local` interactively
488
- And I stop middleman if the output contains:
489
- """
490
- Inspect your site configuration
491
- """
492
- Then the output should contain:
493
- """
494
- The Middleman preview server is bound to "127.0.0.1:4567"
495
- """
496
- And the output should contain:
497
- """
498
- View your site at "http://host.local:4567", "http://127.0.0.1:4567"
499
- """
500
- And the output should contain:
501
- """
502
- Inspect your site configuration at "http://host.local:4567/__middleman", "http://127.0.0.1:4567/__middleman"
503
- """
504
-
505
- @ruby-2.1
506
- @wip
507
- Scenario: Start the server with server name "host" and the link local name server is used to resolve the server name
508
-
509
- To make the mdns resolver resolve a name, it needs to end with ".local". If
510
- a plain hostname is given `middleman` appends ".local" automatically.
511
-
512
- Given I have a local hosts file with:
513
- """
514
- # empty
515
- """
516
- And I start a mdns server with:
517
- """
518
- host.local: 127.0.0.1
519
- """
520
- When I run `middleman server --verbose --server-name host` interactively
521
- And I stop middleman if the output contains:
522
- """
523
- Inspect your site configuration
524
- """
525
- Then the output should contain:
526
- """
527
- The Middleman preview server is bound to "127.0.0.1:4567"
528
- """
529
- And the output should contain:
530
- """
531
- View your site at "http://host.local:4567", "http://127.0.0.1:4567"
532
- """
533
- And the output should contain:
534
- """
535
- Inspect your site configuration at "http://host.local:4567/__middleman", "http://127.0.0.1:4567/__middleman"
536
- """