|
|
|
@ -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) |
|
|
|
|