summaryrefslogtreecommitdiff
path: root/src/http/drafts.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/drafts.go')
-rw-r--r--src/http/drafts.go40
1 files changed, 1 insertions, 39 deletions
diff --git a/src/http/drafts.go b/src/http/drafts.go
index b0550ce..8f17eec 100644
--- a/src/http/drafts.go
+++ b/src/http/drafts.go
@@ -5,50 +5,12 @@ import (
"net/http"
"dev.mediocregopher.com/mediocre-blog.git/src/http/apiutil"
- "dev.mediocregopher.com/mediocre-blog.git/src/post"
)
func (a *api) manageDraftPostsHandler() http.Handler {
-
tpl := a.mustParseBasedTpl("draft-posts-manage.html")
- const pageCount = 20
-
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
-
- page, err := apiutil.StrToInt(r.FormValue("p"), 0)
- if err != nil {
- apiutil.BadRequest(
- rw, r, fmt.Errorf("invalid page number: %w", err),
- )
- return
- }
-
- posts, hasMore, err := a.params.PostDraftStore.Get(page, pageCount)
- if err != nil {
- apiutil.InternalServerError(
- rw, r, fmt.Errorf("fetching page %d of posts: %w", page, err),
- )
- return
- }
-
- tplPayload := struct {
- Posts []post.Post
- PrevPage, NextPage int
- }{
- Posts: posts,
- PrevPage: -1,
- NextPage: -1,
- }
-
- if page > 0 {
- tplPayload.PrevPage = page - 1
- }
-
- if hasMore {
- tplPayload.NextPage = page + 1
- }
-
- a.executeTemplate(rw, r, tpl, tplPayload)
+ a.executeTemplate(rw, r, tpl, nil)
})
}