WIP
This commit is contained in:
parent
7ac2f5ebb3
commit
dfa9bcb9e2
@ -125,7 +125,7 @@ func (a *api) renderPostHandler() http.Handler {
|
|||||||
|
|
||||||
tpl := a.mustParseBasedTpl("post.html")
|
tpl := a.mustParseBasedTpl("post.html")
|
||||||
renderPostsIndexHandler := a.renderPostsIndexHandler()
|
renderPostsIndexHandler := a.renderPostsIndexHandler()
|
||||||
renderEditPostHandler := a.renderEditPostHandler()
|
renderEditPostHandler := a.renderEditPostHandler(false)
|
||||||
|
|
||||||
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
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 {
|
func (a *api) renderPostsIndexHandler() http.Handler {
|
||||||
|
|
||||||
renderEditPostHandler := a.renderEditPostHandler()
|
renderEditPostHandler := a.renderEditPostHandler(false)
|
||||||
tpl := a.mustParseBasedTpl("posts.html")
|
tpl := a.mustParseBasedTpl("posts.html")
|
||||||
const pageCount = 20
|
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")
|
tpl := a.mustParseBasedTpl("edit-post.html")
|
||||||
|
|
||||||
@ -254,9 +254,11 @@ func (a *api) renderEditPostHandler() http.Handler {
|
|||||||
tplPayload := struct {
|
tplPayload := struct {
|
||||||
Post post.StoredPost
|
Post post.StoredPost
|
||||||
Tags []string
|
Tags []string
|
||||||
|
IsDraft bool
|
||||||
}{
|
}{
|
||||||
Post: storedPost,
|
Post: storedPost,
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
|
IsDraft: isDraft,
|
||||||
}
|
}
|
||||||
|
|
||||||
executeTemplate(rw, r, tpl, tplPayload)
|
executeTemplate(rw, r, tpl, tplPayload)
|
||||||
|
@ -94,7 +94,9 @@
|
|||||||
formtarget="_blank"
|
formtarget="_blank"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{{ if eq .Payload.Post.ID "" }}
|
{{ if .Payload.IsDraft }}
|
||||||
|
<input type="submit" value="Save" formaction="{{ BlogURL "drafts/" }}" />
|
||||||
|
{{ else if eq .Payload.Post.ID "" }}
|
||||||
<input type="submit" value="Publish" formaction="{{ BlogURL "posts/" }}" />
|
<input type="submit" value="Publish" formaction="{{ BlogURL "posts/" }}" />
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<input type="submit" value="Update" formaction="{{ BlogURL "posts/" }}" />
|
<input type="submit" value="Update" formaction="{{ BlogURL "posts/" }}" />
|
||||||
|
Loading…
Reference in New Issue
Block a user