Skip to content

Commit

Permalink
v2.7.1. Bugfix.
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Oct 16, 2015
1 parent 49c502e commit b1f8019
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 28 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# History

## v2.7.1 October 16, 2015
- `pathname` configuration now actually does what it was suppose to
- If a custom 404 middleware was added, should no longer interfere with primus as we now use the correct `serverExtend` event rather than `serverAfter`

## v2.7.0 October 16, 2015
- `socketOptions` configuration now actually does what it was suppose to
- Updated dependencies
Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ This option when falsey (the default) means we will create our own socket instan
### `channel`
This option specifies the which channel we should listen to, it defaults to `/docpad-livereload`

### `pathname`
This option specifies the the pathname that primus should use, it defaults to `/docpad-livereload`

### `socketOptions`
This option allows you to customise the [primus configuration](https://github.com/primus/primus) that we use if we have to create our own instance.

Expand Down Expand Up @@ -98,7 +101,7 @@ These options allow you to customise the content of the scripts and styles that

These amazing people are maintaining this project:

<ul><li><a href="http://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/docpad/docpad-plugin-livereload/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository docpad/docpad-plugin-livereload">view contributions</a></li></ul>
<ul><li><a href="http://balupton.com">Benjamin Lupton</a></li></ul>

<h3>Sponsors</h3>

Expand All @@ -116,14 +119,14 @@ No sponsors yet! Will you be the first?
These amazing people have contributed code to this project:

<ul><li><a href="https://github.com/amesarosh">Alex Mesarosh</a> — <a href="https://github.com/docpad/docpad-plugin-livereload/commits?author=amesarosh" title="View the GitHub contributions of Alex Mesarosh on repository docpad/docpad-plugin-livereload">view contributions</a></li>
<li><a href="antoinebrault.ca">Antoine Brault</a> — <a href="https://github.com/docpad/docpad-plugin-livereload/commits?author=antoinebrault" title="View the GitHub contributions of Antoine Brault on repository docpad/docpad-plugin-livereload">view contributions</a></li>
<li><a href="http://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/docpad/docpad-plugin-livereload/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository docpad/docpad-plugin-livereload">view contributions</a></li>
<li><a href="http://delapouite.com">Bruno Heridet</a> — <a href="https://github.com/docpad/docpad-plugin-livereload/commits?author=Delapouite" title="View the GitHub contributions of Bruno Heridet on repository docpad/docpad-plugin-livereload">view contributions</a></li>
<li><a href="http://www.garthdb.com">Garth Braithwaite</a> — <a href="https://github.com/docpad/docpad-plugin-livereload/commits?author=GarthDB" title="View the GitHub contributions of Garth Braithwaite on repository docpad/docpad-plugin-livereload">view contributions</a></li>
<li><a href="http://robloach.net">Rob Loach</a> — <a href="https://github.com/docpad/docpad-plugin-livereload/commits?author=RobLoach" title="View the GitHub contributions of Rob Loach on repository docpad/docpad-plugin-livereload">view contributions</a></li>
<li><a href="antoinebrault.ca">Antoine Brault</a></li>
<li><a href="http://balupton.com">Benjamin Lupton</a></li>
<li><a href="http://delapouite.com">Bruno Heridet</a></li>
<li><a href="http://www.garthdb.com">Garth Braithwaite</a></li>
<li><a href="http://robloach.net">Rob Loach</a></li>
<li><a href="https://github.com/scottoreilly">Scott O'Reilly</a> — <a href="https://github.com/docpad/docpad-plugin-livereload/commits?author=scottoreilly" title="View the GitHub contributions of Scott O'Reilly on repository docpad/docpad-plugin-livereload">view contributions</a></li>
<li><a href="https://github.com/StephenBrown2">Stephen Brown II</a> — <a href="https://github.com/docpad/docpad-plugin-livereload/commits?author=StephenBrown2" title="View the GitHub contributions of Stephen Brown II on repository docpad/docpad-plugin-livereload">view contributions</a></li>
<li><a href="http://vaughan.io">Vaughan Rouesnel</a> — <a href="https://github.com/docpad/docpad-plugin-livereload/commits?author=vjpr" title="View the GitHub contributions of Vaughan Rouesnel on repository docpad/docpad-plugin-livereload">view contributions</a></li>
<li><a href="http://vaughan.io">Vaughan Rouesnel</a></li>
<li><a href="https://github.com/vsopvsop">vsopvsop</a> — <a href="https://github.com/docpad/docpad-plugin-livereload/commits?author=vsopvsop" title="View the GitHub contributions of vsopvsop on repository docpad/docpad-plugin-livereload">view contributions</a></li></ul>

<a href="https://github.com/docpad/docpad-plugin-livereload/blob/master/CONTRIBUTING.md#files">Discover how you can contribute by heading on over to the <code>CONTRIBUTING.md</code> file.</a>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docpad-plugin-livereload",
"version": "2.7.0",
"version": "2.7.1",
"description": "Automatically refreshes your website whenever a rengeration is performed",
"homepage": "http://docpad.org/plugin/livereload",
"license": "MIT",
Expand Down
36 changes: 19 additions & 17 deletions src/livereload.plugin.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = (BasePlugin) ->
# Only enable us on the development environment
config:
channel: '/docpad-livereload'
pathname: '/docpad-livereload'
enabled: false
getSocket: null
inject: true
Expand Down Expand Up @@ -79,7 +80,7 @@ module.exports = (BasePlugin) ->
var t = document.createElement('script');
t.type = 'text/javascript';
t.async = 'async';
t.src = '/primus/primus.js';
t.src = '#{config.pathname}/primus.js';
t.onload = listen;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(t, s);
Expand Down Expand Up @@ -124,32 +125,33 @@ module.exports = (BasePlugin) ->
# Chain
@

# Setup After
# Setup Extend
# Start our socket
serverAfter: (opts) ->
serverExtend: (opts) ->
# Prepare
{server,serverHttp} = opts
{serverHttp} = opts
plugin = @
docpad = @docpad
config = @getConfig()

# Get socket
existingSocket = true
@socket = config.getSocket?()
unless @socket
extendr = require('extendr')
Primus = require('primus')

existingSocket = false
socketOptions = extendr.deep({
pathname: config.channel
}, config.socketOptions)
# Configuration
extendr = require('extendr')
socketOptions = extendr.deep({}, config.socketOptions, {
pathname: config.pathname
})

# Get socket using custom method if set
@socket = config.getSocket?(opts, socketOptions)
if @socket
docpad.log('info', "LiveReload listening to custom socket on channel #{config.channel}")
else
# Create a socket using primus
Primus = require('primus')
@socket = new Primus(serverHttp, socketOptions)
@socket.on('error', docpad.warn)

# Log
docpad.log('info', "LiveReload listening to #{if existingSocket then 'existing' else 'new'} socket on channel #{config.channel}")
# Log
docpad.log('info', "LiveReload listening to new socket on channel #{config.channel}")

# Chain
@
Expand Down
4 changes: 2 additions & 2 deletions test/out-expected/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
var t = document.createElement('script');
t.type = 'text/javascript';
t.async = 'async';
t.src = '/primus/primus.js';
t.src = '/docpad-livereload/primus.js';
t.onload = listen;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(t, s);
Expand All @@ -50,4 +50,4 @@
}
})();</script>
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion test/src/documents/index.html.eco
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
<body>
<%- @getBlock('scripts').toHTML() %>
</body>
</html>
</html>

0 comments on commit b1f8019

Please sign in to comment.