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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/features/asset_hash.feature +44 -6
- data/features/asset_host.feature +1 -0
- data/features/automatic_image_sizes.feature +18 -5
- data/fixtures/asset-hash-host-app/source/index.html.erb +1 -1
- data/fixtures/asset-host-app/config.rb +1 -0
- data/fixtures/asset-host-app/source/asset_host.html.erb +9 -0
- data/fixtures/automatic-image-size-app/source/markdown-sizes.html.markdown +1 -0
- data/lib/middleman-core/application.rb +68 -58
- data/lib/middleman-core/builder.rb +24 -18
- data/lib/middleman-core/callback_manager.rb +8 -1
- data/lib/middleman-core/contracts.rb +13 -102
- data/lib/middleman-core/core_extensions.rb +6 -0
- data/lib/middleman-core/core_extensions/collections/lazy_step.rb +1 -1
- data/lib/middleman-core/core_extensions/data.rb +3 -2
- data/lib/middleman-core/core_extensions/default_helpers.rb +5 -5
- data/lib/middleman-core/core_extensions/external_helpers.rb +6 -11
- data/lib/middleman-core/core_extensions/file_watcher.rb +1 -1
- data/lib/middleman-core/core_extensions/front_matter.rb +1 -0
- data/lib/middleman-core/core_extensions/i18n.rb +4 -4
- data/lib/middleman-core/core_extensions/inline_url_rewriter.rb +150 -0
- data/lib/middleman-core/core_extensions/routing.rb +22 -28
- data/lib/middleman-core/core_extensions/show_exceptions.rb +1 -7
- data/lib/middleman-core/extension.rb +19 -2
- data/lib/middleman-core/extension_manager.rb +2 -0
- data/lib/middleman-core/extensions.rb +12 -0
- data/lib/middleman-core/extensions/asset_hash.rb +21 -20
- data/lib/middleman-core/extensions/asset_host.rb +9 -10
- data/lib/middleman-core/extensions/automatic_image_sizes.rb +1 -1
- data/lib/middleman-core/extensions/cache_buster.rb +6 -12
- data/lib/middleman-core/extensions/gzip.rb +2 -2
- data/lib/middleman-core/extensions/lorem.rb +1 -1
- data/lib/middleman-core/extensions/minify_css.rb +2 -2
- data/lib/middleman-core/extensions/minify_javascript.rb +2 -2
- data/lib/middleman-core/extensions/relative_assets.rb +6 -12
- data/lib/middleman-core/preview_server.rb +11 -9
- data/lib/middleman-core/preview_server/server_hostname.rb +2 -2
- data/lib/middleman-core/rack.rb +1 -1
- data/lib/middleman-core/renderers/kramdown.rb +1 -1
- data/lib/middleman-core/renderers/less.rb +3 -4
- data/lib/middleman-core/renderers/markdown.rb +2 -8
- data/lib/middleman-core/renderers/redcarpet.rb +1 -1
- data/lib/middleman-core/renderers/sass.rb +8 -11
- data/lib/middleman-core/renderers/stylus.rb +1 -5
- data/lib/middleman-core/sitemap/extensions/ignores.rb +5 -4
- data/lib/middleman-core/sitemap/extensions/import.rb +12 -15
- data/lib/middleman-core/sitemap/extensions/move_file.rb +3 -3
- data/lib/middleman-core/sitemap/extensions/proxies.rb +4 -4
- data/lib/middleman-core/sitemap/extensions/redirects.rb +16 -28
- data/lib/middleman-core/sitemap/extensions/request_endpoints.rb +17 -35
- data/lib/middleman-core/sitemap/extensions/traversal.rb +5 -5
- data/lib/middleman-core/sitemap/resource.rb +16 -16
- data/lib/middleman-core/sitemap/store.rb +42 -31
- data/lib/middleman-core/sources.rb +9 -9
- data/lib/middleman-core/sources/source_watcher.rb +14 -10
- data/lib/middleman-core/step_definitions/server_steps.rb +12 -4
- data/lib/middleman-core/template_context.rb +1 -1
- data/lib/middleman-core/template_renderer.rb +74 -75
- data/lib/middleman-core/util.rb +19 -16
- data/lib/middleman-core/util/data.rb +86 -82
- data/lib/middleman-core/version.rb +1 -1
- data/middleman-core.gemspec +1 -0
- metadata +19 -39
- data/features/cli/preview_server-hook.feature +0 -17
- data/features/cli/preview_server.feature +0 -536
- data/features/cli_extension.feature +0 -14
- data/features/cli_init.feature +0 -89
- data/fixtures/asset-hash-host-app/config.rb +0 -4
- data/fixtures/preview-server-app/bin/dns_server.rb +0 -33
- data/fixtures/preview-server-app/config.rb +0 -0
- data/fixtures/preview-server-app/source/index.html.erb +0 -1
- data/fixtures/preview-server-app/source/layout.erb +0 -9
- data/fixtures/preview-server-app/source/layouts/custom.erb +0 -8
- data/fixtures/preview-server-app/source/real.html +0 -1
- data/fixtures/preview-server-app/source/real/index.html.erb +0 -5
- data/fixtures/preview-server-app/source/should_be_ignored.html +0 -1
- data/fixtures/preview-server-app/source/should_be_ignored2.html +0 -1
- data/fixtures/preview-server-app/source/should_be_ignored3.html +0 -1
- data/fixtures/preview-server-app/source/static.html +0 -1
- data/fixtures/preview-server-hook-app/config.rb +0 -19
- data/fixtures/preview-server-hook-app/source/index.html.erb +0 -9
- data/lib/middleman-core/middleware/inline_url_rewriter.rb +0 -109
@@ -1,14 +0,0 @@
|
|
1
|
-
Feature: Middleman New Extension CLI
|
2
|
-
|
3
|
-
Scenario: Create a new extension scaffold
|
4
|
-
Given I run `middleman extension my-extension-library`
|
5
|
-
Then the exit status should be 0
|
6
|
-
When I cd to "my-extension-library"
|
7
|
-
Then the following files should exist:
|
8
|
-
| Gemfile |
|
9
|
-
| Rakefile |
|
10
|
-
| my-extension-library.gemspec |
|
11
|
-
| features/support/env.rb |
|
12
|
-
| lib/my-extension-library/extension.rb |
|
13
|
-
| lib/my-extension-library.rb |
|
14
|
-
| .gitignore |
|
data/features/cli_init.feature
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
Feature: Middleman CLI
|
2
|
-
|
3
|
-
Scenario: Create a new project
|
4
|
-
When I run `middleman init MY_PROJECT` interactively
|
5
|
-
And I type "y"
|
6
|
-
And I type "y"
|
7
|
-
And I type "y"
|
8
|
-
And I type "y"
|
9
|
-
Then the exit status should be 0
|
10
|
-
When I cd to "MY_PROJECT"
|
11
|
-
Then the following files should exist:
|
12
|
-
| Gemfile |
|
13
|
-
| .gitignore |
|
14
|
-
| config.rb |
|
15
|
-
| source/index.html.erb |
|
16
|
-
| source/layouts/layout.erb |
|
17
|
-
| source/javascripts/all.js |
|
18
|
-
| source/stylesheets/site.css.scss |
|
19
|
-
| source/stylesheets/_normalize.scss |
|
20
|
-
|
21
|
-
Scenario: Create a new project in the current directory
|
22
|
-
Given a directory named "MY_PROJECT"
|
23
|
-
When I cd to "MY_PROJECT"
|
24
|
-
And I run `middleman init` interactively
|
25
|
-
And I type "y"
|
26
|
-
And I type "y"
|
27
|
-
And I type "y"
|
28
|
-
And I type "y"
|
29
|
-
Then the exit status should be 0
|
30
|
-
And the following files should exist:
|
31
|
-
| Gemfile |
|
32
|
-
| config.rb |
|
33
|
-
| source/index.html.erb |
|
34
|
-
|
35
|
-
Scenario: Create a new project (alias i)
|
36
|
-
When I run `middleman i MY_PROJECT` interactively
|
37
|
-
And I type "y"
|
38
|
-
And I type "y"
|
39
|
-
And I type "y"
|
40
|
-
And I type "y"
|
41
|
-
Then a directory named "MY_PROJECT" should exist
|
42
|
-
|
43
|
-
Scenario: Create a new project (alias new)
|
44
|
-
When I run `middleman new MY_PROJECT` interactively
|
45
|
-
And I type "y"
|
46
|
-
And I type "y"
|
47
|
-
And I type "y"
|
48
|
-
And I type "y"
|
49
|
-
Then a directory named "MY_PROJECT" should exist
|
50
|
-
|
51
|
-
Scenario: Create a new project (alias n)
|
52
|
-
When I run `middleman n MY_PROJECT` interactively
|
53
|
-
And I type "y"
|
54
|
-
And I type "y"
|
55
|
-
And I type "y"
|
56
|
-
And I type "y"
|
57
|
-
Then a directory named "MY_PROJECT" should exist
|
58
|
-
|
59
|
-
Scenario: Create a new project using Middleman directory
|
60
|
-
When I run `middleman init MY_PROJECT -T blog`
|
61
|
-
Then a directory named "MY_PROJECT" should exist
|
62
|
-
When I cd to "MY_PROJECT"
|
63
|
-
And the file "Gemfile" should contain "middleman-blog"
|
64
|
-
And the file ".gitignore" should exist
|
65
|
-
|
66
|
-
Scenario: Create a new project using github(user/repository)
|
67
|
-
When I run `middleman init MY_PROJECT -T middleman/middleman-templates-default` interactively
|
68
|
-
And I type "y"
|
69
|
-
And I type "y"
|
70
|
-
And I type "y"
|
71
|
-
And I type "y"
|
72
|
-
Then a directory named "MY_PROJECT" should exist
|
73
|
-
|
74
|
-
Scenario: Create a new project using github(user/repository#branch)
|
75
|
-
When I run `middleman init MY_PROJECT -T middleman/middleman-templates-default#master` interactively
|
76
|
-
And I type "y"
|
77
|
-
And I type "y"
|
78
|
-
And I type "y"
|
79
|
-
And I type "y"
|
80
|
-
Then a directory named "MY_PROJECT" should exist
|
81
|
-
And the output should contain "-b master"
|
82
|
-
|
83
|
-
Scenario: Create a new project using full path(://)
|
84
|
-
When I run `middleman init MY_PROJECT -T https://github.com/middleman/middleman-templates-default.git` interactively
|
85
|
-
And I type "y"
|
86
|
-
And I type "y"
|
87
|
-
And I type "y"
|
88
|
-
And I type "y"
|
89
|
-
Then a directory named "MY_PROJECT" should exist
|
@@ -1,33 +0,0 @@
|
|
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
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
<h1>Welcome</h1>
|
@@ -1 +0,0 @@
|
|
1
|
-
I am real
|
@@ -1 +0,0 @@
|
|
1
|
-
<h1>Ignore me!</h1>
|
@@ -1 +0,0 @@
|
|
1
|
-
<h1>Ignore me! 2</h1>
|
@@ -1 +0,0 @@
|
|
1
|
-
<h1>Ignore me! 3</h1>
|
@@ -1 +0,0 @@
|
|
1
|
-
Static, no code!
|
@@ -1,19 +0,0 @@
|
|
1
|
-
set :layout, false
|
2
|
-
|
3
|
-
class MyFeature < Middleman::Extension
|
4
|
-
def initialize(app, options_hash = {}, &block)
|
5
|
-
super
|
6
|
-
|
7
|
-
app.before_server do |server_information|
|
8
|
-
puts "/// #{server_information.listeners.first} ///"
|
9
|
-
puts "/// #{server_information.port} ///"
|
10
|
-
puts "/// #{server_information.server_name} ///"
|
11
|
-
puts "/// #{server_information.site_addresses.first} ///"
|
12
|
-
puts "/// ### END ### ///"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
::Middleman::Extensions.register(:my_feature, MyFeature)
|
18
|
-
|
19
|
-
activate :my_feature
|
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'rack'
|
2
|
-
require 'rack/response'
|
3
|
-
require 'addressable/uri'
|
4
|
-
require 'middleman-core/util'
|
5
|
-
require 'middleman-core/contracts'
|
6
|
-
|
7
|
-
module Middleman
|
8
|
-
module Middleware
|
9
|
-
class InlineURLRewriter
|
10
|
-
include Contracts
|
11
|
-
|
12
|
-
IGNORE_DESCRIPTOR = Or[Regexp, RespondTo[:call], String]
|
13
|
-
|
14
|
-
Contract RespondTo[:call], ({
|
15
|
-
middleman_app: IsA['Middleman::Application'],
|
16
|
-
id: Maybe[Symbol],
|
17
|
-
proc: Or[Proc, Method],
|
18
|
-
url_extensions: ArrayOf[String],
|
19
|
-
source_extensions: ArrayOf[String],
|
20
|
-
ignore: ArrayOf[IGNORE_DESCRIPTOR]
|
21
|
-
}) => Any
|
22
|
-
def initialize(app, options={})
|
23
|
-
@rack_app = app
|
24
|
-
@middleman_app = options.fetch(:middleman_app)
|
25
|
-
|
26
|
-
@uid = options.fetch(:id, nil)
|
27
|
-
@proc = options.fetch(:proc)
|
28
|
-
|
29
|
-
raise 'InlineURLRewriter requires a :proc to call with inline URL results' unless @proc
|
30
|
-
|
31
|
-
@exts = options.fetch(:url_extensions)
|
32
|
-
|
33
|
-
@source_exts = options.fetch(:source_extensions)
|
34
|
-
@source_exts_regex_text = Regexp.union(@source_exts).to_s
|
35
|
-
|
36
|
-
@ignore = options.fetch(:ignore)
|
37
|
-
@rewrite_ignore = Array(options.fetch(:rewrite_ignore, []))
|
38
|
-
end
|
39
|
-
|
40
|
-
def call(env)
|
41
|
-
status, headers, response = @rack_app.call(env)
|
42
|
-
|
43
|
-
# Allow configuration or upstream request to skip all rewriting
|
44
|
-
if rewrite_ignore?(env['PATH_INFO']) || env['bypass_inline_url_rewriter'] == 'true'
|
45
|
-
return [status, headers, response]
|
46
|
-
end
|
47
|
-
|
48
|
-
# Allow upstream request to skip this specific rewriting
|
49
|
-
if @uid
|
50
|
-
uid_key = "bypass_inline_url_rewriter_#{@uid}"
|
51
|
-
return [status, headers, response] if env[uid_key] == 'true'
|
52
|
-
end
|
53
|
-
|
54
|
-
path = ::Middleman::Util.full_path(env['PATH_INFO'], @middleman_app)
|
55
|
-
|
56
|
-
if path =~ /(^\/$)|(#{@source_exts_regex_text}$)/
|
57
|
-
if body = ::Middleman::Util.extract_response_text(response)
|
58
|
-
|
59
|
-
dirpath = Pathname.new(File.dirname(path))
|
60
|
-
|
61
|
-
rewritten = ::Middleman::Util.rewrite_paths(body, path, @exts) do |asset_path|
|
62
|
-
uri = ::Addressable::URI.parse(asset_path)
|
63
|
-
|
64
|
-
relative_path = uri.host.nil?
|
65
|
-
|
66
|
-
full_asset_path = if relative_path
|
67
|
-
dirpath.join(asset_path).to_s
|
68
|
-
else
|
69
|
-
asset_path
|
70
|
-
end
|
71
|
-
|
72
|
-
@ignore.none? { |r| should_ignore?(r, full_asset_path) } && @proc.call(asset_path, dirpath, path)
|
73
|
-
end
|
74
|
-
|
75
|
-
status, headers, response = ::Rack::Response.new(
|
76
|
-
rewritten,
|
77
|
-
status,
|
78
|
-
headers
|
79
|
-
).finish
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
[status, headers, response]
|
84
|
-
end
|
85
|
-
|
86
|
-
Contract IGNORE_DESCRIPTOR, String => Bool
|
87
|
-
def should_ignore?(validator, value)
|
88
|
-
if validator.is_a? Regexp
|
89
|
-
# Treat as Regexp
|
90
|
-
!value.match(validator).nil?
|
91
|
-
elsif validator.respond_to? :call
|
92
|
-
# Treat as proc
|
93
|
-
validator.call(value)
|
94
|
-
elsif validator.is_a? String
|
95
|
-
# Treat as glob
|
96
|
-
File.fnmatch(value, validator)
|
97
|
-
else
|
98
|
-
# If some unknown thing, don't ignore
|
99
|
-
false
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
Contract String => Bool
|
104
|
-
def rewrite_ignore?(path)
|
105
|
-
@rewrite_ignore.any? { |ignore| Middleman::Util.path_match(ignore, path) }
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|