Add queryparam toggle for inactive items
This commit is contained in:
parent
6c2de8880a
commit
60afdd2a32
@ -4,7 +4,7 @@
|
||||
<article class="center">
|
||||
<span class="item-title">
|
||||
<a href="/">Home</a>
|
||||
[<a href="#">Active</a> | <a href="#">All</a>]
|
||||
[<a href="?inactive=0">Active</a> | <a href="?inactive=1">All</a>]
|
||||
</span>
|
||||
</article>
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/Jaculabilis/intake/core"
|
||||
@ -15,11 +16,20 @@ func (env *Env) getSource(writer http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
|
||||
// TODO this needs to properly error if the source doesn't exist instead of just returning []
|
||||
items, err := core.GetAllItemsForSource(env.db, source)
|
||||
var items []core.Item
|
||||
var err error
|
||||
inactive := req.URL.Query().Get("inactive") == "1"
|
||||
log.Printf("inactive = %t", inactive)
|
||||
if inactive {
|
||||
items, err = core.GetAllItemsForSource(env.db, source)
|
||||
} else {
|
||||
items, err = core.GetActiveItemsForSource(env.db, source)
|
||||
}
|
||||
if err != nil {
|
||||
http.Error(writer, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
|
||||
data := html.FeedData{
|
||||
Items: items,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user