Compare commits
	
		
			No commits in common. "0936963aaf8f9bbd367714c2dd7ce3a62ed6138c" and "885d161cf5f1baed291cc1d31ea9e90868492567" have entirely different histories.
		
	
	
		
			0936963aaf
			...
			885d161cf5
		
	
		
							
								
								
									
										12
									
								
								LICENSE
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								LICENSE
									
									
									
									
									
								
							| @ -1,12 +0,0 @@ | |||||||
| Copyright (c) 2019, Přemysl Janouch <p@janouch.name> |  | ||||||
| 
 |  | ||||||
| Permission to use, copy, modify, and/or distribute this software for any |  | ||||||
| purpose with or without fee is hereby granted. |  | ||||||
| 
 |  | ||||||
| THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |  | ||||||
| WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |  | ||||||
| MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |  | ||||||
| SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |  | ||||||
| WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |  | ||||||
| OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |  | ||||||
| CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |  | ||||||
| @ -21,12 +21,13 @@ | |||||||
| {{ end }} | {{ end }} | ||||||
| 
 | 
 | ||||||
| {{ if .Container }} | {{ if .Container }} | ||||||
|  | 
 | ||||||
| <section> | <section> | ||||||
| <header> | <header> | ||||||
| 	<h2>{{ .Container.Id }} | 	<h2>{{ .Container.Id }} | ||||||
| 		{{- range .Container.Path }} | {{ range .Container.Path }} | ||||||
| 	<small>« <a href="container?id={{ . }}">{{ . }}</a></small> | 	<small>« <a href="container?id={{ . }}">{{ . }}</a></small> | ||||||
| 		{{- end }} | {{ end }} | ||||||
| 	</h2> | 	</h2> | ||||||
| 	<form method=post action="label?id={{ .Container.Id }}" target=_blank> | 	<form method=post action="label?id={{ .Container.Id }}" target=_blank> | ||||||
| 	<input type=submit value="Vytisknout štítek"> | 	<input type=submit value="Vytisknout štítek"> | ||||||
| @ -35,27 +36,25 @@ | |||||||
| 	<input type=submit value="Odstranit"> | 	<input type=submit value="Odstranit"> | ||||||
| 	</form> | 	</form> | ||||||
| </header> | </header> | ||||||
|  | 
 | ||||||
| <form method=post action="container?id={{ .Container.Id }}"> | <form method=post action="container?id={{ .Container.Id }}"> | ||||||
| 		<textarea name=description | <textarea name=description rows="{{ max 5 (lines .Container.Description) }}" | ||||||
| 			rows="{{ max 5 (lines .Container.Description) }}" |  | ||||||
| 	placeholder="Popis obalu nebo jeho obsahu"> | 	placeholder="Popis obalu nebo jeho obsahu"> | ||||||
| 			{{- .Container.Description -}} | {{ .Container.Description }}</textarea> | ||||||
| 		</textarea> |  | ||||||
| <footer> | <footer> | ||||||
| 	<div> | 	<div> | ||||||
| 		<label for=series>Řada:</label> | 		<label for=series>Řada:</label> | ||||||
| 		<select name=series id=series> | 		<select name=series id=series> | ||||||
| 				{{- range $prefix, $desc := .AllSeries }} | {{ range $prefix, $desc := .AllSeries }} | ||||||
| 			<option value="{{ $prefix }}" | 			<option value="{{ $prefix }}" | ||||||
| 						{{ if eq $prefix $.Container.Series }}selected{{ end -}} | 				{{ if eq $prefix $.Container.Series }}selected{{ end }} | ||||||
| 				>{{ $prefix }} — {{ $desc }}</option> | 				>{{ $prefix }} — {{ $desc }}</option> | ||||||
| 				{{- end }} | {{ end }} | ||||||
| 		</select> | 		</select> | ||||||
| 	</div> | 	</div> | ||||||
| 	<div> | 	<div> | ||||||
| 		<label for=parent>Nadobal:</label> | 		<label for=parent>Nadobal:</label> | ||||||
| 				<input type=text name=parent id=parent | 		<input type=text name=parent id=parent value="{{ .Container.Parent }}"> | ||||||
| 					value="{{ .Container.Parent }}"> |  | ||||||
| 	</div> | 	</div> | ||||||
| 	<input type=submit value="Uložit"> | 	<input type=submit value="Uložit"> | ||||||
| </footer> | </footer> | ||||||
| @ -63,6 +62,7 @@ | |||||||
| </section> | </section> | ||||||
| 
 | 
 | ||||||
