Permalink
Browse files

Support server-provided URL overrides for updated files

  • Loading branch information...
1 parent 380fa8f commit 139627e765d6d1f20dfba4fbf673c0ac4db1527e @andreyvit andreyvit committed Feb 13, 2012
Showing with 11 additions and 0 deletions.
  1. +2 −0 src/livereload.coffee
  2. +9 −0 src/reloader.coffee
View
@@ -80,6 +80,8 @@ exports.LiveReload = class LiveReload
liveCSS: message.liveCSS ? yes
liveImg: message.liveImg ? yes
originalPath: message.originalPath || ''
+ overrideURL: message.overrideURL || ''
+ serverURL: "http://#{@options.host}:#{@options.port}"
performAlert: (message) ->
alert message.message
View
@@ -77,6 +77,7 @@ exports.Reloader = class Reloader
reload: (path, options) ->
+ @options = options # avoid passing it through all the funcs
for plugin in @plugins
if plugin.reload && plugin.reload(path, options)
return
@@ -263,6 +264,14 @@ exports.Reloader = class Reloader
generateCacheBustUrl: (url, expando=@generateUniqueString()) ->
{ url, hash, params: oldParams } = splitUrl(url)
+ if @options.overrideURL
+ console.log "@options.overrideURL = #{@options.overrideURL}"
+ console.log "@options.serverURL = #{@options.serverURL}"
+ console.log "url = #{url}"
+ if url.indexOf(@options.serverURL) < 0
+ url = @options.serverURL + @options.overrideURL + "?url=" + encodeURIComponent(url)
+ console.log "url' = #{url}"
+
params = oldParams.replace /(\?|&)livereload=(\d+)/, (match, sep) -> "#{sep}#{expando}"
if params == oldParams
if oldParams.length == 0

0 comments on commit 139627e

Please sign in to comment.