Compare commits
4 Commits
5b7113905e
...
1713bd1f06
Author | SHA1 | Date | |
---|---|---|---|
1713bd1f06 | |||
f8bb344aab | |||
0b32fa576f | |||
82c6c34ea5 |
@ -36,9 +36,9 @@
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<form method=post action="container?id={{ .Container.Id }}">
|
<form method=post action="container?id={{ .Container.Id }}">
|
||||||
<textarea name=description rows=5>
|
<textarea name=description rows="{{ max 5 (lines .Container.Description) }}"
|
||||||
{{ .Container.Description }}
|
placeholder="Popis obalu nebo jeho obsahu">
|
||||||
</textarea>
|
{{ .Container.Description }}</textarea>
|
||||||
<footer>
|
<footer>
|
||||||
<div>
|
<div>
|
||||||
<label for=series>Řada:</label>
|
<label for=series>Řada:</label>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{{ define "Title" }}Tisk štítku{{ end }}
|
{{ define "Title" }}Tisk štítku{{ end }}
|
||||||
{{ define "Content" }}
|
{{ define "Content" }}
|
||||||
<h2>Tisk štítku pro {{ .Id }}</h2>
|
<h2>Tisk štítku pro <a href="container?id={{ .Id }}">{{ .Id }}</a></h2>
|
||||||
|
|
||||||
{{ if .UnknownId }}
|
{{ if .UnknownId }}
|
||||||
<p>Neznámý obal.
|
<p>Neznámý obal.
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"janouch.name/sklad/imgutil"
|
"janouch.name/sklad/imgutil"
|
||||||
@ -73,9 +74,9 @@ func handleLogout(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func handleContainerPost(r *http.Request) error {
|
func handleContainerPost(r *http.Request) error {
|
||||||
id := ContainerId(r.FormValue("id"))
|
id := ContainerId(r.FormValue("id"))
|
||||||
description := r.FormValue("description")
|
description := strings.TrimSpace(r.FormValue("description"))
|
||||||
series := r.FormValue("series")
|
series := r.FormValue("series")
|
||||||
parent := ContainerId(r.FormValue("parent"))
|
parent := ContainerId(strings.TrimSpace(r.FormValue("parent")))
|
||||||
_, remove := r.Form["remove"]
|
_, remove := r.Form["remove"]
|
||||||
|
|
||||||
if container, ok := indexContainer[id]; ok {
|
if container, ok := indexContainer[id]; ok {
|
||||||
@ -150,8 +151,8 @@ func handleContainer(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handleSeriesPost(r *http.Request) error {
|
func handleSeriesPost(r *http.Request) error {
|
||||||
prefix := r.FormValue("prefix")
|
prefix := strings.TrimSpace(r.FormValue("prefix"))
|
||||||
description := r.FormValue("description")
|
description := strings.TrimSpace(r.FormValue("description"))
|
||||||
_, remove := r.Form["remove"]
|
_, remove := r.Form["remove"]
|
||||||
|
|
||||||
if series, ok := indexSeries[prefix]; ok {
|
if series, ok := indexSeries[prefix]; ok {
|
||||||
@ -333,6 +334,18 @@ func handle(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var funcMap = template.FuncMap{
|
||||||
|
"max": func(i, j int) int {
|
||||||
|
if i > j {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
return j
|
||||||
|
},
|
||||||
|
"lines": func(s string) int {
|
||||||
|
return strings.Count(s, "\n") + 1
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Randomize the RNG for session string generation.
|
// Randomize the RNG for session string generation.
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
@ -355,7 +368,8 @@ func main() {
|
|||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
for _, name := range m {
|
for _, name := range m {
|
||||||
templates[name] = template.Must(template.ParseFiles("base.tmpl", name))
|
templates[name] = template.Must(template.New("base.tmpl").
|
||||||
|
Funcs(funcMap).ParseFiles("base.tmpl", name))
|
||||||
}
|
}
|
||||||
|
|
||||||
http.HandleFunc("/", handle)
|
http.HandleFunc("/", handle)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user