1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 09:37:02 +00:00

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
This commit is contained in:
James Hillyerd
2014-03-12 09:09:47 -07:00
parent 8f10e18fef
commit 13868d85d4
7 changed files with 49 additions and 27 deletions

View File

@@ -8,6 +8,6 @@
"Include": "README*,LICENSE*,inbucket.bat,etc,themes"
},
"PackageVersion": "1.0",
"PrereleaseInfo": "rc3",
"PrereleaseInfo": "rc4",
"FormatVersion": "0.8"
}

View File

@@ -46,6 +46,10 @@ type DataStoreConfig struct {
}
var (
// Build info, set by main
VERSION = ""
BUILD_DATE = ""
// Global goconfig object
Config *config.Config

View File

@@ -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" {

View File

@@ -320,7 +320,7 @@ table.metrics {
width: 15em;
}
.metrics td {
.metrics td.number {
width: 10em;
}

View File

@@ -154,6 +154,10 @@
<div class="box">
<h3>Configuration</h3>
<table class="metrics">
<tr>
<th>Version:</th>
<td><span>{{.version}}, built on {{.buildDate}}</span></td>
</tr>
<tr>
<th>SMTP Listener:</th>
<td><span>{{.smtpListener}}</span></td>
@@ -174,29 +178,29 @@
<table class="metrics">
<tr>
<th>Uptime:</th>
<td><span id="m-uptime">.</span></td>
<td class="number"><span id="m-uptime">.</span></td>
</tr>
<tr>
<th>System Memory:</th>
<td><span id="m-memstatsSys">.</span></td>
<td class="number"><span id="m-memstatsSys">.</span></td>
<td class="sparkline"><span id="s-memstatsSys">.</span></td>
<td>(10min)</td>
</tr>
<tr>
<th>Heap Size:</th>
<td><span id="m-memstatsHeapSys">.</span></td>
<td class="number"><span id="m-memstatsHeapSys">.</span></td>
<td class="sparkline"><span id="s-memstatsHeapSys">.</span></td>
<td>(10min)</td>
</tr>
<tr>
<th>Heap In-Use:</th>
<td><span id="m-memstatsHeapAlloc">.</span></td>
<td class="number"><span id="m-memstatsHeapAlloc">.</span></td>
<td class="sparkline"><span id="s-memstatsHeapAlloc">.</span></td>
<td>(10min)</td>
</tr>
<tr>
<th>Heap # Objects:</th>
<td><span id="m-memstatsHeapObjects">.</span></td>
<td class="number"><span id="m-memstatsHeapObjects">.</span></td>
<td class="sparkline"><span id="s-memstatsHeapObjects">.</span></td>
<td>(10min)</td>
</tr>
@@ -208,31 +212,31 @@
<table class="metrics">
<tr>
<th>Current Connections:</th>
<td><span id="m-smtpConnectsCurrent">.</span></td>
<td class="number"><span id="m-smtpConnectsCurrent">.</span></td>
<td class="sparkline"><span id="s-smtpConnectsCurrent">.</span></td>
<td>(10min)</td>
</tr>
<tr>
<th>Total Connections:</th>
<td><span id="m-smtpConnectsTotal">.</span></td>
<td class="number"><span id="m-smtpConnectsTotal">.</span></td>
<td class="sparkline"><span id="s-smtpConnectsTotal">.</span></td>
<td>(60min)</td>
</tr>
<tr>
<th>Messages Received:</th>
<td><span id="m-smtpReceivedTotal">.</span></td>
<td class="number"><span id="m-smtpReceivedTotal">.</span></td>
<td class="sparkline"><span id="s-smtpReceivedTotal">.</span></td>
<td>(60min)</td>
</tr>
<tr>
<th>Errors Logged:</th>
<td><span id="m-smtpErrorsTotal">.</span></td>
<td class="number"><span id="m-smtpErrorsTotal">.</span></td>
<td class="sparkline"><span id="s-smtpErrorsTotal"></span></td>
<td>(60min)</td>
</tr>
<tr>
<th>Warnings Logged:</th>
<td><span id="m-smtpWarnsTotal">.</span></td>
<td class="number"><span id="m-smtpWarnsTotal">.</span></td>
<td class="sparkline"><span id="s-smtpWarnsTotal"></span></td>
<td>(60min)</td>
</tr>
@@ -264,13 +268,13 @@
</tr>
<tr>
<th>Retention Deletes:</th>
<td><span id="m-retentionDeletesTotal">.</span></td>
<td class="number"><span id="m-retentionDeletesTotal">.</span></td>
<td class="sparkline"><span id="s-retentionDeletesTotal"></span></td>
<td>(60min)</td>
</tr>
<tr>
<th>Currently Retained:</th>
<td><span id="m-retainedCurrent">.</span></td>
<td class="number"><span id="m-retainedCurrent">.</span></td>
<td class="sparkline"><span id="s-retainedCurrent"></span></td>
<td>(60min)</td>
</tr>

View File

@@ -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,

View File

@@ -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,