Add queryparam toggle for inactive items

This commit is contained in:
Tim Van Baak 2025-01-30 17:20:29 -08:00
parent 6c2de8880a
commit 60afdd2a32
2 changed files with 12 additions and 2 deletions

View File

@ -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>

View File

@ -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,
}