# HG changeset patch # User sqwishy # Date 1383716209 28800 # Tue Nov 05 21:36:49 2013 -0800 # Node ID 911ea6a685aef73d4c8495095d3fcc24d0c4bb45 # Parent 141e578677cb97fd34db16ca5ae70eaebec63187 renamed project to goquitur diff --git a/main.go b/main.go --- a/main.go +++ b/main.go @@ -6,11 +6,11 @@ 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) } diff --git a/server.go b/server.go --- a/server.go +++ b/server.go @@ -10,14 +10,14 @@ 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 @@ return nil, err } - h := &MetronomeHandler{ + h := &GoquiturHandler{ ServeMux: http.NewServeMux(), watchdir: watchdir, watcher: watcher, @@ -42,7 +42,7 @@ 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 @@ 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 @@ 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) 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) handleFsEvents() { +func (h *GoquiturHandler) handleFsEvents() { for { log.Println("waiting for fs events") select { @@ -174,7 +174,7 @@ 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) 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 @@ 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 @@ 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, diff --git a/static/js.js b/static/js.js --- a/static/js.js +++ b/static/js.js @@ -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 @@ }); $(document).ready(function() { - var conn = new MetronomeConn(); + var conn = new GoquiturConn(); conn.on('open', function() { conn.sub('/');