From 088b63a507d7535e1c2fc0df76358c02ccad5f14 Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Wed, 28 Jan 2015 13:01:30 +0700 Subject: [PATCH] Bundle dashboard assets with rice --- .gitignore | 1 + server/server.go | 13 ++- server/static/app.css | 67 +++++++++++++++ server/{dashboard.go => static/app.js} | 114 ------------------------- server/static/dashboard.tmpl | 29 +++++++ 5 files changed, 107 insertions(+), 117 deletions(-) create mode 100644 server/static/app.css rename server/{dashboard.go => static/app.js} (60%) create mode 100644 server/static/dashboard.tmpl diff --git a/.gitignore b/.gitignore index f6049fa..5364a62 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ burlesque +*.rice-box.go diff --git a/server/server.go b/server/server.go index fb6c7cb..365adfe 100644 --- a/server/server.go +++ b/server/server.go @@ -10,13 +10,15 @@ import ( "strings" "text/template" + "github.com/GeertJohan/go.rice" "github.com/KosyanMedia/burlesque/hub" ) type ( Server struct { - port int - hub *hub.Hub + port int + hub *hub.Hub + dashboardTmpl string } ) @@ -30,6 +32,9 @@ func New(port int, h *hub.Hub) *Server { hub: h, } + box := rice.MustFindBox("static") + http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(box.HTTPBox()))) + http.HandleFunc("/status", s.statusHandler) http.HandleFunc("/debug", s.debugHandler) http.HandleFunc("/publish", s.pubHandler) @@ -37,6 +42,8 @@ func New(port int, h *hub.Hub) *Server { http.HandleFunc("/flush", s.flushHandler) http.HandleFunc("/dashboard", s.dashboardHandler) + s.dashboardTmpl, _ = box.String("dashboard.tmpl") + return &s } @@ -136,7 +143,7 @@ func (s *Server) flushHandler(w http.ResponseWriter, r *http.Request) { func (s *Server) dashboardHandler(w http.ResponseWriter, r *http.Request) { tmpl := template.New("dashboard") - tmpl, _ = tmpl.Parse(dashboardTmpl) + tmpl, _ = tmpl.Parse(s.dashboardTmpl) w.Header().Set("Content-Type", "text/html; charset=utf8") hostname, _ := os.Hostname() diff --git a/server/static/app.css b/server/static/app.css new file mode 100644 index 0000000..0d0492f --- /dev/null +++ b/server/static/app.css @@ -0,0 +1,67 @@ +* { box-sizing: border-box; } +.title, td, th { + font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; + font-size: 1.3em; + padding: 0.6em; + font-weight: 300; +} + +.title, table { + position: absolute; + left: 50%; + width: 650px; + margin-left: -325px; +} +.title { + top: 10px; + text-align: center; + font-size: 1.8em; +} +table { + top: 100px; + border-spacing: 0; + border-collapse: collapse; +} +th { + font-weight: 400; +} +thead tr { + border-bottom: #666 1px solid; +} +tbody tr:nth-child(even) { + background-color: #f5f5f5; +} +.name { + width: 350px; + max-width: 350px; + text-align: left; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} +.messages, .subscriptions { + width: 150px; + max-width: 150px; + text-align: right; +} +.zero { + color: #aaa; +} +.fat { + font-weight: 600; +} +.hot { + font-weight: 600; + color: #f20; +} +#loading { + display: none; + position: absolute; + bottom: 10px; + right: 10px; + font-size: 0.5em; + width: auto; +} +#placeholder td { + text-align: center; +} diff --git a/server/dashboard.go b/server/static/app.js similarity index 60% rename from server/dashboard.go rename to server/static/app.js index 4a5ada3..59f259e 100644 --- a/server/dashboard.go +++ b/server/static/app.js @@ -1,109 +1,3 @@ -package server - -const dashboardTmpl = ` -{{define "dashboard"}} - - - - - Queues @ {{.hostname}} - - - - - - - -

Burlesque v{{.version}} at {{.hostname}}

- - - - - - - - - - - - - - -
Loading...
-
QueueMessagesSubscriptions
Loading queues...
- - - - - - -{{end}} -` diff --git a/server/static/dashboard.tmpl b/server/static/dashboard.tmpl new file mode 100644 index 0000000..d57c118 --- /dev/null +++ b/server/static/dashboard.tmpl @@ -0,0 +1,29 @@ +{{define "dashboard"}} + + + + Queues @ {{.hostname}} + + + + +

Burlesque v{{.version}} at {{.hostname}}

+ + + + + + + + + + + + + +
Loading...
+
QueueMessagesSubscriptions
Loading queues...
+ + + +{{end}}