diff --git a/README.md b/README.md index 64d0c1e..9a0b0cb 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ Instead, the web interface can be locked behind a password set via `intake passw Parity features * [x] web feed supports item TTS -* [ ] item punt +* [x] item punt * [ ] web feed paging * [ ] web fetch * [ ] set a working directory for item actions diff --git a/web/html/item.html b/web/html/item.html index 248339b..193401e 100644 --- a/web/html/item.html +++ b/web/html/item.html @@ -9,6 +9,10 @@ {{- if .Link }} {{ end -}} diff --git a/web/item.go b/web/item.go index 82cbd7f..ccd7b2e 100644 --- a/web/item.go +++ b/web/item.go @@ -40,6 +40,30 @@ func (env *Env) deleteItem(writer http.ResponseWriter, req *http.Request) { html.Item(writer, html.ItemData{Item: item}) } +func (env *Env) puntItem(writer http.ResponseWriter, req *http.Request) { + source := req.PathValue("source") + id := req.PathValue("id") + + item, err := core.GetItem(env.db, source, id) + if err != nil { + http.Error(writer, err.Error(), 500) + return + } + + now := time.Now() + tomorrow := now.Add(time.Hour * 60) + morning := time.Date(tomorrow.Year(), tomorrow.Month(), tomorrow.Day(), 6, 0, 0, 0, time.UTC) + til_then := int(morning.Unix()) - item.Created + item.Tts = til_then + + if err := core.UpdateItems(env.db, []core.Item{item}); err != nil { + http.Error(writer, err.Error(), 500) + return + } + + html.Item(writer, html.ItemData{Item: item}) +} + func (env *Env) doAction(writer http.ResponseWriter, req *http.Request) { source := req.PathValue("source") id := req.PathValue("id") diff --git a/web/main.go b/web/main.go index 637f025..bf058f8 100644 --- a/web/main.go +++ b/web/main.go @@ -43,6 +43,7 @@ func RunServer(db core.DB, addr string, port string) { handleFunc("GET /item/{source}/{id}", env.getItem, env.authed, logged) handleFunc("DELETE /item/{source}/{id}", env.deleteItem, env.authed, logged) handleFunc("POST /item/{source}/{id}/action/{action}", env.doAction, env.authed, logged) + handleFunc("PATCH /item/{source}/{id}/punt", env.puntItem, env.authed, logged) handleFunc("POST /mass-deactivate", env.massDeactivate, env.authed, logged) log.Fatal(http.ListenAndServe(bind, nil))