From 39ca21ebec245d9067c399bda0a61c4aa7f6dead Mon Sep 17 00:00:00 2001 From: Victor Castell Date: Wed, 2 Dec 2015 00:28:47 +0100 Subject: [PATCH] Better render command output --- dkron/dashboard.go | 15 +++++++++++++-- templates/executions.html.tmpl | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/dkron/dashboard.go b/dkron/dashboard.go index 42f3fc206..ca948bc8d 100644 --- a/dkron/dashboard.go +++ b/dkron/dashboard.go @@ -138,8 +138,19 @@ func (a *AgentCommand) dashboardExecutionsHandler(w http.ResponseWriter, r *http } tmpl := template.Must(template.New("dashboard.html.tmpl").Funcs(template.FuncMap{ - "html": func(value []byte) template.HTML { - return template.HTML(value) + "b2s": func(value []byte) string { + return template.JSEscapeString(string(value)) + }, + // Now unicode compliant + "truncate": func(s string) string { + var numRunes = 0 + for index, _ := range s { + numRunes++ + if numRunes > 25 { + return s[:index] + } + } + return s }, }).ParseFiles(templateSet(a.config.UIDir, "executions")...)) diff --git a/templates/executions.html.tmpl b/templates/executions.html.tmpl index 23e451bee..960afb1e3 100644 --- a/templates/executions.html.tmpl +++ b/templates/executions.html.tmpl @@ -22,7 +22,7 @@ {{ $ex.StartedAt }} {{ $ex.FinishedAt }} {{ $ex.NodeName }} - {{ html $ex.Output }} + {{ $ex.Output | b2s | truncate }}... {{ $ex.Success }} {{ end }}