@@ 6,11 6,11 @@ import _"fmt"
import "net/http"
func main() {
- web, err := NewMetronomeHandler("watchdir")
+ web, err := NewGoquiturHandler("watchdir")
if err != nil {
log.Fatal(err)
}
- log.Println("Loaded metronome, beginning to serve webstuffs")
+ log.Println("Loaded goquitur, beginning to serve webstuffs")
if err := http.ListenAndServe(":8123", web); err != nil {
log.Fatal(err)
}
@@ 10,14 10,14 @@ import "path/filepath"
import "code.google.com/p/go.net/websocket"
import "github.com/howeyc/fsnotify"
-type MetronomeHandler struct {
+type GoquiturHandler struct {
*http.ServeMux
watchdir string
watcher *fsnotify.Watcher
subs map[string][]*websocket.Conn
}
-func NewMetronomeHandler(watchdir string) (*MetronomeHandler, error) {
+func NewGoquiturHandler(watchdir string) (*GoquiturHandler, error) {
watchdir, err := filepath.Abs(watchdir)
if err != nil {
return nil, err
@@ 30,7 30,7 @@ func NewMetronomeHandler(watchdir string
return nil, err
}
- h := &MetronomeHandler{
+ h := &GoquiturHandler{
ServeMux: http.NewServeMux(),
watchdir: watchdir,
watcher: watcher,
@@ 42,7 42,7 @@ func NewMetronomeHandler(watchdir string
return h, nil
}
-func (h *MetronomeHandler) resFromWebPath(path string) (*Resource, error) {
+func (h *GoquiturHandler) resFromWebPath(path string) (*Resource, error) {
if path == "" {
return nil, fmt.Errorf("Path must not be empty")
}
@@ 57,7 57,7 @@ func (h *MetronomeHandler) resFromWebPat
return &Resource{path, fspath}, nil
}
-func (h *MetronomeHandler) openResource(r *Resource) (*OpenResource, error) {
+func (h *GoquiturHandler) openResource(r *Resource) (*OpenResource, error) {
file, err := os.Open(r.FSPath)
if err != nil {
return nil,err
@@ 69,14 69,14 @@ func (h *MetronomeHandler) openResource(
return &OpenResource{r, file, fi}, nil
}
-func (h *MetronomeHandler) validateResource(r *Resource) error {
+func (h *GoquiturHandler) validateResource(r *Resource) error {
if strings.HasPrefix(r.FSPath, h.watchdir) == false {
return fmt.Errorf("Path does not appear to be inside a valid directory")
}
return nil
}
-func (h *MetronomeHandler) serveWS(ws *websocket.Conn) {
+func (h *GoquiturHandler) serveWS(ws *websocket.Conn) {
defer ws.Close()
for {
log.Println("serving:", ws)
@@ 87,7 87,7 @@ func (h *MetronomeHandler) serveWS(ws *w
}
}
-func (h *MetronomeHandler) serveOneWS(ws *websocket.Conn) error {
+func (h *GoquiturHandler) serveOneWS(ws *websocket.Conn) error {
r := new(Request)
if err := websocket.JSON.Receive(ws, r); err != nil {
return websocket.JSON.Send(ws, &Error{
@@ 140,7 140,7 @@ func (h *MetronomeHandler) serveOneWS(ws
})
}
-func (h *MetronomeHandler) handleFsEvents() {
+func (h *GoquiturHandler) handleFsEvents() {
for {
log.Println("waiting for fs events")
select {
@@ 174,7 174,7 @@ func notifyConn(conn *websocket.Conn, ms
return websocket.JSON.Send(conn, msg)
}
-func (h *MetronomeHandler) notifyConns(path string, msg interface{}) {
+func (h *GoquiturHandler) notifyConns(path string, msg interface{}) {
conns, ok := h.subs[path]
if ok {
for _, conn := range conns {
@@ 187,7 187,7 @@ func (h *MetronomeHandler) notifyConns(p
}
}
-func (h *MetronomeHandler) resAdded(res *Resource) error {
+func (h *GoquiturHandler) resAdded(res *Resource) error {
ores, err := h.openResource(res)
if err != nil {
return err
@@ 211,7 211,7 @@ func (h *MetronomeHandler) resAdded(res
return nil
}
-func (h *MetronomeHandler) resModified(res *Resource) error {
+func (h *GoquiturHandler) resModified(res *Resource) error {
ores, err := h.openResource(res)
if err != nil {
return err
@@ 228,7 228,7 @@ func (h *MetronomeHandler) resModified(r
return nil
}
-func (h *MetronomeHandler) resRemoved(res *Resource) error {
+func (h *GoquiturHandler) resRemoved(res *Resource) error {
h.notifyConns(res.WebPath, &State{
Event: EventDelete,
Path: res.WebPath,
@@ 1,6 1,6 @@
var get_ws_address = function() { return "ws://" + window.location.host + "/ws" };
-var MetronomeConn = function() {
+var GoquiturConn = function() {
var that = this;
_.extend(that, Backbone.Events);
@@ 69,7 69,7 @@ var Model = Backbone.Model.extend({
});
$(document).ready(function() {
- var conn = new MetronomeConn();
+ var conn = new GoquiturConn();
conn.on('open', function() {
conn.sub('/');