mirror of
https://github.com/miniflux/v2.git
synced 2025-08-06 17:41:00 +00:00
Move UI middlewares and routes to ui package
This commit is contained in:
parent
0925899cee
commit
5a69a61d48
70 changed files with 739 additions and 769 deletions
|
@ -16,16 +16,15 @@ import (
|
|||
"miniflux.app/ui/view"
|
||||
)
|
||||
|
||||
// ShowReadEntry shows a single feed entry in "history" mode.
|
||||
func (c *Controller) ShowReadEntry(w http.ResponseWriter, r *http.Request) {
|
||||
user, err := c.store.UserByID(request.UserID(r))
|
||||
func (h *handler) showReadEntryPage(w http.ResponseWriter, r *http.Request) {
|
||||
user, err := h.store.UserByID(request.UserID(r))
|
||||
if err != nil {
|
||||
html.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
entryID := request.RouteInt64Param(r, "entryID")
|
||||
builder := c.store.NewEntryQueryBuilder(user.ID)
|
||||
builder := h.store.NewEntryQueryBuilder(user.ID)
|
||||
builder.WithEntryID(entryID)
|
||||
builder.WithoutStatus(model.EntryStatusRemoved)
|
||||
|
||||
|
@ -40,7 +39,7 @@ func (c *Controller) ShowReadEntry(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
entryPaginationBuilder := storage.NewEntryPaginationBuilder(c.store, user.ID, entry.ID, user.EntryDirection)
|
||||
entryPaginationBuilder := storage.NewEntryPaginationBuilder(h.store, user.ID, entry.ID, user.EntryDirection)
|
||||
entryPaginationBuilder.WithStatus(model.EntryStatusRead)
|
||||
prevEntry, nextEntry, err := entryPaginationBuilder.Entries()
|
||||
if err != nil {
|
||||
|
@ -50,16 +49,16 @@ func (c *Controller) ShowReadEntry(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
nextEntryRoute := ""
|
||||
if nextEntry != nil {
|
||||
nextEntryRoute = route.Path(c.router, "readEntry", "entryID", nextEntry.ID)
|
||||
nextEntryRoute = route.Path(h.router, "readEntry", "entryID", nextEntry.ID)
|
||||
}
|
||||
|
||||
prevEntryRoute := ""
|
||||
if prevEntry != nil {
|
||||
prevEntryRoute = route.Path(c.router, "readEntry", "entryID", prevEntry.ID)
|
||||
prevEntryRoute = route.Path(h.router, "readEntry", "entryID", prevEntry.ID)
|
||||
}
|
||||
|
||||
sess := session.New(c.store, request.SessionID(r))
|
||||
view := view.New(c.tpl, r, sess)
|
||||
sess := session.New(h.store, request.SessionID(r))
|
||||
view := view.New(h.tpl, r, sess)
|
||||
view.Set("entry", entry)
|
||||
view.Set("prevEntry", prevEntry)
|
||||
view.Set("nextEntry", nextEntry)
|
||||
|
@ -67,9 +66,9 @@ func (c *Controller) ShowReadEntry(w http.ResponseWriter, r *http.Request) {
|
|||
view.Set("prevEntryRoute", prevEntryRoute)
|
||||
view.Set("menu", "history")
|
||||
view.Set("user", user)
|
||||
view.Set("countUnread", c.store.CountUnreadEntries(user.ID))
|
||||
view.Set("countErrorFeeds", c.store.CountErrorFeeds(user.ID))
|
||||
view.Set("hasSaveEntry", c.store.HasSaveEntry(user.ID))
|
||||
view.Set("countUnread", h.store.CountUnreadEntries(user.ID))
|
||||
view.Set("countErrorFeeds", h.store.CountErrorFeeds(user.ID))
|
||||
view.Set("hasSaveEntry", h.store.HasSaveEntry(user.ID))
|
||||
|
||||
html.OK(w, r, view.Render("entry"))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue