From dfa9bcb9e23b10bb28973d1d27f05e04e8638320 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Thu, 18 Aug 2022 22:34:38 -0600 Subject: WIP --- srv/src/http/posts.go | 16 +++++++++------- srv/src/http/tpl/edit-post.html | 4 +++- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'srv/src') diff --git a/srv/src/http/posts.go b/srv/src/http/posts.go index 71f30ab..8484817 100644 --- a/srv/src/http/posts.go +++ b/srv/src/http/posts.go @@ -125,7 +125,7 @@ func (a *api) renderPostHandler() http.Handler { tpl := a.mustParseBasedTpl("post.html") renderPostsIndexHandler := a.renderPostsIndexHandler() - renderEditPostHandler := a.renderEditPostHandler() + renderEditPostHandler := a.renderEditPostHandler(false) return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { @@ -171,7 +171,7 @@ func (a *api) renderPostHandler() http.Handler { func (a *api) renderPostsIndexHandler() http.Handler { - renderEditPostHandler := a.renderEditPostHandler() + renderEditPostHandler := a.renderEditPostHandler(false) tpl := a.mustParseBasedTpl("posts.html") const pageCount = 20 @@ -219,7 +219,7 @@ func (a *api) renderPostsIndexHandler() http.Handler { }) } -func (a *api) renderEditPostHandler() http.Handler { +func (a *api) renderEditPostHandler(isDraft bool) http.Handler { tpl := a.mustParseBasedTpl("edit-post.html") @@ -252,11 +252,13 @@ func (a *api) renderEditPostHandler() http.Handler { } tplPayload := struct { - Post post.StoredPost - Tags []string + Post post.StoredPost + Tags []string + IsDraft bool }{ - Post: storedPost, - Tags: tags, + Post: storedPost, + Tags: tags, + IsDraft: isDraft, } executeTemplate(rw, r, tpl, tplPayload) diff --git a/srv/src/http/tpl/edit-post.html b/srv/src/http/tpl/edit-post.html index 5db0600..a585b82 100644 --- a/srv/src/http/tpl/edit-post.html +++ b/srv/src/http/tpl/edit-post.html @@ -94,7 +94,9 @@ formtarget="_blank" /> - {{ if eq .Payload.Post.ID "" }} + {{ if .Payload.IsDraft }} + + {{ else if eq .Payload.Post.ID "" }} {{ else }} -- cgit v1.2.3