idiotbox-go

youtube web application in Go
git clone git://git.codemadness.org/idiotbox-go
Log | Files | Refs | README | LICENSE

commit d753e1781a998d8f2782a90986306c7c89cf6130
parent 164e5b288a3d4d7205d875f3b2142f1d2d29bb83
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun, 17 Sep 2017 12:34:29 +0200

add order support:

- add dropdown for "order by".
- allow parameter "o" and use it in pagination also.

Diffstat:
data/templates/pages/search.html | 14++++++++++++--
main.go | 2++
2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/data/templates/pages/search.html b/data/templates/pages/search.html @@ -15,6 +15,16 @@ </td> <td nowrap class="nowrap"> <input type="submit" value="Search" class="button" /> + + <select name="o" title="Order by" accesskey="o"> + <option value="date"{{if eq .Order "date"}} selected="selected"{{end}}>Creation date</option> + <option value="rating"{{if eq .Order "rating"}} selected="selected"{{end}}>Rating</option> + <option value="relevance"{{if or (not .Order) (eq .Order "relevance")}} selected="selected"{{end}}>Relevance</option> + <option value="title"{{if eq .Order "title"}} selected="selected"{{end}}>Title</option> + <!--<option value="videoCount"{{if eq .Order "videoCount"}} selected="selected"{{end}}>Amount of uploaded videos per channel</option>--> + <option value="viewCount"{{if eq .Order "viewCount"}} selected="selected"{{end}}>Views</option> + </select> + <label>Style: </label> {{if eq .Mode "light"}} <a href="?m=dark&q={{.Query}}" title="Dark mode" accesskey="s">Dark</a> @@ -66,13 +76,13 @@ <tr> <td align="left" class="nowrap" nowrap> {{if .Searchresult.Searchlist.Prevpagetoken}} - <a href="?q={{.Query}}&next={{.Searchresult.Searchlist.Prevpagetoken}}&m={{.Mode}}" rel="prev nofollow" accesskey="p">&larr; prev</a> + <a href="?q={{.Query}}&next={{.Searchresult.Searchlist.Prevpagetoken}}&m={{.Mode}}&o={{.Order}}" rel="prev nofollow" accesskey="p">&larr; prev</a> {{end}} </td> <td></td> <td align="right" nowrap class="a-r nowrap"> {{if .Searchresult.Searchlist.Nextpagetoken}} - <a href="?q={{.Query}}&next={{.Searchresult.Searchlist.Nextpagetoken}}&m={{.Mode}}" rel="next nofollow" accesskey="n">next &rarr;</a> + <a href="?q={{.Query}}&next={{.Searchresult.Searchlist.Nextpagetoken}}&m={{.Mode}}&o={{.Order}}" rel="next nofollow" accesskey="n">next &rarr;</a> {{end}} </td> </tr> diff --git a/main.go b/main.go @@ -176,12 +176,14 @@ func SearchHandler(w http.ResponseWriter, r *http.Request) error { return templates.Render(w, "search.html", "page.html", struct { Next string Mode string + Order string Query string Stylesheet string Searchresult *SearchResult }{ Next: next, Mode: mode, + Order: o, Query: q, Stylesheet: stylesheet, Searchresult: searchresult,