Compare commits
	
		
			No commits in common. "3d98454543f4494fd267e851b48d58a05aea11dc" and "e003427f9f86b0b3898cca67b39a96e391fd1b16" have entirely different histories.
		
	
	
		
			3d98454543
			...
			e003427f9f
		
	
		
| @ -53,7 +53,7 @@ | |||||||
| 	<a href=/series>Řady</a> | 	<a href=/series>Řady</a> | ||||||
| 
 | 
 | ||||||
| 	<form method=get action=/search> | 	<form method=get action=/search> | ||||||
| 	<input type=text name=q autofocus><input type=submit value="Hledat"> | 	<input type=text name=q><input type=submit value="Hledat"> | ||||||
| 	</form> | 	</form> | ||||||
| 
 | 
 | ||||||
| 	<form method=post action=/logout> | 	<form method=post action=/logout> | ||||||
|  | |||||||
| @ -1,23 +1,22 @@ | |||||||
| {{ define "Title" }}{{/* | {{ define "Title" }}{{ or .Id "Obaly" }}{{ end }} | ||||||
| */}}{{ if .Container }}{{ .Container.Id }}{{ else }}Obaly{{ end }}{{ end }} |  | ||||||
| {{ define "Content" }} | {{ define "Content" }} | ||||||
| 
 | 
 | ||||||
| {{ if .Container }} | {{ if .Id }} | ||||||
| 
 | 
 | ||||||
| <section> | <section> | ||||||
| <header> | <header> | ||||||
| 	<h2>{{ .Container.Id }}</h2> | 	<h2>{{ .Id }}</h2> | ||||||
| 	<form method=post action="/label?id={{ .Container.Id }}"> | 	<form method=post action="/label?id={{ .Id }}"> | ||||||
| 	<input type=submit value="Vytisknout štítek"> | 	<input type=submit value="Vytisknout štítek"> | ||||||
| 	</form> | 	</form> | ||||||
| 	<form method=post action="/?id={{ .Container.Id }}&remove"> | 	<form method=post action="/?id={{ .Id }}&remove"> | ||||||
| 	<input type=submit value="Odstranit"> | 	<input type=submit value="Odstranit"> | ||||||
| 	</form> | 	</form> | ||||||
| </header> | </header> | ||||||
| 
 | 
 | ||||||
| <form method=post action="/?id={{ .Container.Id }}"> | <form method=post action="/?id={{ .Id }}"> | ||||||
| <textarea name=description rows=5> | <textarea name=description rows=5> | ||||||
| {{ .Container.Description }} | {{ .Description }} | ||||||
| </textarea> | </textarea> | ||||||
| <footer> | <footer> | ||||||
| 	<div> | 	<div> | ||||||
| @ -25,14 +24,14 @@ | |||||||
| 		<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 $.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 value="{{ .Container.Parent }}"> | 		<input type=text name=parent id=parent value="{{ .Parent }}"> | ||||||
| 	</div> | 	</div> | ||||||
| 	<input type=submit value="Uložit"> | 	<input type=submit value="Uložit"> | ||||||
| </footer> | </footer> | ||||||
| @ -55,6 +54,7 @@ | |||||||
| 		<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 $.Series }}selected{{ end }} | ||||||
| 				>{{ $prefix }} — {{ $desc }}</option> | 				>{{ $prefix }} — {{ $desc }}</option> | ||||||
| {{ end }} | {{ end }} | ||||||
| 		</select> | 		</select> | ||||||
| @ -74,7 +74,7 @@ | |||||||
| {{ range .Children }} | {{ range .Children }} | ||||||
| <section> | <section> | ||||||
| <header> | <header> | ||||||
| 	<h3><a href="/?id={{ .Id }}">{{ .Id }}</a></h3> | 	<h3><a href="/container?id={{ .Id }}">{{ .Id }}</a></h3> | ||||||
| 	<form method=post action="/label?id={{ .Id }}"> | 	<form method=post action="/label?id={{ .Id }}"> | ||||||
| 	<input type=submit value="Vytisknout štítek"> | 	<input type=submit value="Vytisknout štítek"> | ||||||
| 	</form> | 	</form> | ||||||
| @ -85,12 +85,6 @@ | |||||||
| {{ if .Description }} | {{ if .Description }} | ||||||
| <p>{{ .Description }} | <p>{{ .Description }} | ||||||
| {{ end }} | {{ end }} | ||||||
| {{ if .Children }} |  | ||||||
| <p> |  | ||||||
| {{ range .Children }} |  | ||||||
| <a href="/?id={{ .Id }}">{{ .Id }}</a> |  | ||||||
| {{ end }} |  | ||||||
| {{ end }} |  | ||||||
| </section> | </section> | ||||||
| {{ else }} | {{ else }} | ||||||
| <p>Obal je prázdný. | <p>Obal je prázdný. | ||||||
|  | |||||||
| @ -13,8 +13,6 @@ type Series struct { | |||||||
| 	Description string // what kind of containers this is for | 	Description string // what kind of containers this is for | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type ContainerId string |  | ||||||
| 
 |  | ||||||
| type Container struct { | type Container struct { | ||||||
| 	Series      string      // PK: what series does this belong to | 	Series      string      // PK: what series does this belong to | ||||||
| 	Number      uint        // PK: order within the series | 	Number      uint        // PK: order within the series | ||||||
| @ -22,15 +20,12 @@ type Container struct { | |||||||
| 	Description string      // description and/or contents of this container | 	Description string      // description and/or contents of this container | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | type ContainerId string | ||||||
|  | 
 | ||||||
| func (c *Container) Id() ContainerId { | func (c *Container) Id() ContainerId { | ||||||
| 	return ContainerId(fmt.Sprintf("%s%s%d", db.Prefix, c.Series, c.Number)) | 	return ContainerId(fmt.Sprintf("%s%s%d", db.Prefix, c.Series, c.Number)) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (c *Container) Children() []*Container { |  | ||||||
| 	// TODO: Sort this by Id, or maybe even return a map[string]*Container. |  | ||||||
| 	return indexChildren[c.Id()] |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| type Database struct { | type Database struct { | ||||||
| 	Password   string       // password for web users | 	Password   string       // password for web users | ||||||
| 	Prefix     string       // prefix for all container IDs | 	Prefix     string       // prefix for all container IDs | ||||||
|  | |||||||
| @ -6,7 +6,7 @@ | |||||||
| 
 | 
 | ||||||
| <form method=post> | <form method=post> | ||||||
| <label for=password>Heslo:</label> | <label for=password>Heslo:</label> | ||||||
| <input type=password name=password id=password autofocus | <input type=password name=password id=password | ||||||
| ><input type=submit value="Přihlásit"> | ><input type=submit value="Přihlásit"> | ||||||
| </form> | </form> | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -92,24 +92,35 @@ func handleContainer(w http.ResponseWriter, r *http.Request) { | |||||||
| 		allSeries[s.Prefix] = s.Description | 		allSeries[s.Prefix] = s.Description | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	var container *Container |  | ||||||
| 	children := []*Container{} | 	children := []*Container{} | ||||||
|  | 	id := ContainerId(r.FormValue("id")) | ||||||
|  | 	description := "" | ||||||
|  | 	series := "" | ||||||
|  | 	parent := ContainerId("") | ||||||
| 
 | 
 | ||||||
| 	if id := ContainerId(r.FormValue("id")); id == "" { | 	if id == "" { | ||||||
| 		children = indexChildren[""] | 		children = indexChildren[id] | ||||||
| 	} else if c, ok := indexContainer[id]; ok { | 	} else if container, ok := indexContainer[id]; ok { | ||||||
| 		children = c.Children() | 		children = indexChildren[id] | ||||||
| 		container = c | 		description = container.Description | ||||||
|  | 		series = container.Series | ||||||
|  | 		parent = container.Parent | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	params := struct { | 	params := struct { | ||||||
| 		Container *Container | 		Id          ContainerId | ||||||
| 		Children  []*Container | 		Description string | ||||||
| 		AllSeries map[string]string | 		Children    []*Container | ||||||
|  | 		Series      string | ||||||
|  | 		Parent      ContainerId | ||||||
|  | 		AllSeries   map[string]string | ||||||
| 	}{ | 	}{ | ||||||
| 		Container: container, | 		Id:          id, | ||||||
| 		Children:  children, | 		Description: description, | ||||||
| 		AllSeries: allSeries, | 		Children:    children, | ||||||
|  | 		Series:      series, | ||||||
|  | 		Parent:      parent, | ||||||
|  | 		AllSeries:   allSeries, | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	executeTemplate("container.tmpl", w, ¶ms) | 	executeTemplate("container.tmpl", w, ¶ms) | ||||||
| @ -160,7 +171,6 @@ func handleSearch(w http.ResponseWriter, r *http.Request) { | |||||||
| 	_ = query | 	_ = query | ||||||
| 
 | 
 | ||||||
| 	// TODO: Query the database for exact matches and fulltext. | 	// TODO: Query the database for exact matches and fulltext. | ||||||
| 	//  - Will want to show the full path from the root "" container. |  | ||||||
| 
 | 
 | ||||||
| 	params := struct{}{} | 	params := struct{}{} | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user