middleman-core 3.4.0 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -7
- data/features/clean_build.feature +18 -0
- data/features/cli/preview_server-hook.feature +17 -0
- data/features/cli/preview_server.feature +20 -20
- data/features/data.feature +28 -0
- data/features/step_definitions/queryable_steps.rb +122 -45
- data/features/stylus.feature +1 -1
- data/fixtures/asciidoc-app/source/hello-with-title.adoc +1 -0
- data/fixtures/clean-app/config-hidden-dir-after.rb +5 -0
- data/fixtures/clean-app/config-hidden-dir-before.rb +1 -0
- data/fixtures/preview-server-hook-app/config.rb +19 -0
- data/fixtures/preview-server-hook-app/source/index.html.erb +9 -0
- data/lib/middleman-core.rb +0 -4
- data/lib/middleman-core/application.rb +3 -0
- data/lib/middleman-core/cli.rb +1 -1
- data/lib/middleman-core/cli/build.rb +1 -1
- data/lib/middleman-core/cli/server.rb +1 -1
- data/lib/middleman-core/configuration.rb +1 -1
- data/lib/middleman-core/core_extensions/data.rb +4 -8
- data/lib/middleman-core/core_extensions/data/file_loader.rb +71 -0
- data/lib/middleman-core/core_extensions/rendering.rb +8 -8
- data/lib/middleman-core/core_extensions/show_exceptions.rb +1 -1
- data/lib/middleman-core/dns_resolver/basic_network_resolver.rb +2 -2
- data/lib/middleman-core/extensions.rb +0 -2
- data/lib/middleman-core/meta_pages/sitemap_resource.rb +2 -0
- data/lib/middleman-core/meta_pages/sitemap_tree.rb +1 -1
- data/lib/middleman-core/preview_server.rb +9 -10
- data/lib/middleman-core/preview_server/server_information.rb +12 -3
- data/lib/middleman-core/preview_server/server_information_callback_proxy.rb +35 -0
- data/lib/middleman-core/preview_server/server_url.rb +17 -4
- data/lib/middleman-core/renderers/asciidoc.rb +1 -1
- data/lib/middleman-core/renderers/liquid.rb +1 -1
- data/lib/middleman-core/sitemap/extensions/content_type.rb +1 -1
- data/lib/middleman-core/sitemap/store.rb +9 -8
- data/lib/middleman-core/step_definitions.rb +1 -1
- data/lib/middleman-core/step_definitions/builder_steps.rb +10 -12
- data/lib/middleman-core/step_definitions/commandline_steps.rb +9 -9
- data/lib/middleman-core/step_definitions/middleman_steps.rb +10 -2
- data/lib/middleman-core/step_definitions/server_steps.rb +50 -30
- data/lib/middleman-core/templates/shared/Gemfile.tt +2 -2
- data/lib/middleman-core/templates/shared/config.ru +0 -1
- data/lib/middleman-core/templates/shared/gitignore +3 -0
- data/lib/middleman-core/util.rb +1 -1
- data/lib/middleman-core/version.rb +1 -1
- data/lib/middleman-more/core_extensions/default_helpers.rb +13 -2
- data/lib/middleman-more/extensions/cache_buster.rb +1 -1
- data/middleman-core.gemspec +4 -2
- metadata +15 -5
- data/.gemtest +0 -0
- data/.rspec +0 -1
@@ -6,7 +6,7 @@ module Middleman
|
|
6
6
|
class ServerUrl
|
7
7
|
private
|
8
8
|
|
9
|
-
attr_reader :hosts, :port, :https
|
9
|
+
attr_reader :hosts, :port, :https, :format_output
|
10
10
|
|
11
11
|
public
|
12
12
|
|
@@ -14,6 +14,7 @@ module Middleman
|
|
14
14
|
@hosts = opts.fetch(:hosts)
|
15
15
|
@port = opts.fetch(:port)
|
16
16
|
@https = opts.fetch(:https, false)
|
17
|
+
@format_output = opts.fetch(:format_output, true)
|
17
18
|
end
|
18
19
|
|
19
20
|
# Return bind addresses
|
@@ -21,7 +22,11 @@ module Middleman
|
|
21
22
|
# @return [Array]
|
22
23
|
# List of bind addresses of format host:port
|
23
24
|
def to_bind_addresses
|
24
|
-
|
25
|
+
if format_output
|
26
|
+
hosts.map { |l| format('"%s:%s"', l.to_s, port) }
|
27
|
+
else
|
28
|
+
hosts.map { |l| format('%s:%s', l.to_s, port) }
|
29
|
+
end
|
25
30
|
end
|
26
31
|
|
27
32
|
# Return server urls
|
@@ -29,7 +34,11 @@ module Middleman
|
|
29
34
|
# @return [Array]
|
30
35
|
# List of urls of format http://host:port
|
31
36
|
def to_urls
|
32
|
-
|
37
|
+
if format_output
|
38
|
+
hosts.map { |l| format('"%s://%s:%s"', https? ? 'https' : 'http', l.to_browser, port) }
|
39
|
+
else
|
40
|
+
hosts.map { |l| format('%s://%s:%s', https? ? 'https' : 'http', l.to_browser, port) }
|
41
|
+
end
|
33
42
|
end
|
34
43
|
|
35
44
|
# Return server config urls
|
@@ -37,7 +46,11 @@ module Middleman
|
|
37
46
|
# @return [Array]
|
38
47
|
# List of urls of format http://host:port/__middleman
|
39
48
|
def to_config_urls
|
40
|
-
|
49
|
+
if format_output
|
50
|
+
hosts.map { |l| format('"%s://%s:%s/__middleman"', https? ? 'https' : 'http', l.to_browser, port) }
|
51
|
+
else
|
52
|
+
hosts.map { |l| format('%s://%s:%s/__middleman', https? ? 'https' : 'http', l.to_browser, port) }
|
53
|
+
end
|
41
54
|
end
|
42
55
|
|
43
56
|
private
|
@@ -8,7 +8,7 @@ module Middleman
|
|
8
8
|
app.config.define_setting :asciidoc, {
|
9
9
|
safe: :safe,
|
10
10
|
backend: :html5,
|
11
|
-
attributes: %W(
|
11
|
+
attributes: %W(env=middleman env-middleman middleman-version=#{::Middleman::VERSION})
|
12
12
|
}, 'AsciiDoc engine options (Hash)'
|
13
13
|
app.config.define_setting :asciidoc_attributes, [], 'AsciiDoc custom attributes (Array)'
|
14
14
|
app.before_configuration do
|
@@ -5,7 +5,7 @@ module Middleman::Sitemap::Extensions
|
|
5
5
|
module ContentType
|
6
6
|
# The preferred MIME content type for this resource
|
7
7
|
def content_type
|
8
|
-
# Allow
|
8
|
+
# Allow explicitly setting content type from page/proxy options
|
9
9
|
meta_type = metadata[:options][:content_type]
|
10
10
|
return meta_type if meta_type
|
11
11
|
|
@@ -54,7 +54,7 @@ module Middleman
|
|
54
54
|
rebuild_resource_list!(:registered_new)
|
55
55
|
end
|
56
56
|
|
57
|
-
# Rebuild the list of resources from scratch, using
|
57
|
+
# Rebuild the list of resources from scratch, using registered manipulators
|
58
58
|
# rubocop:disable UnusedMethodArgument
|
59
59
|
# @return [void]
|
60
60
|
def rebuild_resource_list!(reason=nil)
|
@@ -99,7 +99,7 @@ module Middleman
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
# Invalidate our cached view of resource that are not
|
102
|
+
# Invalidate our cached view of resource that are not ignored. If your extension
|
103
103
|
# adds ways to ignore files, you should call this to make sure #resources works right.
|
104
104
|
def invalidate_resources_not_ignored_cache!
|
105
105
|
@resources_not_ignored = nil
|
@@ -211,20 +211,21 @@ module Middleman
|
|
211
211
|
|
212
212
|
@app.logger.debug '== Rebuilding resource list'
|
213
213
|
|
214
|
-
@resources =
|
215
|
-
|
214
|
+
@resources = []
|
215
|
+
|
216
|
+
@resource_list_manipulators.each do |(_, inst)|
|
217
|
+
@resources = inst.manipulate_resource_list(@resources)
|
216
218
|
|
217
219
|
# Reset lookup cache
|
218
220
|
reset_lookup_cache!
|
219
|
-
|
221
|
+
|
222
|
+
@resources.each do |resource|
|
220
223
|
@_lookup_by_path[resource.path] = resource
|
221
224
|
@_lookup_by_destination_path[resource.destination_path] = resource
|
222
225
|
end
|
223
226
|
|
224
|
-
|
227
|
+
invalidate_resources_not_ignored_cache!
|
225
228
|
end
|
226
|
-
|
227
|
-
invalidate_resources_not_ignored_cache!
|
228
229
|
end
|
229
230
|
end
|
230
231
|
|
@@ -5,29 +5,27 @@ Before do
|
|
5
5
|
end
|
6
6
|
|
7
7
|
Given /^app "([^\"]*)" is using config "([^\"]*)"$/ do |path, config_name|
|
8
|
-
|
9
|
-
config_path = File.join(current_directory, "config-#{config_name}.rb")
|
10
|
-
config_dest = File.join(current_directory, 'config.rb')
|
11
|
-
FileUtils.cp(config_path, config_dest)
|
8
|
+
copy("config-#{config_name}.rb", 'config.rb')
|
12
9
|
end
|
13
10
|
|
14
11
|
Given /^an empty app$/ do
|
15
12
|
step %Q{a directory named "empty_app"}
|
16
13
|
step %Q{I cd to "empty_app"}
|
17
|
-
|
14
|
+
|
15
|
+
delete_environment_variable 'MM_ROOT'
|
18
16
|
end
|
19
17
|
|
20
18
|
Given /^a fixture app "([^\"]*)"$/ do |path|
|
21
|
-
|
19
|
+
delete_environment_variable 'MM_ROOT'
|
22
20
|
|
23
21
|
# This step can be reentered from several places but we don't want
|
24
22
|
# to keep re-copying and re-cd-ing into ever-deeper directories
|
25
|
-
next if File.basename(
|
23
|
+
next if File.basename(expand_path('.')) == path
|
26
24
|
|
27
25
|
step %Q{a directory named "#{path}"}
|
28
26
|
|
29
27
|
target_path = File.join(PROJECT_ROOT_PATH, 'fixtures', path)
|
30
|
-
FileUtils.cp_r(target_path,
|
28
|
+
FileUtils.cp_r(target_path, expand_path('.'))
|
31
29
|
|
32
30
|
step %Q{I cd to "#{path}"}
|
33
31
|
end
|
@@ -58,20 +56,20 @@ Given /^a successfully built app at "([^\"]*)" with flags "([^\"]*)"$/ do |path,
|
|
58
56
|
end
|
59
57
|
|
60
58
|
Given /^a modification time for a file named "([^\"]*)"$/ do |file|
|
61
|
-
target =
|
59
|
+
target = expand_path(file)
|
62
60
|
@modification_times[target] = File.mtime(target)
|
63
61
|
end
|
64
62
|
|
65
63
|
Then /^the file "([^\"]*)" should not have been updated$/ do |file|
|
66
|
-
target =
|
64
|
+
target = expand_path(file)
|
67
65
|
File.mtime(target).should == @modification_times[target]
|
68
66
|
end
|
69
67
|
|
70
68
|
# Provide this Aruba overload in case we're matching something with quotes in it
|
71
69
|
Then /^the file "([^"]*)" should contain '([^']*)'$/ do |file, partial_content|
|
72
|
-
|
70
|
+
expect(file).to have_file_content Regexp.new(Regexp.escape(partial_content))
|
73
71
|
end
|
74
72
|
|
75
73
|
And /the file "(.*)" should be gzipped/ do |file|
|
76
|
-
expect(File.binread(
|
74
|
+
expect(File.binread(expand_path(file), 2)).to eq(['1F8B'].pack('H*'))
|
77
75
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
When /^I stop (?:middleman|all commands) if the output( of the last command)? contains:$/ do |last_command, expected|
|
2
2
|
begin
|
3
|
-
Timeout.timeout(exit_timeout) do
|
3
|
+
Timeout.timeout(aruba.config.exit_timeout) do
|
4
4
|
loop do
|
5
|
-
fail "You need to start middleman interactively first."
|
5
|
+
fail "You need to start middleman interactively first." if last_command_started.nil?
|
6
6
|
|
7
|
-
if
|
8
|
-
|
7
|
+
if sanitize_text(last_command_started.output) =~ Regexp.new(sanitize_text(expected))
|
8
|
+
terminate_all_commands
|
9
9
|
break
|
10
10
|
end
|
11
11
|
|
@@ -13,10 +13,10 @@ When /^I stop (?:middleman|all commands) if the output( of the last command)? co
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
rescue ChildProcess::TimeoutError, TimeoutError
|
16
|
-
|
16
|
+
terminate_all_commands
|
17
17
|
ensure
|
18
|
-
announcer.stdout
|
19
|
-
announcer.stderr
|
18
|
+
announcer.announce :stdout, last_command_started.stdout
|
19
|
+
announcer.announce :stderr, last_command_started.stderr
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -68,7 +68,7 @@ Given /I start a mdns server with:/ do |string|
|
|
68
68
|
)
|
69
69
|
)
|
70
70
|
|
71
|
-
|
71
|
+
set_environment_variable 'PATH', File.expand_path(File.join(current_dir, 'bin')) + ':' + ENV['PATH']
|
72
72
|
write_file db_file, string
|
73
73
|
|
74
74
|
@mdns_server = run("dns_server.rb #{db_file} #{port}", 120)
|
@@ -80,7 +80,7 @@ end
|
|
80
80
|
|
81
81
|
# Make sure each and every process is really dead
|
82
82
|
After do
|
83
|
-
|
83
|
+
terminate_all_commands
|
84
84
|
end
|
85
85
|
|
86
86
|
Before '@ruby-2.1' do
|
@@ -9,9 +9,17 @@ Then /^the file "([^\"]*)" is removed$/ do |path|
|
|
9
9
|
end
|
10
10
|
|
11
11
|
Then /^the file "([^\"]*)" did change$/ do |path|
|
12
|
-
|
12
|
+
cd '.' do
|
13
|
+
with_environment do
|
14
|
+
@server_inst.files.did_change(path)
|
15
|
+
end
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
19
|
Then /^the file "([^\"]*)" did delete$/ do |path|
|
16
|
-
|
20
|
+
cd '.' do
|
21
|
+
with_environment do
|
22
|
+
@server_inst.files.did_delete(path)
|
23
|
+
end
|
24
|
+
end
|
17
25
|
end
|
@@ -31,15 +31,13 @@ Given /^current environment is "([^\"]*)"$/ do |env|
|
|
31
31
|
end
|
32
32
|
|
33
33
|
Given /^the Server is running$/ do
|
34
|
-
|
35
|
-
|
36
|
-
if File.exists?(File.join(root_dir, 'source'))
|
37
|
-
ENV['MM_SOURCE'] = 'source'
|
34
|
+
if exist? 'source'
|
35
|
+
set_environment_variable 'MM_SOURCE', 'source'
|
38
36
|
else
|
39
|
-
|
37
|
+
set_environment_variable 'MM_SOURCE', ''
|
40
38
|
end
|
41
39
|
|
42
|
-
|
40
|
+
set_environment_variable 'MM_ROOT', expand_path('.')
|
43
41
|
|
44
42
|
initialize_commands = @initialize_commands || []
|
45
43
|
initialize_commands.unshift lambda {
|
@@ -47,10 +45,12 @@ Given /^the Server is running$/ do
|
|
47
45
|
set :show_exceptions, false
|
48
46
|
}
|
49
47
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
cd '.' do
|
49
|
+
with_environment do
|
50
|
+
@server_inst = Middleman::Application.server.inst do
|
51
|
+
initialize_commands.each do |p|
|
52
|
+
instance_exec(&p)
|
53
|
+
end
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -68,61 +68,81 @@ Given /^a template named "([^\"]*)" with:$/ do |name, string|
|
|
68
68
|
end
|
69
69
|
|
70
70
|
When /^I go to "([^\"]*)"$/ do |url|
|
71
|
-
|
72
|
-
|
71
|
+
cd '.' do
|
72
|
+
with_environment do
|
73
|
+
visit(URI.encode(url).to_s)
|
74
|
+
end
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|
76
78
|
Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
|
77
|
-
|
78
|
-
|
79
|
+
cd '.' do
|
80
|
+
with_environment do
|
81
|
+
expect{ visit(URI.encode(url).to_s) }.to_not raise_exception
|
82
|
+
end
|
79
83
|
end
|
80
84
|
end
|
81
85
|
|
82
86
|
Then /^the content type should be "([^\"]*)"$/ do |expected|
|
83
|
-
|
84
|
-
|
87
|
+
cd '.' do
|
88
|
+
with_environment do
|
89
|
+
expect(page.response_headers['Content-Type']).to start_with expected
|
90
|
+
end
|
85
91
|
end
|
86
92
|
end
|
87
93
|
|
88
94
|
Then /^I should see "([^\"]*)"$/ do |expected|
|
89
|
-
|
90
|
-
|
95
|
+
cd '.' do
|
96
|
+
with_environment do
|
97
|
+
expect(page.body).to include expected
|
98
|
+
end
|
91
99
|
end
|
92
100
|
end
|
93
101
|
|
94
102
|
Then /^I should see '([^\']*)'$/ do |expected|
|
95
|
-
|
96
|
-
|
103
|
+
cd '.' do
|
104
|
+
with_environment do
|
105
|
+
expect(page.body).to include expected
|
106
|
+
end
|
97
107
|
end
|
98
108
|
end
|
99
109
|
|
100
110
|
Then /^I should see:$/ do |expected|
|
101
|
-
|
102
|
-
|
111
|
+
cd '.' do
|
112
|
+
with_environment do
|
113
|
+
expect(page.body).to include expected
|
114
|
+
end
|
103
115
|
end
|
104
116
|
end
|
105
117
|
|
106
118
|
Then /^I should not see "([^\"]*)"$/ do |expected|
|
107
|
-
|
108
|
-
|
119
|
+
cd '.' do
|
120
|
+
with_environment do
|
121
|
+
expect(page.body).not_to include expected
|
122
|
+
end
|
109
123
|
end
|
110
124
|
end
|
111
125
|
|
112
126
|
Then /^I should not see:$/ do |expected|
|
113
|
-
|
114
|
-
|
127
|
+
cd '.' do
|
128
|
+
with_environment do
|
129
|
+
expect(page.body).not_to include expected
|
130
|
+
end
|
115
131
|
end
|
116
132
|
end
|
117
133
|
|
118
134
|
Then /^the status code should be "([^\"]*)"$/ do |expected|
|
119
|
-
|
120
|
-
|
135
|
+
cd '.' do
|
136
|
+
with_environment do
|
137
|
+
expect(page.status_code).to eq expected.to_i
|
138
|
+
end
|
121
139
|
end
|
122
140
|
end
|
123
141
|
|
124
142
|
Then /^I should see "([^\"]*)" lines$/ do |lines|
|
125
|
-
|
126
|
-
|
143
|
+
cd '.' do
|
144
|
+
with_environment do
|
145
|
+
expect(page.body.chomp.split($/).length).to eq lines.to_i
|
146
|
+
end
|
127
147
|
end
|
128
148
|
end
|
@@ -5,10 +5,10 @@ source 'https://rubygems.org'
|
|
5
5
|
gem "middleman", "~><%= Middleman::VERSION %>"
|
6
6
|
|
7
7
|
# Live-reloading plugin
|
8
|
-
gem "middleman-livereload", "~> 3.
|
8
|
+
gem "middleman-livereload", "~> 3.3.0"
|
9
9
|
|
10
10
|
# For faster file watcher updates on Windows:
|
11
11
|
gem "wdm", "~> 0.1.0", :platforms => [:mswin, :mingw]
|
12
12
|
|
13
13
|
# Windows does not come with time zone data
|
14
|
-
gem "tzinfo-data", platforms: [:mswin, :mingw, :jruby]
|
14
|
+
gem "tzinfo-data", platforms: [:mswin, :mingw, :jruby]
|
data/lib/middleman-core/util.rb
CHANGED