Add search terms to the moderation page

* Closes: #22
This commit is contained in:
Las Zenow 2017-02-04 01:28:10 +00:00
parent fcf9b1eb8d
commit 8e82ee3702
5 changed files with 26 additions and 15 deletions

View file

@ -127,12 +127,13 @@ type newBook struct {
B database.Book
}
type newData struct {
S Status
Found int
Books []newBook
Page int
Next string
Prev string
S Status
Found int
Books []newBook
Page int
Next string
Prev string
Search string
}
func newHandler(h handler) {
@ -146,6 +147,7 @@ func newHandler(h handler) {
http.Error(h.w, err.Error(), http.StatusInternalServerError)
return
}
req := strings.Join(h.r.Form["q"], " ")
page := 0
if len(h.r.Form["p"]) != 0 {
page, err = strconv.Atoi(h.r.Form["p"][0])
@ -153,7 +155,7 @@ func newHandler(h handler) {
page = 0
}
}
res, num, _ := h.db.GetNewBooks(newItemsPage, page*newItemsPage)
res, num, _ := h.db.GetNewBooks(req, newItemsPage, page*newItemsPage)
var data newData
data.S = GetStatus(h)
@ -176,6 +178,7 @@ func newHandler(h handler) {
if page > 0 {
data.Prev = "/new/?p=" + strconv.Itoa(page-1)
}
data.Search = req
h.template.load(h, "new", data)
}