2023-06-19 23:42:47 +02:00
|
|
|
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2018-12-14 09:54:25 +01:00
|
|
|
|
2023-08-10 06:15:55 +02:00
|
|
|
package ui // import "miniflux.app/v2/ui"
|
2018-12-14 09:54:25 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2023-08-10 06:15:55 +02:00
|
|
|
"miniflux.app/v2/http/request"
|
|
|
|
"miniflux.app/v2/http/response/html"
|
|
|
|
"miniflux.app/v2/http/route"
|
|
|
|
"miniflux.app/v2/model"
|
|
|
|
"miniflux.app/v2/ui/session"
|
|
|
|
"miniflux.app/v2/ui/view"
|
2018-12-14 09:54:25 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func (h *handler) showCategoryEntriesAllPage(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
|
|
|
|
}
|
|
|
|
|
|
|
|
offset := request.QueryIntParam(r, "offset", 0)
|
|
|
|
builder := h.store.NewEntryQueryBuilder(user.ID)
|
|
|
|
builder.WithCategoryID(category.ID)
|
2023-06-19 23:00:10 +02:00
|
|
|
builder.WithSorting(user.EntryOrder, user.EntryDirection)
|
2018-12-14 09:54:25 +01:00
|
|
|
builder.WithoutStatus(model.EntryStatusRemoved)
|
|
|
|
builder.WithOffset(offset)
|
2020-07-09 01:24:54 +02:00
|
|
|
builder.WithLimit(user.EntriesPerPage)
|
2018-12-14 09:54:25 +01:00
|
|
|
|
|
|
|
entries, err := builder.GetEntries()
|
|
|
|
if err != nil {
|
|
|
|
html.ServerError(w, r, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
count, err := builder.CountEntries()
|
|
|
|
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("total", count)
|
|
|
|
view.Set("entries", entries)
|
2020-07-09 01:24:54 +02:00
|
|
|
view.Set("pagination", getPagination(route.Path(h.router, "categoryEntriesAll", "categoryID", category.ID), count, offset, user.EntriesPerPage))
|
2018-12-14 09:54:25 +01:00
|
|
|
view.Set("menu", "categories")
|
|
|
|
view.Set("user", user)
|
|
|
|
view.Set("countUnread", h.store.CountUnreadEntries(user.ID))
|
2020-09-28 01:01:06 +02:00
|
|
|
view.Set("countErrorFeeds", h.store.CountUserFeedsWithErrors(user.ID))
|
2018-12-14 09:54:25 +01:00
|
|
|
view.Set("hasSaveEntry", h.store.HasSaveEntry(user.ID))
|
|
|
|
view.Set("showOnlyUnreadEntries", false)
|
|
|
|
|
|
|
|
html.OK(w, r, view.Render("category_entries"))
|
|
|
|
}
|