Add queryparam toggle for inactive items
This commit is contained in:
parent
6c2de8880a
commit
60afdd2a32
@ -4,7 +4,7 @@
|
|||||||
<article class="center">
|
<article class="center">
|
||||||
<span class="item-title">
|
<span class="item-title">
|
||||||
<a href="/">Home</a>
|
<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>
|
</span>
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/Jaculabilis/intake/core"
|
"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 []
|
// 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 {
|
if err != nil {
|
||||||
http.Error(writer, err.Error(), 500)
|
http.Error(writer, err.Error(), 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data := html.FeedData{
|
data := html.FeedData{
|
||||||
Items: items,
|
Items: items,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user