history.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2017 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package controller
  5. import (
  6. "github.com/miniflux/miniflux2/model"
  7. "github.com/miniflux/miniflux2/server/core"
  8. )
  9. func (c *Controller) ShowHistoryPage(ctx *core.Context, request *core.Request, response *core.Response) {
  10. user := ctx.GetLoggedUser()
  11. offset := request.GetQueryIntegerParam("offset", 0)
  12. args, err := c.getCommonTemplateArgs(ctx)
  13. if err != nil {
  14. response.Html().ServerError(err)
  15. return
  16. }
  17. builder := c.store.GetEntryQueryBuilder(user.ID, user.Timezone)
  18. builder.WithStatus(model.EntryStatusRead)
  19. builder.WithOrder(model.DefaultSortingOrder)
  20. builder.WithDirection(model.DefaultSortingDirection)
  21. builder.WithOffset(offset)
  22. builder.WithLimit(NbItemsPerPage)
  23. entries, err := builder.GetEntries()
  24. if err != nil {
  25. response.Html().ServerError(err)
  26. return
  27. }
  28. count, err := builder.CountEntries()
  29. if err != nil {
  30. response.Html().ServerError(err)
  31. return
  32. }
  33. response.Html().Render("history", args.Merge(tplParams{
  34. "entries": entries,
  35. "total": count,
  36. "pagination": c.getPagination(ctx.GetRoute("history"), count, offset),
  37. "menu": "history",
  38. }))
  39. }