Add basic html/rss support for book lists
This commit is contained in:
parent
c0a70a18e1
commit
46762ea17b
11 changed files with 254 additions and 78 deletions
|
@ -52,6 +52,8 @@ type bookData struct {
|
|||
S Status
|
||||
Book database.Book
|
||||
Description []string
|
||||
Lists []database.BookList
|
||||
UserLists []string
|
||||
}
|
||||
|
||||
func bookHandler(h handler) {
|
||||
|
@ -71,6 +73,21 @@ func bookHandler(h handler) {
|
|||
}
|
||||
data.S.Title = book.Title + author + " -- " + data.S.Title
|
||||
|
||||
data.Lists, err = h.db.GetListsByBook(id)
|
||||
if err != nil {
|
||||
log.Error("Error getting lists: ", err)
|
||||
}
|
||||
if h.sess.User != "" {
|
||||
userLists, err := h.db.GetListsByUser(h.sess.User)
|
||||
if err != nil {
|
||||
log.Error("Error getting lists: ", err)
|
||||
} else {
|
||||
data.UserLists = make([]string, len(userLists))
|
||||
for i, l := range userLists {
|
||||
data.UserLists[i] = l.Title
|
||||
}
|
||||
}
|
||||
}
|
||||
data.Description = strings.Split(data.Book.Description, "\n")
|
||||
h.load("book", data)
|
||||
}
|
||||
|
@ -191,6 +208,9 @@ func InitRouter(db database.DB, sg *StatsGatherer, assetsPath string) http.Handl
|
|||
r.HandleFunc("/dashboard/", sg.Gather(dashboardHandler))
|
||||
r.HandleFunc("/settings/", sg.Gather(settingsHandler))
|
||||
|
||||
r.HandleFunc("/list/{listID:"+idPattern+"}", sg.Gather(listHandler)).Methods("GET")
|
||||
r.HandleFunc("/list/", sg.Gather(listPostHandler)).Methods("POST")
|
||||
|
||||
r.HandleFunc("/new/", sg.Gather(newHandler))
|
||||
r.HandleFunc("/save/{id:"+idPattern+"}", sg.Gather(saveHandler)).Methods("POST")
|
||||
r.HandleFunc("/edit/{id:"+idPattern+"}", sg.Gather(editHandler))
|
||||
|
|
Reference in a new issue