counter add anotations
This commit is contained in:
parent
d612ce68c4
commit
13433c2972
2 changed files with 24 additions and 2 deletions
|
@ -9,6 +9,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang-migrate/migrate/v4"
|
"github.com/golang-migrate/migrate/v4"
|
||||||
|
@ -23,6 +24,14 @@ var conf config.Config
|
||||||
|
|
||||||
var templates *template.Template
|
var templates *template.Template
|
||||||
|
|
||||||
|
var funcMap = template.FuncMap{
|
||||||
|
"sub": sub,
|
||||||
|
}
|
||||||
|
|
||||||
|
func sub(a, b int64) string {
|
||||||
|
return strconv.FormatInt(a-b, 10)
|
||||||
|
}
|
||||||
|
|
||||||
var db *pgxpool.Pool
|
var db *pgxpool.Pool
|
||||||
|
|
||||||
func Start(_conf config.Config, tmplFS embed.FS, staticFS embed.FS, migrationsFS embed.FS) {
|
func Start(_conf config.Config, tmplFS embed.FS, staticFS embed.FS, migrationsFS embed.FS) {
|
||||||
|
@ -33,7 +42,9 @@ func Start(_conf config.Config, tmplFS embed.FS, staticFS embed.FS, migrationsFS
|
||||||
fs := http.FileServer(staticServer)
|
fs := http.FileServer(staticServer)
|
||||||
|
|
||||||
// Templates
|
// Templates
|
||||||
t, err := template.ParseFS(tmplFS, "tmpl/*.tmpl")
|
t := template.New("")
|
||||||
|
t.Funcs(funcMap)
|
||||||
|
t, err := t.ParseFS(tmplFS, "tmpl/*.tmpl")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("Parsing templates: %w", err))
|
panic(fmt.Errorf("Parsing templates: %w", err))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,18 @@
|
||||||
{{template "head"}}
|
{{template "head"}}
|
||||||
<div id="wierd-flex" class="counter">
|
<div id="wierd-flex" class="counter">
|
||||||
{{range $c := .Counter}}
|
{{ $l := len .Counter }}
|
||||||
|
{{range $i, $c := .Counter}}
|
||||||
<img class="counter-image" alt="{{$c}}" src="/static/counter/{{$c}}.gif">
|
<img class="counter-image" alt="{{$c}}" src="/static/counter/{{$c}}.gif">
|
||||||
|
{{ $n := sub $l $i }}
|
||||||
|
{{ if $n eq 4 }}
|
||||||
|
KB
|
||||||
|
{{ else if $n eq 8 }}
|
||||||
|
MB
|
||||||
|
{{ else if $n eq 12 }}
|
||||||
|
GB
|
||||||
|
{{ else if $n eq 16 }}
|
||||||
|
TB
|
||||||
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
<h2>Workers</h2>
|
<h2>Workers</h2>
|
||||||
|
|
Loading…
Add table
Reference in a new issue