summaryrefslogtreecommitdiff
path: root/src/http/index.go
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-11-29 21:32:41 +0100
committerBrian Picciano <mediocregopher@gmail.com>2022-11-29 21:34:55 +0100
commit7943865cc66b80eb54e06ec304bccef0d3a44151 (patch)
treeb0dcfc2104c1f2c689d01ada7115677315f0ba47 /src/http/index.go
parent1f3ae665ed2e58ca572678ce7caf8b711f226392 (diff)
Move mediocregopher.com content to index of this site
Diffstat (limited to 'src/http/index.go')
-rw-r--r--src/http/index.go61
1 files changed, 1 insertions, 60 deletions
diff --git a/src/http/index.go b/src/http/index.go
index a392361..21c6c16 100644
--- a/src/http/index.go
+++ b/src/http/index.go
@@ -1,14 +1,10 @@
package http
import (
- "fmt"
"net/http"
"path/filepath"
"regexp"
"strings"
-
- "github.com/mediocregopher/blog.mediocregopher.com/srv/http/apiutil"
- "github.com/mediocregopher/blog.mediocregopher.com/srv/post"
)
func (a *api) renderIndexHandler() http.Handler {
@@ -35,61 +31,6 @@ func (a *api) renderIndexHandler() http.Handler {
return
}
- page, err := apiutil.StrToInt(r.FormValue("p"), 0)
- if err != nil {
- apiutil.BadRequest(
- rw, r, fmt.Errorf("invalid page number: %w", err),
- )
- return
- }
-
- tag := r.FormValue("tag")
-
- var (
- posts []post.StoredPost
- hasMore bool
- )
-
- if tag == "" {
- posts, hasMore, err = a.params.PostStore.Get(page, pageCount)
- } else {
- posts, err = a.params.PostStore.GetByTag(tag)
- }
-
- if err != nil {
- apiutil.InternalServerError(
- rw, r, fmt.Errorf("fetching page %d of posts: %w", page, err),
- )
- return
- }
-
- tags, err := a.params.PostStore.GetTags()
- if err != nil {
- apiutil.InternalServerError(
- rw, r, fmt.Errorf("fething tags: %w", err),
- )
- return
- }
-
- tplPayload := struct {
- Posts []post.StoredPost
- PrevPage, NextPage int
- Tags []string
- }{
- Posts: posts,
- PrevPage: -1,
- NextPage: -1,
- Tags: tags,
- }
-
- if page > 0 {
- tplPayload.PrevPage = page - 1
- }
-
- if hasMore {
- tplPayload.NextPage = page + 1
- }
-
- executeTemplate(rw, r, tpl, tplPayload)
+ executeTemplate(rw, r, tpl, nil)
})
}