summaryrefslogtreecommitdiff
path: root/srv/src/http/drafts.go
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-08-19 21:47:38 -0600
committerBrian Picciano <mediocregopher@gmail.com>2022-08-19 21:47:38 -0600
commitf365b0975778984281b69d66150ee2d026e2613b (patch)
treee16022ab67413f96538cb720065264f73f562cb0 /srv/src/http/drafts.go
parent33a81f73e1ba59e76cf94c4439b80176cbb8261f (diff)
implemented draft publishing and removed New Posts link/capability
Diffstat (limited to 'srv/src/http/drafts.go')
-rw-r--r--srv/src/http/drafts.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/srv/src/http/drafts.go b/srv/src/http/drafts.go
index 8bb08e5..cb776b0 100644
--- a/srv/src/http/drafts.go
+++ b/srv/src/http/drafts.go
@@ -108,3 +108,23 @@ func (a *api) renderDraftPostsIndexHandler() http.Handler {
executeTemplate(rw, r, tpl, tplPayload)
})
}
+
+func (a *api) postDraftPostHandler() http.Handler {
+ return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
+
+ p, err := postFromPostReq(r)
+ if err != nil {
+ apiutil.BadRequest(rw, r, err)
+ return
+ }
+
+ if err := a.params.PostDraftStore.Set(p); err != nil {
+ apiutil.InternalServerError(
+ rw, r, fmt.Errorf("storing post with id %q: %w", p.ID, err),
+ )
+ return
+ }
+
+ a.executeRedirectTpl(rw, r, a.draftURL(p.ID, false)+"?edit")
+ })
+}