Skip to content

Commit

Permalink
Better render command output
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Castell committed Dec 1, 2015
1 parent 0d878f1 commit 39ca21e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions dkron/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")...))

Expand Down
2 changes: 1 addition & 1 deletion templates/executions.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<td>{{ $ex.StartedAt }}</td>
<td>{{ $ex.FinishedAt }}</td>
<td>{{ $ex.NodeName }}</td>
<td>{{ html $ex.Output }}</td>
<td><span data-toggle="tooltip" data-placement="top" title="{{ $ex.Output | b2s }}" data-html="true">{{ $ex.Output | b2s | truncate }}...</span></td>
<td>{{ $ex.Success }}</td>
</tr>
{{ end }}
Expand Down

0 comments on commit 39ca21e

Please sign in to comment.