| <h2>Podobaly</h3> | <h2>Podobaly</h3> | ||||||
|  | 
 | ||||||
| {{ else }} | {{ else }} | ||||||
| <section> | <section> | ||||||
| <header> | <header> | ||||||
| @ -75,10 +75,10 @@ | |||||||
| 	<div> | 	<div> | ||||||
| 		<label for=series>Řada:</label> | 		<label for=series>Řada:</label> | ||||||
| 		<select name=series id=series> | 		<select name=series id=series> | ||||||
| 				{{- range $prefix, $desc := .AllSeries }} | {{ range $prefix, $desc := .AllSeries }} | ||||||
| 			<option value="{{ $prefix }}" | 			<option value="{{ $prefix }}" | ||||||
| 				>{{ $prefix }} — {{ $desc }}</option> | 				>{{ $prefix }} — {{ $desc }}</option> | ||||||
| 				{{- end }} | {{ end }} | ||||||
| 		</select> | 		</select> | ||||||
| 	</div> | 	</div> | ||||||
| 	<div> | 	<div> | ||||||
| @ -97,34 +97,26 @@ | |||||||
| <section> | <section> | ||||||
| <header> | <header> | ||||||
| 	<h3><a href="container?id={{ .Id }}">{{ .Id }}</a> | 	<h3><a href="container?id={{ .Id }}">{{ .Id }}</a> | ||||||
| 		{{- range .Path }} | {{ range .Path }} | ||||||
| 	<small>« <a href="container?id={{ . }}">{{ . }}</a></small> | 	<small>« <a href="container?id={{ . }}">{{ . }}</a></small> | ||||||
| 		{{- end }} | {{ end }} | ||||||
| 	</h3> | 	</h3> | ||||||
| 	<form method=post action="label?id={{ .Id }}" target=_blank> | 	<form method=post action="label?id={{ .Id }}" target=_blank> | ||||||
| 			{{- if $.Container }} |  | ||||||
| 			<input type=hidden name=context value="{{ $.Container.Id }}"> |  | ||||||
| 			{{- end }} |  | ||||||
| 	<input type=submit value="Vytisknout štítek"> | 	<input type=submit value="Vytisknout štítek"> | ||||||
| 	</form> | 	</form> | ||||||
| 	<form method=post action="container?id={{ .Id }}&remove"> | 	<form method=post action="container?id={{ .Id }}&remove"> | ||||||
| 			{{- if $.Container }} |  | ||||||
| 			<input type=hidden name=context value="{{ $.Container.Id }}"> |  | ||||||
| 			{{- end }} |  | ||||||
| 	<input type=submit value="Odstranit"> | 	<input type=submit value="Odstranit"> | ||||||
| 	</form> | 	</form> | ||||||
| </header> | </header> | ||||||
| 
 | {{ if .Description }} | ||||||
| 	{{- if .Description }} |  | ||||||
| <p>{{ .Description }} | <p>{{ .Description }} | ||||||
| 	{{- end }} | {{ end }} | ||||||
| 
 | {{ if .Children }} | ||||||
| 	{{- if .Children }} |  | ||||||
| <p> | <p> | ||||||
| 	{{- range .Children }} | {{ range .Children }} | ||||||
| <a href="container?id={{ .Id }}">{{ .Id }}</a> | <a href="container?id={{ .Id }}">{{ .Id }}</a> | ||||||
| 	{{- end }} | {{ end }} | ||||||
| 	{{- end }} | {{ end }} | ||||||
| </section> | </section> | ||||||
| {{ else }} | {{ else }} | ||||||
| <p>Obal je prázdný. | <p>Obal je prázdný. | ||||||
|  | |||||||
| @ -1,6 +1,5 @@ | |||||||
| {{ define "Title" }}Tisk štítku{{ end }} | {{ define "Title" }}Tisk štítku{{ end }} | ||||||
| {{ define "Content" }} | {{ define "Content" }} | ||||||
| 
 |  | ||||||
