From 13868d85d409d2c0b10c1d3627ab0be2311fda21 Mon Sep 17 00:00:00 2001 From: James Hillyerd Date: Wed, 12 Mar 2014 09:09:47 -0700 Subject: [PATCH] HTML view encoding fix - HTML popup now specifies UTF8 encoding - Version and build date are captured from goxc - Version is displayed on status page, and initial log entry --- .goxc.json | 2 +- config/config.go | 4 +++ inbucket.go | 32 +++++++++++++++------- themes/integral/public/main.css | 2 +- themes/integral/templates/root/status.html | 28 +++++++++++-------- web/mailbox_controller.go | 2 +- web/root_controller.go | 6 ++-- 7 files changed, 49 insertions(+), 27 deletions(-) diff --git a/.goxc.json b/.goxc.json index c00d186..945d7ff 100644 --- a/.goxc.json +++ b/.goxc.json @@ -8,6 +8,6 @@ "Include": "README*,LICENSE*,inbucket.bat,etc,themes" }, "PackageVersion": "1.0", - "PrereleaseInfo": "rc3", + "PrereleaseInfo": "rc4", "FormatVersion": "0.8" } diff --git a/config/config.go b/config/config.go index d9dee7c..bcf4c2b 100644 --- a/config/config.go +++ b/config/config.go @@ -46,6 +46,10 @@ type DataStoreConfig struct { } var ( + // Build info, set by main + VERSION = "" + BUILD_DATE = "" + // Global goconfig object Config *config.Config diff --git a/inbucket.go b/inbucket.go index c1f0022..76bebc4 100644 --- a/inbucket.go +++ b/inbucket.go @@ -19,21 +19,31 @@ import ( "time" ) -// Command line flags -var help = flag.Bool("help", false, "Displays this help") -var pidfile = flag.String("pidfile", "none", "Write our PID into the specified file") -var logfile = flag.String("logfile", "stderr", "Write out log into the specified file") +var ( + // Build info, populated during linking by goxc + VERSION = "1.0" + BUILD_DATE = "undefined" -// startTime is used to calculate uptime of Inbucket -var startTime = time.Now() + // Command line flags + help = flag.Bool("help", false, "Displays this help") + pidfile = flag.String("pidfile", "none", "Write our PID into the specified file") + logfile = flag.String("logfile", "stderr", "Write out log into the specified file") -// The file we send log output to, will be nil for stderr or stdout -var logf *os.File + // startTime is used to calculate uptime of Inbucket + startTime = time.Now() -var smtpServer *smtpd.Server -var pop3Server *pop3d.Server + // The file we send log output to, will be nil for stderr or stdout + logf *os.File + + // Server instances + smtpServer *smtpd.Server + pop3Server *pop3d.Server +) func main() { + config.VERSION = VERSION + config.BUILD_DATE = BUILD_DATE + flag.Parse() if *help { flag.Usage() @@ -82,6 +92,8 @@ func main() { } } + log.LogInfo("Inbucket %v (%v) starting...", config.VERSION, config.BUILD_DATE) + // Write pidfile if requested // TODO: Probably supposed to remove pidfile during shutdown if *pidfile != "none" { diff --git a/themes/integral/public/main.css b/themes/integral/public/main.css index f0e5bd4..dd285b5 100644 --- a/themes/integral/public/main.css +++ b/themes/integral/public/main.css @@ -320,7 +320,7 @@ table.metrics { width: 15em; } -.metrics td { +.metrics td.number { width: 10em; } diff --git a/themes/integral/templates/root/status.html b/themes/integral/templates/root/status.html index d55c2f6..6ab12c8 100644 --- a/themes/integral/templates/root/status.html +++ b/themes/integral/templates/root/status.html @@ -154,6 +154,10 @@

Configuration

+ + + + @@ -174,29 +178,29 @@
Version:{{.version}}, built on {{.buildDate}}
SMTP Listener: {{.smtpListener}}
- + - + - + - + - + @@ -208,31 +212,31 @@
Uptime:..
System Memory:.. . (10min)
Heap Size:.. . (10min)
Heap In-Use:.. . (10min)
Heap # Objects:.. . (10min)
- + - + - + - + - + @@ -264,13 +268,13 @@ - + - + diff --git a/web/mailbox_controller.go b/web/mailbox_controller.go index 79a1a89..1a01d53 100644 --- a/web/mailbox_controller.go +++ b/web/mailbox_controller.go @@ -210,7 +210,7 @@ func MailboxHtml(w http.ResponseWriter, req *http.Request, ctx *Context) (err er return err } - w.Header().Set("Content-Type", "text/html") + w.Header().Set("Content-Type", "text/html; charset=UTF-8") return RenderPartial("mailbox/_html.html", w, map[string]interface{}{ "ctx": ctx, "name": name, diff --git a/web/root_controller.go b/web/root_controller.go index aa410a1..a0c68b4 100644 --- a/web/root_controller.go +++ b/web/root_controller.go @@ -13,9 +13,9 @@ func RootIndex(w http.ResponseWriter, req *http.Request, ctx *Context) (err erro if err != nil { return fmt.Errorf("Failed to load greeting: %v", err) } - + return RenderTemplate("root/index.html", w, map[string]interface{}{ - "ctx": ctx, + "ctx": ctx, "greeting": template.HTML(string(greeting)), }) } @@ -30,6 +30,8 @@ func RootStatus(w http.ResponseWriter, req *http.Request, ctx *Context) (err err config.GetWebConfig().Ip4port) return RenderTemplate("root/status.html", w, map[string]interface{}{ "ctx": ctx, + "version": config.VERSION, + "buildDate": config.BUILD_DATE, "retentionMinutes": retentionMinutes, "smtpListener": smtpListener, "pop3Listener": pop3Listener,
Current Connections:.. . (10min)
Total Connections:.. . (60min)
Messages Received:.. . (60min)
Errors Logged:.. (60min)
Warnings Logged:.. (60min)
Retention Deletes:.. (60min)
Currently Retained:.. (60min)