mirror of
https://github.com/miniflux/v2.git
synced 2025-08-01 17:38:37 +00:00
Display list of feeds per category
This commit is contained in:
parent
15fe9c20df
commit
fad9ad2be4
22 changed files with 345 additions and 141 deletions
52
ui/category_feeds.go
Normal file
52
ui/category_feeds.go
Normal file
|
@ -0,0 +1,52 @@
|
|||
// Copyright 2019 Frédéric Guillot. All rights reserved.
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package ui // import "miniflux.app/ui"
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"miniflux.app/http/request"
|
||||
"miniflux.app/http/response/html"
|
||||
"miniflux.app/ui/session"
|
||||
"miniflux.app/ui/view"
|
||||
)
|
||||
|
||||
func (h *handler) showCategoryFeedsPage(w http.ResponseWriter, r *http.Request) {
|
||||
user, err := h.store.UserByID(request.UserID(r))
|
||||
if err != nil {
|
||||
html.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
categoryID := request.RouteInt64Param(r, "categoryID")
|
||||
category, err := h.store.Category(request.UserID(r), categoryID)
|
||||
if err != nil {
|
||||
html.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
if category == nil {
|
||||
html.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
feeds, err := h.store.FeedsByCategoryWithCounters(user.ID, categoryID)
|
||||
if err != nil {
|
||||
html.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
sess := session.New(h.store, request.SessionID(r))
|
||||
view := view.New(h.tpl, r, sess)
|
||||
view.Set("category", category)
|
||||
view.Set("feeds", feeds)
|
||||
view.Set("total", len(feeds))
|
||||
view.Set("menu", "categories")
|
||||
view.Set("user", user)
|
||||
view.Set("countUnread", h.store.CountUnreadEntries(user.ID))
|
||||
view.Set("countErrorFeeds", h.store.CountErrorFeeds(user.ID))
|
||||
|
||||
html.OK(w, r, view.Render("category_feeds"))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue