mirror of
https://github.com/miniflux/v2.git
synced 2025-07-22 17:18:37 +00:00
Use vanilla HTTP handlers (refactoring)
This commit is contained in:
parent
1eba1730d1
commit
f49b42f70f
121 changed files with 4339 additions and 3369 deletions
36
ui/entry_prev_next.go
Normal file
36
ui/entry_prev_next.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Copyright 2017 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 (
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/storage"
|
||||
)
|
||||
|
||||
func (c *Controller) getEntryPrevNext(user *model.User, builder *storage.EntryQueryBuilder, entryID int64) (prev *model.Entry, next *model.Entry, err error) {
|
||||
builder.WithoutStatus(model.EntryStatusRemoved)
|
||||
builder.WithOrder(model.DefaultSortingOrder)
|
||||
builder.WithDirection(user.EntryDirection)
|
||||
|
||||
entries, err := builder.GetEntries()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
n := len(entries)
|
||||
for i := 0; i < n; i++ {
|
||||
if entries[i].ID == entryID {
|
||||
if i-1 >= 0 {
|
||||
prev = entries[i-1]
|
||||
}
|
||||
|
||||
if i+1 < n {
|
||||
next = entries[i+1]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return prev, next, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue