{{define "title"}}Search{{end}}
{{define "content"}}
	<form action="/search" method="get">
		<input id="term" name="term" type="search" placeholder="search" value="{{.Term}}" autocomplete="on" required>
		<select id="lang" name="lang">
			{{range .Langs}}
				{{if eq . $.Lang}}
					<option selected>{{.}}</option>
				{{else}}
					<option>{{.}}</option>
				{{end}}
			{{end}}
		</select>
		<select id="order" name="order">
			{{range .Orders}}
				{{if eq . $.Order}}
					<option selected>{{.}}</option>
				{{else}}
					<option>{{.}}</option>
				{{end}}
			{{end}}
		</select>
	</form>
	<table>
	{{range .Items}}
		<tr>
			<td>
				<a href="/embed?id={{.Id}}"><img width=240 src="{{.ThumbUrl}}"></a>
			</td>
			<td>
				<a href="/embed?id={{.Id}}">{{.Title}}</a>
				<br/>
				<a href="{{.ChannelUrl}}">{{.ChannelTitle}}</a> | <a href="{{.AtomUrl}}">Atom feed</a>
				<br/>
				<a href="{{.Url}}">Comments</a>
				<br/>
				{{.ViewCount}}
				<br/>
				{{.Published}}
			</td>
			<td>
				{{.LengthText}}
			</td>
		</tr>
	{{end}}
	</table>
	{{if ge .Page 0 }}
		<a href="/search?term={{.Term}}&page={{dec .Page}}&lang={{.Lang}}">Prev Page</a> |
		<a href="/search?term={{.Term}}&page={{inc .Page}}&lang={{.Lang}}">Next Page</a>
	{{end}}
{{end}}
