aboutsummaryrefslogtreecommitdiffhomepage
path: root/ui
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2019-11-17 19:44:12 -0800
committerGravatar Frédéric Guillot <fred@miniflux.net>2019-11-17 20:10:44 -0800
commitfad9ad2be4fc800f8710e2a498cc8f536af8827c (patch)
tree8bc4f134b63f100442850bd9eb443f03fffcf7e6 /ui
parent15fe9c20df7eaab4c1e10461f1a9965eeaf85f0f (diff)
Display list of feeds per category
Diffstat (limited to 'ui')
-rw-r--r--ui/category_feeds.go52
-rw-r--r--ui/category_update.go2
-rw-r--r--ui/ui.go1
3 files changed, 54 insertions, 1 deletions
diff --git a/ui/category_feeds.go b/ui/category_feeds.go
new file mode 100644
index 0000000..202fc3e
--- /dev/null
+++ b/ui/category_feeds.go
@@ -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"))
+}
diff --git a/ui/category_update.go b/ui/category_update.go
index 026f991..591063a 100644
--- a/ui/category_update.go
+++ b/ui/category_update.go
@@ -66,5 +66,5 @@ func (h *handler) updateCategory(w http.ResponseWriter, r *http.Request) {
return
}
- html.Redirect(w, r, route.Path(h.router, "categories"))
+ html.Redirect(w, r, route.Path(h.router, "categoryFeeds", "categoryID", categoryID))
}
diff --git a/ui/ui.go b/ui/ui.go
index dd1a9d8..dabc2fc 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -74,6 +74,7 @@ func Serve(router *mux.Router, store *storage.Storage, pool *worker.Pool, feedHa
uiRouter.HandleFunc("/categories", handler.showCategoryListPage).Name("categories").Methods("GET")
uiRouter.HandleFunc("/category/create", handler.showCreateCategoryPage).Name("createCategory").Methods("GET")
uiRouter.HandleFunc("/category/save", handler.saveCategory).Name("saveCategory").Methods("POST")
+ uiRouter.HandleFunc("/category/{categoryID}/feeds", handler.showCategoryFeedsPage).Name("categoryFeeds").Methods("GET")
uiRouter.HandleFunc("/category/{categoryID}/entries", handler.showCategoryEntriesPage).Name("categoryEntries").Methods("GET")
uiRouter.HandleFunc("/category/{categoryID}/entries/all", handler.showCategoryEntriesAllPage).Name("categoryEntriesAll").Methods("GET")
uiRouter.HandleFunc("/category/{categoryID}/edit", handler.showEditCategoryPage).Name("editCategory").Methods("GET")