From d303a4bb09bc655f5b76bf2f4b3e9b042463ffde Mon Sep 17 00:00:00 2001 From: Martin Boehm Date: Thu, 28 Jun 2018 00:08:33 +0200 Subject: [PATCH] Display tx summary in explorer --- server/public.go | 16 ++++++++++++++-- static/css/main.css | 9 ++++++--- static/templates/base.html | 2 +- static/templates/tx.html | 30 +++++++++++++++++++++++++++--- static/templates/txdetail.html | 3 +++ 5 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 static/templates/txdetail.html diff --git a/server/public.go b/server/public.go index 84ce4873..543e07ec 100644 --- a/server/public.go +++ b/server/public.go @@ -89,11 +89,19 @@ func NewPublicServer(binding string, certFiles string, db *db.RocksDB, chain bch // default handler serveMux.HandleFunc(path, s.index) - s.txTpl = template.Must(template.New("tx").ParseFiles("./static/templates/tx.html", "./static/templates/base.html")) + templateFuncMap := template.FuncMap{ + "formatUnixTime": formatUnixTime, + } + + s.txTpl = template.Must(template.New("tx").Funcs(templateFuncMap).ParseFiles("./static/templates/tx.html", "./static/templates/txdetail.html", "./static/templates/base.html")) return s, nil } +func formatUnixTime(ut int64) string { + return time.Unix(ut, 0).Format(time.RFC1123) +} + // Run starts the server func (s *PublicServer) Run() error { if s.certFiles == "" { @@ -170,9 +178,13 @@ func (s *PublicServer) explorerTx(w http.ResponseWriter, r *http.Request) { } } w.Header().Set("Content-Type", "text/html; charset=utf-8") + // temporarily reread the template on each request // to reflect changes during development - txTpl := template.Must(template.New("tx").ParseFiles("./static/templates/tx.html", "./static/templates/base.html")) + templateFuncMap := template.FuncMap{ + "formatUnixTime": formatUnixTime, + } + txTpl := template.Must(template.New("tx").Funcs(templateFuncMap).ParseFiles("./static/templates/tx.html", "./static/templates/txdetail.html", "./static/templates/base.html")) data := struct { CoinName string diff --git a/static/css/main.css b/static/css/main.css index 66aa2aa7..988ea8b6 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -3,7 +3,6 @@ html, body { } body { - display: inline-block; width: 100%; min-width: 727px; min-height: 100%; @@ -64,12 +63,16 @@ body { min-height: 100%; height: auto; padding: 75px 0; - margin: 0 auto -51px; + margin: 0 auto -53px; } #footer { background-color: #212121; color: #fff; - height: 51px; + height: 53px; overflow: hidden; +} + +.value-group { + margin: 20px 0; } \ No newline at end of file diff --git a/static/templates/base.html b/static/templates/base.html index ad1fe9be..4dc8accb 100644 --- a/static/templates/base.html +++ b/static/templates/base.html @@ -50,7 +50,7 @@
{{template "specific" .Specific}} -
+