vods layout: autofocus search field, use f as format parameter - twitch-go - twitch.tv web application in Go
(HTM) git clone git://git.codemadness.org/twitch-go
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 4d831a39ecffe51c5e64ac72a1f9a8ce832a5314
(DIR) parent ce4781ef15eb2330b793db45629d223a7e294b98
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sat, 6 Apr 2019 20:39:05 +0200
vods layout: autofocus search field, use f as format parameter
Diffstat:
M data/templates/pages/vods.html | 4 ++--
M main.go | 7 ++++---
2 files changed, 6 insertions(+), 5 deletions(-)
---
(DIR) diff --git a/data/templates/pages/vods.html b/data/templates/pages/vods.html
@@ -5,7 +5,7 @@
{{if .Search}}
-<p><a href="?n={{.Search}}&format=atom">Atom feed</a></p>
+<p><a href="?n={{.Search}}&f=atom">Atom feed</a></p>
<table class="table" border="0">
<thead>
@@ -31,7 +31,7 @@
{{else}}
<form method="get" action="">
- <input type="search" name="n" value="" placeholder="Login name..." />
+ <input type="search" name="n" value="" placeholder="Login name..." autofocus="autofocus" />
<input type="submit" name="list" value="List vods" />
</form>
(DIR) diff --git a/main.go b/main.go
@@ -218,7 +218,7 @@ func VODSHandler(w http.ResponseWriter, r *http.Request) error {
var users *twitch.Users
var videos *twitch.Videos
- format := r.FormValue("format")
+ format := r.FormValue("f")
name := r.FormValue("n")
v := struct {
@@ -250,11 +250,12 @@ func VODSHandler(w http.ResponseWriter, r *http.Request) error {
v.Videos = videos.Items
}
- if format == "atom" {
+ switch format {
+ case "atom":
w.Header().Set("Content-Type", "text/xml; charset=utf-8")
fmt.Fprintf(w, `<?xml version="1.0" encoding="UTF-8"?>`+"\n")
return templates.Render(w, "vods.xml", "atom.xml", v)
- } else {
+ default:
return templates.Render(w, "vods.html", "page.html", v)
}
}