clean up templates
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{{ template "title" }}</title>
|
||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">
|
||||
<title>gonic</title>
|
||||
<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="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">
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
{{ define "title" }}home{{ end }}
|
||||
|
||||
{{ define "content" }}
|
||||
<div class="side-padded light text-right mono">
|
||||
welcome {{ .User.Name }}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
{{ define "title" }}home{{ end }}
|
||||
|
||||
{{ define "user" }}
|
||||
<div class="padded box mono">
|
||||
<div class="box-title">
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
{{ define "title" }}home{{ end }}
|
||||
|
||||
{{ define "user" }}
|
||||
<div class="padded box mono">
|
||||
<div class="box-title">
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
{{ define "title" }}home{{ end }}
|
||||
|
||||
{{ define "user" }}
|
||||
<div class="padded box mono">
|
||||
<div class="box-title">
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
{{ define "title" }}home{{ end }}
|
||||
|
||||
{{ define "user" }}
|
||||
<div class="padded box mono">
|
||||
<div class="box-title">
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
{{ define "title" }}home{{ end }}
|
||||
|
||||
{{ define "user" }}
|
||||
<div class="padded box mono">
|
||||
<div class="box-title">
|
||||
@@ -78,7 +76,7 @@
|
||||
{{ range $folder := .RecentFolders }}
|
||||
<tr>
|
||||
<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>
|
||||
{{ end }}
|
||||
</table>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
{{ define "title" }}gonic{{ end }}
|
||||
|
||||
{{ define "content" }}
|
||||
<div class="padded box mono">
|
||||
<div class="box-title">
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
{{ define "title" }}home{{ end }}
|
||||
|
||||
{{ define "user" }}
|
||||
<div class="padded box mono">
|
||||
<div class="box-title">
|
||||
<i class="mdi mdi-key-change"></i> updating last.fm keys
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<span class="light">current key</span> <i>{{ if .CurrentLastFMAPIKey }}{{ .CurrentLastFMAPIKey }}{{ else }}not set{{ end }}</i><br/>
|
||||
<span class="light">current secret</span> <i>{{ if .CurrentLastFMAPISecret }}{{ .CurrentLastFMAPISecret }}{{ else }}not set{{ end }}</i>
|
||||
<span class="light">current key</span> <i>{{ default "not set" .CurrentLastFMAPIKey }}</i><br/>
|
||||
<span class="light">current secret</span> <i>{{ default "not set" .CurrentLastFMAPISecret }}</i>
|
||||
</div>
|
||||
<form action="/admin/update_lastfm_api_key_do" method="post">
|
||||
<input type="text" id="api_key" name="api_key" placeholder="new key">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<i class="mdi mdi-chart-arc"></i> {{ .Title }}
|
||||
</div>
|
||||
<div class="block-right">
|
||||
{{ .Title }}
|
||||
{{ .Content }}
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
@@ -38,8 +38,8 @@ func renderTemplate(w http.ResponseWriter, r *http.Request,
|
||||
}
|
||||
err := tmpl.Execute(w, data)
|
||||
if err != nil {
|
||||
log.Println("error executing template: %v\n", err)
|
||||
http.Redirect(w, r, "/", 500)
|
||||
log.Printf("error executing template: %v\n", err)
|
||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/Masterminds/sprig"
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/gorilla/securecookie"
|
||||
"github.com/pkg/errors"
|
||||
@@ -26,18 +27,24 @@ func (s *Server) SetupAdmin() error {
|
||||
//
|
||||
tmplBase := template.
|
||||
New("layout").
|
||||
Funcs(sprig.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 {
|
||||
return errors.Wrap(err, "parsing layouts")
|
||||
}
|
||||
tmplPartials, err := vfstemplate.ParseGlob(assets, tmplLayouts, "/templates/partials/*")
|
||||
tmplPartials, err := vfstemplate.ParseGlob(assets, tmplLayouts, partialDir)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "parsing partials")
|
||||
}
|
||||
pages, err := vfspath.Glob(assets, "/templates/pages/*")
|
||||
pages, err := vfspath.Glob(assets, pageDir)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "parsing pages")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user