Minor tweak to #1695
This commit is contained in:
parent
b0582bcebf
commit
4594f46fb8
8 changed files with 20 additions and 33 deletions
|
@ -398,7 +398,6 @@ module Middleman
|
||||||
execute_callbacks(:before_shutdown)
|
execute_callbacks(:before_shutdown)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# Set attributes (global variables)
|
# Set attributes (global variables)
|
||||||
#
|
#
|
||||||
# @deprecated Prefer accessing settings through "config".
|
# @deprecated Prefer accessing settings through "config".
|
||||||
|
|
|
@ -37,7 +37,8 @@ module Middleman
|
||||||
engine = extension[1..-1].to_sym
|
engine = extension[1..-1].to_sym
|
||||||
|
|
||||||
# Store last engine for later (could be inside nested renders)
|
# Store last engine for later (could be inside nested renders)
|
||||||
context.current_engine, engine_was = engine, context.current_engine
|
context.current_engine = engine
|
||||||
|
engine_was = context.current_engine
|
||||||
|
|
||||||
# Save current buffer for later
|
# Save current buffer for later
|
||||||
buf_was = context.save_buffer
|
buf_was = context.save_buffer
|
||||||
|
|
|
@ -62,7 +62,7 @@ module Middleman
|
||||||
# To output the child PID, let's make preview server a daemon by hand
|
# To output the child PID, let's make preview server a daemon by hand
|
||||||
if child_pid = fork
|
if child_pid = fork
|
||||||
app.logger.info "== Middleman preview server is running in background with PID #{child_pid}"
|
app.logger.info "== Middleman preview server is running in background with PID #{child_pid}"
|
||||||
Process.detach child_pid
|
Process.detach child_pid
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
$stdout.reopen('/dev/null', 'w')
|
$stdout.reopen('/dev/null', 'w')
|
||||||
|
@ -183,7 +183,7 @@ module Middleman
|
||||||
|
|
||||||
app.logger.warn format('== The Middleman uses a different port "%s" then the configured one "%s" because some other server is listening on that port.', server_information.port, configured_port) unless app.config[:port] == configured_port
|
app.logger.warn format('== The Middleman uses a different port "%s" then the configured one "%s" because some other server is listening on that port.', server_information.port, configured_port) unless app.config[:port] == configured_port
|
||||||
|
|
||||||
@environment = app.config[:environment]
|
@environment = app.config[:environment]
|
||||||
|
|
||||||
@ssl_certificate = app.config[:ssl_certificate]
|
@ssl_certificate = app.config[:ssl_certificate]
|
||||||
@ssl_private_key = app.config[:ssl_private_key]
|
@ssl_private_key = app.config[:ssl_private_key]
|
||||||
|
|
|
@ -13,15 +13,15 @@ module Middleman
|
||||||
attr_reader :server_name, :port, :site_addresses, :listeners
|
attr_reader :server_name, :port, :site_addresses, :listeners
|
||||||
|
|
||||||
def initialize(server_information)
|
def initialize(server_information)
|
||||||
@listeners = ServerUrl.new(
|
@listeners = ServerUrl.new(
|
||||||
hosts: server_information.listeners,
|
hosts: server_information.listeners,
|
||||||
port: server_information.port,
|
port: server_information.port,
|
||||||
https: server_information.https?,
|
https: server_information.https?,
|
||||||
format_output: false
|
format_output: false
|
||||||
).to_bind_addresses
|
).to_bind_addresses
|
||||||
|
|
||||||
@port = server_information.port
|
@port = server_information.port
|
||||||
@server_name = server_information.server_name.dup unless server_information.server_name == nil
|
@server_name = server_information.server_name.dup unless server_information.server_name.nil?
|
||||||
|
|
||||||
@site_addresses = ServerUrl.new(
|
@site_addresses = ServerUrl.new(
|
||||||
hosts: server_information.site_addresses,
|
hosts: server_information.site_addresses,
|
||||||
|
|
|
@ -133,9 +133,7 @@ module Middleman
|
||||||
locs[:current_path] ||= destination_path
|
locs[:current_path] ||= destination_path
|
||||||
|
|
||||||
# Certain output file types don't use layouts
|
# Certain output file types don't use layouts
|
||||||
unless opts.key?(:layout)
|
opts[:layout] = false unless opts.key?(:layout) || !ext != '.html'
|
||||||
opts[:layout] = false if ext != '.html'
|
|
||||||
end
|
|
||||||
|
|
||||||
renderer = ::Middleman::TemplateRenderer.new(@app, file_descriptor[:full_path].to_s)
|
renderer = ::Middleman::TemplateRenderer.new(@app, file_descriptor[:full_path].to_s)
|
||||||
renderer.render(locs, opts)
|
renderer.render(locs, opts)
|
||||||
|
|
|
@ -182,14 +182,8 @@ module Middleman
|
||||||
# @return [void]
|
# @return [void]
|
||||||
Contract Any
|
Contract Any
|
||||||
def poll_once!
|
def poll_once!
|
||||||
removed = @files.keys
|
updated = ::Middleman::Util.all_files_under(@directory.to_s)
|
||||||
|
removed = @files.keys.reject { |p| updated.include?(p) }
|
||||||
updated = []
|
|
||||||
|
|
||||||
::Middleman::Util.all_files_under(@directory.to_s).each do |filepath|
|
|
||||||
removed.delete(filepath)
|
|
||||||
updated << filepath
|
|
||||||
end
|
|
||||||
|
|
||||||
update(updated, removed)
|
update(updated, removed)
|
||||||
|
|
||||||
|
@ -314,16 +308,10 @@ module Middleman
|
||||||
# @return [Array] All related file paths, not including the source file paths.
|
# @return [Array] All related file paths, not including the source file paths.
|
||||||
Contract ArrayOf[String] => ArrayOf[String]
|
Contract ArrayOf[String] => ArrayOf[String]
|
||||||
def find_related_files(files)
|
def find_related_files(files)
|
||||||
files.map do |file|
|
files.flat_map do |file|
|
||||||
related_files = []
|
# If any partial file changes, reload all non-partials
|
||||||
|
Dir[File.join(@directory, app.config[:source], "**/[^_]*.#{File.extname(file)}")] if File.basename(file).start_with?('_')
|
||||||
# If any SASS file changes, reload all non-partials
|
end.compact.uniq - files
|
||||||
if file =~ /\.(sass|scss)$/
|
|
||||||
related_files |= Dir[File.join(@directory, app.config[:css_dir], '**/[^_]*.{scss,sass}')]
|
|
||||||
end
|
|
||||||
|
|
||||||
related_files
|
|
||||||
end.flatten.uniq - files
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,7 +42,8 @@ module Middleman
|
||||||
# @api private
|
# @api private
|
||||||
# @return [String] The old buffer.
|
# @return [String] The old buffer.
|
||||||
def save_buffer
|
def save_buffer
|
||||||
@_out_buf, buf_was = '', @_out_buf
|
buf_was = @_out_buf
|
||||||
|
@_out_buf = ''
|
||||||
buf_was
|
buf_was
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,10 @@ module Middleman::Util::Data
|
||||||
end
|
end
|
||||||
|
|
||||||
start_delims, stop_delims = frontmatter_delims
|
start_delims, stop_delims = frontmatter_delims
|
||||||
.values
|
.values
|
||||||
.flatten(1)
|
.flatten(1)
|
||||||
.transpose
|
.transpose
|
||||||
.map(&Regexp.method(:union))
|
.map(&Regexp.method(:union))
|
||||||
|
|
||||||
match = /
|
match = /
|
||||||
\A(?:[^\r\n]*coding:[^\r\n]*\r?\n)?
|
\A(?:[^\r\n]*coding:[^\r\n]*\r?\n)?
|
||||||
|
|
Loading…
Reference in a new issue