override the host. now it is complete. no more changes ever need to be made to this. ever.
This commit is contained in:
parent
ccf888dd30
commit
eccebca01f
|
@ -19,7 +19,8 @@ MyApp::Application.configure do
|
||||||
Rack::Lock, Rack::LiveReload,
|
Rack::Lock, Rack::LiveReload,
|
||||||
:min_delay => 500,
|
:min_delay => 500,
|
||||||
:max_delay => 10000,
|
:max_delay => 10000,
|
||||||
:port => 56789
|
:port => 56789,
|
||||||
|
:host => 'myhost.cool.wow'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
@ -42,9 +43,5 @@ such a way that the `HTTP_HOST` is used as the LiveReload host, so you can conne
|
||||||
`mycomputer:3000` instead of `localhost:3000`) and as long as the LiveReload port is accessible from the external machine,
|
`mycomputer:3000` instead of `localhost:3000`) and as long as the LiveReload port is accessible from the external machine,
|
||||||
you'll connect and be LiveReloading away!
|
you'll connect and be LiveReloading away!
|
||||||
|
|
||||||
## To-do
|
|
||||||
|
|
||||||
* Override the `host`
|
|
||||||
|
|
||||||
As usual, super-alpha!
|
As usual, super-alpha!
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,11 @@ module Rack
|
||||||
body.each do |line|
|
body.each do |line|
|
||||||
if !headers['X-Rack-LiveReload'] && line['</head>']
|
if !headers['X-Rack-LiveReload'] && line['</head>']
|
||||||
src = LIVERELOAD_JS_PATH.dup
|
src = LIVERELOAD_JS_PATH.dup
|
||||||
|
if @options[:host]
|
||||||
|
src << "?host=#{@options[:host]}"
|
||||||
|
else
|
||||||
src << "?host=#{env['HTTP_HOST'].gsub(%r{:.*}, '')}" if env['HTTP_HOST']
|
src << "?host=#{env['HTTP_HOST'].gsub(%r{:.*}, '')}" if env['HTTP_HOST']
|
||||||
|
end
|
||||||
src << "&mindelay=#{@options[:min_delay]}" if @options[:min_delay]
|
src << "&mindelay=#{@options[:min_delay]}" if @options[:min_delay]
|
||||||
src << "&maxdelay=#{@options[:max_delay]}" if @options[:max_delay]
|
src << "&maxdelay=#{@options[:max_delay]}" if @options[:max_delay]
|
||||||
src << "&port=#{@options[:port]}" if @options[:port]
|
src << "&port=#{@options[:port]}" if @options[:port]
|
||||||
|
|
|
@ -44,15 +44,17 @@ describe Rack::LiveReload do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'set options' do
|
context 'set options' do
|
||||||
let(:middleware) { described_class.new(app, :port => port, :min_delay => min_delay, :max_delay => max_delay) }
|
let(:middleware) { described_class.new(app, :host => new_host, :port => port, :min_delay => min_delay, :max_delay => max_delay) }
|
||||||
let(:min_delay) { 5 }
|
let(:min_delay) { 5 }
|
||||||
let(:max_delay) { 10 }
|
let(:max_delay) { 10 }
|
||||||
let(:port) { 23 }
|
let(:port) { 23 }
|
||||||
|
let(:new_host) { 'myhost' }
|
||||||
|
|
||||||
it 'should add the livereload.js script tag' do
|
it 'should add the livereload.js script tag' do
|
||||||
body.should include("mindelay=#{min_delay}")
|
body.should include("mindelay=#{min_delay}")
|
||||||
body.should include("maxdelay=#{max_delay}")
|
body.should include("maxdelay=#{max_delay}")
|
||||||
body.should include("port=#{port}")
|
body.should include("port=#{port}")
|
||||||
|
body.should include("host=#{new_host}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue