diff --git a/bouquins/bouquins.go b/bouquins/bouquins.go index e01d561..a7c740f 100644 --- a/bouquins/bouquins.go +++ b/bouquins/bouquins.go @@ -12,6 +12,14 @@ const ( TPL_AUTHORS = "author.html" TPL_SERIES = "series.html" TPL_INDEX = "index.html" + + PARAM_LIST = "list" + PARAM_ORDER = "order" + PARAM_SORT = "sort" + + LIST_AUTHORS = "authors" + LIST_SERIES = "series" + LIST_BOOKS = "books" ) type Bouquins struct { @@ -146,7 +154,17 @@ func (app *Bouquins) IndexPage(res http.ResponseWriter, req *http.Request) { log.Print(err) } model := NewIndexModel("", count) - model.Books, err = app.BooksAdv(0, 0, "", "") + order, sort := req.URL.Query().Get(PARAM_ORDER), req.URL.Query().Get(PARAM_SORT) + switch req.URL.Query().Get(PARAM_LIST) { + case LIST_AUTHORS: + model.Authors, err = app.AuthorsAdv(0, 0, sort, order) + case LIST_SERIES: + model.Series, err = app.SeriesAdv(0, 0, sort, order) + case LIST_BOOKS: + fallthrough + default: + model.Books, err = app.BooksAdv(0, 0, sort, order) + } if err != nil { log.Print(err) } diff --git a/bouquins/db.go b/bouquins/db.go index 41e3409..e11bd3d 100644 --- a/bouquins/db.go +++ b/bouquins/db.go @@ -196,6 +196,12 @@ func (app *Bouquins) BookCount() (int64, error) { err := row.Scan(&count) return count, err } +func (app *Bouquins) SeriesAdv(limit, offset int, sort, order string) ([]*SeriesAdv, error) { + panic("not implemented") +} +func (app *Bouquins) AuthorsAdv(limit, offset int, sort, order string) ([]*AuthorAdv, error) { + panic("not implemented") +} func (app *Bouquins) BooksAdv(limit, offset int, sort, order string) ([]*BookAdv, error) { if limit == 0 {