Enable soft livereload of CSS and images

Prior to this commit a dummy JavaScript filename was sent to LiveReload when changing a static file (CSS, image etc.), forcing a full browser reload of the page.

This commit fixes this by sending the relative file path of the changed static resource, enabling partial live reloading for CSS- and image-changes. If more than one static file happens to end up in the same changeevent-batch, it will fall back to do a full refresh. To enable this logic, the change events with names ending with ".goutputstream*" is now filtered out as temporary.

Changes in dynamic content behaves like before.

Issue #490
This commit is contained in:
bep 2014-09-10 12:21:22 +02:00 committed by spf13
parent 0099b5a3cb
commit df489b4712
4 changed files with 65 additions and 3 deletions

View file

@ -39,7 +39,12 @@ func Initialize() {
func ForceRefresh() {
// Tell livereload a js file changed to force a hard refresh
wsHub.broadcast <- []byte(`{"command":"reload","path":"/x.js","originalPath":"","liveCSS":true}`)
RefreshPath("/x.js")
}
func RefreshPath(s string) {
// Tell livereload a file has changed - will force a hard refresh if not CSS or an image
wsHub.broadcast <- []byte(`{"command":"reload","path":"` + s + "\"" + `,"originalPath":"","liveCSS":true,"liveImg":true}`)
}
func ServeJS(w http.ResponseWriter, r *http.Request) {