| <h2>Tisk štítku pro <a href="container?id={{ .Id }}">{{ .Id }}</a></h2> | <h2>Tisk štítku pro <a href="container?id={{ .Id }}">{{ .Id }}</a></h2> | ||||||
| 
 | 
 | ||||||
| {{ if .UnknownId }} | {{ if .UnknownId }} | ||||||
|  | |||||||
| @ -12,7 +12,6 @@ import ( | |||||||
| 	"path" | 	"path" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"sync" |  | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"janouch.name/sklad/imgutil" | 	"janouch.name/sklad/imgutil" | ||||||
| @ -104,11 +103,8 @@ func handleContainer(w http.ResponseWriter, r *http.Request) { | |||||||
| 	var err error | 	var err error | ||||||
| 	if r.Method == http.MethodPost { | 	if r.Method == http.MethodPost { | ||||||
| 		err = handleContainerPost(r) | 		err = handleContainerPost(r) | ||||||
| 		// FIXME: This is rather ugly. When removing, we want to keep | 		// XXX: This is rather ugly. When removing, we want to keep | ||||||
| 		// the context id, in addition to the id being changed. | 		// the context id, in addition to the id being changed. | ||||||
| 		// TODO: If there were no errors, redirect the user to GET, |  | ||||||
| 		// which is related to the previous comment. |  | ||||||
| 		// TODO: If there were errors, use the last data as a prefill. |  | ||||||
| 	} else if r.Method != http.MethodGet { | 	} else if r.Method != http.MethodGet { | ||||||
| 		w.WriteHeader(http.StatusMethodNotAllowed) | 		w.WriteHeader(http.StatusMethodNotAllowed) | ||||||
| 		return | 		return | ||||||
| @ -309,8 +305,6 @@ func handleLabel(w http.ResponseWriter, r *http.Request) { | |||||||
| 	executeTemplate("label.tmpl", w, ¶ms) | 	executeTemplate("label.tmpl", w, ¶ms) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| var mutex sync.Mutex |  | ||||||
| 
 |  | ||||||
| func handle(w http.ResponseWriter, r *http.Request) { | func handle(w http.ResponseWriter, r *http.Request) { | ||||||
| 	if err := r.ParseForm(); err != nil { | 	if err := r.ParseForm(); err != nil { | ||||||
| 		http.Error(w, err.Error(), http.StatusInternalServerError) | 		http.Error(w, err.Error(), http.StatusInternalServerError) | ||||||
| @ -320,9 +314,6 @@ func handle(w http.ResponseWriter, r *http.Request) { | |||||||
| 		w.Header().Set("Cache-Control", "no-store") | 		w.Header().Set("Cache-Control", "no-store") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	mutex.Lock() |  | ||||||
| 	defer mutex.Unlock() |  | ||||||
| 
 |  | ||||||
| 	switch _, base := path.Split(r.URL.Path); base { | 	switch _, base := path.Split(r.URL.Path); base { | ||||||
| 	case "login": | 	case "login": | ||||||
| 		handleLogin(w, r) | 		handleLogin(w, r) | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| {{ define "Title" }}„{{ .Query }}“ — Vyhledávání{{ end }} | {{ define "Title" }}„{{ .Query }}“ — Vyhledávání{{ end }} | ||||||
| {{ define "Content" }} | {{ define "Content" }} | ||||||
| 
 | 
 | ||||||
| <h2>Vyhledávání: „{{ .Query }}“</h2> | <h2>Vyhledávání: „{{ .Query }}“<h2> | ||||||
| 
 | 
 | ||||||
| <h3>Řady</h3> | <h3>Řady</h3> | ||||||
| 
 | 
 | ||||||
| @ -22,14 +22,14 @@ | |||||||
| <section> | <section> | ||||||
| <header> | <header> | ||||||
| 	<h3><a href="container?id={{ .Id }}">{{ .Id }}</a> | 	<h3><a href="container?id={{ .Id }}">{{ .Id }}</a> | ||||||
| 		{{- range .Path }} | {{ range .Path }} | ||||||
| 	<small>« <a href="container?id={{ . }}">{{ . }}</a></small> | 	<small>« <a href="container?id={{ . }}">{{ . }}</a></small> | ||||||
| 		{{- end }} | {{ end }} | ||||||
| 	</h3> | 	</h3> | ||||||
| </header> | </header> | ||||||
| 	{{- if .Description }} | {{ if .Description }} | ||||||
| <p>{{ .Description }} | <p>{{ .Description }} | ||||||
| 	{{- end }} | {{ end }} | ||||||
| </section> | </section> | ||||||
| {{ else }} | {{ else }} | ||||||
| <p>Neodpovídají žádné obaly. | <p>Neodpovídají žádné obaly. | ||||||
|  | |||||||
| @ -22,6 +22,7 @@ | |||||||
| <p>{{ .Description }} | <p>{{ .Description }} | ||||||
| {{ end }} | {{ end }} | ||||||
| {{ else }} | {{ else }} | ||||||
|  | 
 | ||||||
| <section> | <section> | ||||||
| <form method=post action="series"> | <form method=post action="series"> | ||||||
| <header> | <header> | ||||||
| @ -29,6 +30,7 @@ | |||||||
| 	<input type=text name=prefix placeholder="Prefix řady"> | 	<input type=text name=prefix placeholder="Prefix řady"> | ||||||
| 	<input type=text name=description placeholder="Popis řady" | 	<input type=text name=description placeholder="Popis řady" | ||||||
| 	><input type=submit value="Uložit"> | 	><input type=submit value="Uložit"> | ||||||
|  | 	</form> | ||||||
| </header> | </header> | ||||||
| </form> | </form> | ||||||
| </section> | </section> | ||||||
| @ -37,15 +39,15 @@ | |||||||
| <section> | <section> | ||||||
| <header> | <header> | ||||||
| 	<h3><a href="series?prefix={{ .Prefix }}">{{ .Prefix }}</a></h3> | 	<h3><a href="series?prefix={{ .Prefix }}">{{ .Prefix }}</a></h3> | ||||||
| 		{{- with $count := len .Containers }} | {{ with $count := len .Containers }} | ||||||
| 		{{- if eq $count 1 }} | {{ if eq $count 1 }} | ||||||
| 	<p>{{ $count }} obal | 	<p>{{ $count }} obal | ||||||
| 		{{- else if and (ge $count 2) (le $count 4) }} | {{ else if and (ge $count 2) (le $count 4) }} | ||||||
| 	<p>{{ $count }} obaly | 	<p>{{ $count }} obaly | ||||||
| 		{{- else if gt $count 0 }} | {{ else if gt $count 0 }} | ||||||
| 	<p>{{ $count }} obalů | 	<p>{{ $count }} obalů | ||||||
| 		{{- end }} | {{ end }} | ||||||
| 		{{- end }} | {{ end }} | ||||||
| 	<form method=post action="series?prefix={{ .Prefix }}"> | 	<form method=post action="series?prefix={{ .Prefix }}"> | ||||||
| 	<input type=text name=description value="{{ .Description }}" | 	<input type=text name=description value="{{ .Description }}" | ||||||
| 	><input type=submit value="Uložit"> | 	><input type=submit value="Uložit"> | ||||||
| @ -58,6 +60,7 @@ | |||||||
| {{ else }} | {{ else }} | ||||||
| <p>Nejsou žádné řady. | <p>Nejsou žádné řady. | ||||||
| {{ end }} | {{ end }} | ||||||
|  | 
 | ||||||
| {{ end }} | {{ end }} | ||||||
| 
 | 
 | ||||||
| {{ end }} | {{ end }} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user