From f365b0975778984281b69d66150ee2d026e2613b Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Fri, 19 Aug 2022 21:47:38 -0600 Subject: implemented draft publishing and removed New Posts link/capability --- srv/src/http/drafts.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'srv/src/http/drafts.go') 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") + }) +} -- cgit v1.2.3