mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
Merge pull request #1508 from bhollis/localhost
Port "localhost" preview server URL to v3-stable
This commit is contained in:
commit
bd67f8ad0e
3 changed files with 16 additions and 4 deletions
|
@ -2,6 +2,8 @@ master
|
||||||
===
|
===
|
||||||
|
|
||||||
* The preview server can now serve over HTTPS using the `--https` flag. It will use an automatic self-signed cert which can be overridden using `--ssl_certificate` and `--ssl_private_key`. These settings can also be set in `config.rb`
|
* The preview server can now serve over HTTPS using the `--https` flag. It will use an automatic self-signed cert which can be overridden using `--ssl_certificate` and `--ssl_private_key`. These settings can also be set in `config.rb`
|
||||||
|
* The preview server URL will use 'localhost' rather than '0.0.0.0'.
|
||||||
|
* The preview server URL will once again use the machine's hostname if available.
|
||||||
|
|
||||||
3.3.11
|
3.3.11
|
||||||
===
|
===
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
require 'socket'
|
||||||
|
|
||||||
# Using Tilt for templating
|
# Using Tilt for templating
|
||||||
require 'tilt'
|
require 'tilt'
|
||||||
|
|
||||||
|
@ -69,7 +71,7 @@ module Middleman
|
||||||
|
|
||||||
# Which host preview should start on.
|
# Which host preview should start on.
|
||||||
# @return [Fixnum]
|
# @return [Fixnum]
|
||||||
config.define_setting :host, '0.0.0.0', 'The preview server host'
|
config.define_setting :host, Socket.gethostname, 'The preview server host'
|
||||||
|
|
||||||
# Which port preview should start on.
|
# Which port preview should start on.
|
||||||
# @return [Fixnum]
|
# @return [Fixnum]
|
||||||
|
|
|
@ -21,9 +21,8 @@ module Middleman
|
||||||
@options = opts
|
@options = opts
|
||||||
|
|
||||||
mount_instance(new_app)
|
mount_instance(new_app)
|
||||||
scheme = https? ? 'https' : 'http'
|
logger.info "== The Middleman is standing watch at #{uri}"
|
||||||
logger.info "== The Middleman is standing watch at #{scheme}://#{host}:#{port}"
|
logger.info "== Inspect your site configuration at #{uri + '__middleman'}"
|
||||||
logger.info "== Inspect your site configuration at #{scheme}://#{host}:#{port}/__middleman/"
|
|
||||||
|
|
||||||
@initialized ||= false
|
@initialized ||= false
|
||||||
return if @initialized
|
return if @initialized
|
||||||
|
@ -264,6 +263,15 @@ module Middleman
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns the URI the preview server will run on
|
||||||
|
# @return [URI]
|
||||||
|
def uri
|
||||||
|
host = @host == '0.0.0.0' ? 'localhost' : @host
|
||||||
|
scheme = https? ? 'https' : 'http'
|
||||||
|
URI("#{scheme}://#{host}:#{@port}")
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class FilteredWebrickLog < ::WEBrick::Log
|
class FilteredWebrickLog < ::WEBrick::Log
|
||||||
|
|
Loading…
Reference in a new issue