clean up templates
This commit is contained in:
6
go.mod
6
go.mod
@@ -2,13 +2,19 @@ module github.com/sentriz/gonic
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
cloud.google.com/go v0.37.1 // indirect
|
cloud.google.com/go v0.37.1 // indirect
|
||||||
|
github.com/Masterminds/goutils v1.1.0 // indirect
|
||||||
|
github.com/Masterminds/semver v1.4.2 // indirect
|
||||||
|
github.com/Masterminds/sprig v2.20.0+incompatible
|
||||||
github.com/denisenkom/go-mssqldb v0.0.0-20190315220205-a8ed825ac853 // indirect
|
github.com/denisenkom/go-mssqldb v0.0.0-20190315220205-a8ed825ac853 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.0
|
github.com/dustin/go-humanize v1.0.0
|
||||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 // indirect
|
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 // indirect
|
||||||
github.com/go-sql-driver/mysql v1.4.1 // indirect
|
github.com/go-sql-driver/mysql v1.4.1 // indirect
|
||||||
github.com/gofrs/uuid v3.2.0+incompatible // indirect
|
github.com/gofrs/uuid v3.2.0+incompatible // indirect
|
||||||
|
github.com/google/uuid v1.1.1 // indirect
|
||||||
github.com/gorilla/securecookie v1.1.1
|
github.com/gorilla/securecookie v1.1.1
|
||||||
github.com/gorilla/sessions v1.1.3
|
github.com/gorilla/sessions v1.1.3
|
||||||
|
github.com/huandu/xstrings v1.2.0 // indirect
|
||||||
|
github.com/imdario/mergo v0.3.7 // indirect
|
||||||
github.com/jinzhu/gorm v1.9.2
|
github.com/jinzhu/gorm v1.9.2
|
||||||
github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a // indirect
|
github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a // indirect
|
||||||
github.com/jinzhu/now v1.0.0 // indirect
|
github.com/jinzhu/now v1.0.0 // indirect
|
||||||
|
|||||||
12
go.sum
12
go.sum
@@ -7,6 +7,12 @@ git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGy
|
|||||||
git.apache.org/thrift.git v0.12.0/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
|
git.apache.org/thrift.git v0.12.0/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
|
||||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg=
|
||||||
|
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
||||||
|
github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc=
|
||||||
|
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
|
||||||
|
github.com/Masterminds/sprig v2.20.0+incompatible h1:dJTKKuUkYW3RMFdQFXPU/s6hg10RgctmTjRcbZ98Ap8=
|
||||||
|
github.com/Masterminds/sprig v2.20.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
|
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
|
||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
@@ -49,6 +55,8 @@ github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO
|
|||||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57 h1:eqyIo2HjKhKe/mJzTG8n4VqvLXIOEG+SLdDqX7xGtkY=
|
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57 h1:eqyIo2HjKhKe/mJzTG8n4VqvLXIOEG+SLdDqX7xGtkY=
|
||||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||||
|
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
|
||||||
|
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY=
|
github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY=
|
||||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||||
github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
|
github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
|
||||||
@@ -61,6 +69,10 @@ github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:Fecb
|
|||||||
github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw=
|
github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw=
|
||||||
github.com/grpc-ecosystem/grpc-gateway v1.6.2/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw=
|
github.com/grpc-ecosystem/grpc-gateway v1.6.2/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw=
|
||||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
|
github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0=
|
||||||
|
github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4=
|
||||||
|
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
|
||||||
|
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||||
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
|
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
|
||||||
github.com/jinzhu/gorm v1.9.2 h1:lCvgEaqe/HVE+tjAR2mt4HbbHAZsQOv3XAZiEZV37iw=
|
github.com/jinzhu/gorm v1.9.2 h1:lCvgEaqe/HVE+tjAR2mt4HbbHAZsQOv3XAZiEZV37iw=
|
||||||
github.com/jinzhu/gorm v1.9.2/go.mod h1:Vla75njaFJ8clLU1W44h34PjIkijhjHIYnZxMqCdxqo=
|
github.com/jinzhu/gorm v1.9.2/go.mod h1:Vla75njaFJ8clLU1W44h34PjIkijhjHIYnZxMqCdxqo=
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>{{ template "title" }}</title>
|
<title>gonic</title>
|
||||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">
|
|
||||||
<link rel="stylesheet" href="/admin/static/stylesheets/reset.css">
|
<link rel="stylesheet" href="/admin/static/stylesheets/reset.css">
|
||||||
|
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">
|
||||||
<link rel="stylesheet" href="/admin/static/stylesheets/main.css">
|
<link rel="stylesheet" href="/admin/static/stylesheets/main.css">
|
||||||
<link rel="shortcut icon" href="/admin/static/images/favicon.ico" type="image/x-icon">
|
<link rel="shortcut icon" href="/admin/static/images/favicon.ico" type="image/x-icon">
|
||||||
<link rel="icon" href="/admin/static/images/favicon.ico" type="image/x-icon">
|
<link rel="icon" href="/admin/static/images/favicon.ico" type="image/x-icon">
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
{{ define "title" }}home{{ end }}
|
|
||||||
|
|
||||||
{{ define "content" }}
|
{{ define "content" }}
|
||||||
<div class="side-padded light text-right mono">
|
<div class="side-padded light text-right mono">
|
||||||
welcome {{ .User.Name }}
|
welcome {{ .User.Name }}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
{{ define "title" }}home{{ end }}
|
|
||||||
|
|
||||||
{{ define "user" }}
|
{{ define "user" }}
|
||||||
<div class="padded box mono">
|
<div class="padded box mono">
|
||||||
<div class="box-title">
|
<div class="box-title">
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
{{ define "title" }}home{{ end }}
|
|
||||||
|
|
||||||
{{ define "user" }}
|
{{ define "user" }}
|
||||||
<div class="padded box mono">
|
<div class="padded box mono">
|
||||||
<div class="box-title">
|
<div class="box-title">
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
{{ define "title" }}home{{ end }}
|
|
||||||
|
|
||||||
{{ define "user" }}
|
{{ define "user" }}
|
||||||
<div class="padded box mono">
|
<div class="padded box mono">
|
||||||
<div class="box-title">
|
<div class="box-title">
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
{{ define "title" }}home{{ end }}
|
|
||||||
|
|
||||||
{{ define "user" }}
|
{{ define "user" }}
|
||||||
<div class="padded box mono">
|
<div class="padded box mono">
|
||||||
<div class="box-title">
|
<div class="box-title">
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
{{ define "title" }}home{{ end }}
|
|
||||||
|
|
||||||
{{ define "user" }}
|
{{ define "user" }}
|
||||||
<div class="padded box mono">
|
<div class="padded box mono">
|
||||||
<div class="box-title">
|
<div class="box-title">
|
||||||
@@ -78,7 +76,7 @@
|
|||||||
{{ range $folder := .RecentFolders }}
|
{{ range $folder := .RecentFolders }}
|
||||||
<tr>
|
<tr>
|
||||||
<td><span>{{ $folder.RightPath }}</span></td>
|
<td><span>{{ $folder.RightPath }}</span></td>
|
||||||
<td><span class="light">{{ $folder.CreatedAt | humandate }}</span></td>
|
<td><span class="light">{{ $folder.CreatedAt | humanDate }}</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
{{ define "title" }}gonic{{ end }}
|
|
||||||
|
|
||||||
{{ define "content" }}
|
{{ define "content" }}
|
||||||
<div class="padded box mono">
|
<div class="padded box mono">
|
||||||
<div class="box-title">
|
<div class="box-title">
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
{{ define "title" }}home{{ end }}
|
|
||||||
|
|
||||||
{{ define "user" }}
|
{{ define "user" }}
|
||||||
<div class="padded box mono">
|
<div class="padded box mono">
|
||||||
<div class="box-title">
|
<div class="box-title">
|
||||||
<i class="mdi mdi-key-change"></i> updating last.fm keys
|
<i class="mdi mdi-key-change"></i> updating last.fm keys
|
||||||
</div>
|
</div>
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<span class="light">current key</span> <i>{{ if .CurrentLastFMAPIKey }}{{ .CurrentLastFMAPIKey }}{{ else }}not set{{ end }}</i><br/>
|
<span class="light">current key</span> <i>{{ default "not set" .CurrentLastFMAPIKey }}</i><br/>
|
||||||
<span class="light">current secret</span> <i>{{ if .CurrentLastFMAPISecret }}{{ .CurrentLastFMAPISecret }}{{ else }}not set{{ end }}</i>
|
<span class="light">current secret</span> <i>{{ default "not set" .CurrentLastFMAPISecret }}</i>
|
||||||
</div>
|
</div>
|
||||||
<form action="/admin/update_lastfm_api_key_do" method="post">
|
<form action="/admin/update_lastfm_api_key_do" method="post">
|
||||||
<input type="text" id="api_key" name="api_key" placeholder="new key">
|
<input type="text" id="api_key" name="api_key" placeholder="new key">
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<i class="mdi mdi-chart-arc"></i> {{ .Title }}
|
<i class="mdi mdi-chart-arc"></i> {{ .Title }}
|
||||||
</div>
|
</div>
|
||||||
<div class="block-right">
|
<div class="block-right">
|
||||||
{{ .Title }}
|
{{ .Content }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ func renderTemplate(w http.ResponseWriter, r *http.Request,
|
|||||||
}
|
}
|
||||||
err := tmpl.Execute(w, data)
|
err := tmpl.Execute(w, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("error executing template: %v\n", err)
|
log.Printf("error executing template: %v\n", err)
|
||||||
http.Redirect(w, r, "/", 500)
|
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Masterminds/sprig"
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/gorilla/securecookie"
|
"github.com/gorilla/securecookie"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@@ -26,18 +27,24 @@ func (s *Server) SetupAdmin() error {
|
|||||||
//
|
//
|
||||||
tmplBase := template.
|
tmplBase := template.
|
||||||
New("layout").
|
New("layout").
|
||||||
|
Funcs(sprig.FuncMap()).
|
||||||
Funcs(template.FuncMap{
|
Funcs(template.FuncMap{
|
||||||
"humandate": humanize.Time,
|
"humanDate": humanize.Time,
|
||||||
})
|
})
|
||||||
tmplLayouts, err := vfstemplate.ParseGlob(assets, tmplBase, "/templates/layouts/*")
|
const (
|
||||||
|
layoutDir = "/templates/layouts/*"
|
||||||
|
partialDir = "/templates/partials/*"
|
||||||
|
pageDir = "/templates/pages/*"
|
||||||
|
)
|
||||||
|
tmplLayouts, err := vfstemplate.ParseGlob(assets, tmplBase, layoutDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "parsing layouts")
|
return errors.Wrap(err, "parsing layouts")
|
||||||
}
|
}
|
||||||
tmplPartials, err := vfstemplate.ParseGlob(assets, tmplLayouts, "/templates/partials/*")
|
tmplPartials, err := vfstemplate.ParseGlob(assets, tmplLayouts, partialDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "parsing partials")
|
return errors.Wrap(err, "parsing partials")
|
||||||
}
|
}
|
||||||
pages, err := vfspath.Glob(assets, "/templates/pages/*")
|
pages, err := vfspath.Glob(assets, pageDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "parsing pages")
|
return errors.Wrap(err, "parsing pages")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user