continue
}
- isstatic := strings.HasPrefix(ev.Name, helpers.AbsPathify(viper.GetString("StaticDir"))) || strings.HasPrefix(ev.Name, helpers.AbsPathify("themes/"+viper.GetString("theme"))+"/static/")
+ isstatic := strings.HasPrefix(ev.Name, helpers.GetStaticDirPath()) || strings.HasPrefix(ev.Name, helpers.GetThemesDirPath())
static_changed = static_changed || isstatic
dynamic_changed = dynamic_changed || !isstatic
return filepath.Clean(filepath.Join(viper.GetString("WorkingDir"), inPath))
}
+func GetStaticDirPath() string {
+ return AbsPathify(viper.GetString("StaticDir"))
+}
+
+func GetThemesDirPath() string {
+ return AbsPathify(filepath.Join("themes", viper.GetString("theme"), "static"))
+}
+
func MakeStaticPathRelative(inPath string) (string, error) {
- staticDir := AbsPathify(viper.GetString("StaticDir"))
- themeStaticDir := AbsPathify("themes/"+viper.GetString("theme")) + "/static/"
+ staticDir := GetStaticDirPath()
+ themeStaticDir := GetThemesDirPath()
return MakePathRelative(inPath, staticDir, themeStaticDir)
}
import (
"net/http"
+ "strings"
"github.com/gorilla/websocket"
)
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}`)
+ url_path := strings.Replace(s, "\\", "/", -1) // If path has backslashes on Windows, make path work for URL
+ wsHub.broadcast <- []byte(`{"command":"reload","path":"` + url_path + "\"" + `,"originalPath":"","liveCSS":true,"liveImg":true}`)
}
func ServeJS(w http.ResponseWriter, r *http.Request) {