diff options
Diffstat (limited to 'srv/src/api')
-rw-r--r-- | srv/src/api/render.go | 2 | ||||
-rw-r--r-- | srv/src/api/tpl/index.html | 48 |
2 files changed, 29 insertions, 21 deletions
diff --git a/srv/src/api/render.go b/srv/src/api/render.go index 6359505..cacdb26 100644 --- a/srv/src/api/render.go +++ b/srv/src/api/render.go @@ -42,7 +42,7 @@ func mustParseTpl(name string) *template.Template { func (a *api) renderIndexHandler() http.Handler { tpl := mustParseTpl("index.html") - const pageCount = 20 + const pageCount = 10 return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { diff --git a/srv/src/api/tpl/index.html b/srv/src/api/tpl/index.html index b71dc01..1858ea8 100644 --- a/srv/src/api/tpl/index.html +++ b/srv/src/api/tpl/index.html @@ -1,28 +1,36 @@ {{ define "body" }} -<ul id="posts-list"> - - {{ range .Posts }} - <li> - <h2> - <a href="{{ .HTTPPath }}">{{ .Title }}</a> - </h2> - <span>{{ .PublishedAt.Format "2006-01-02" }}</span> - {{ if not .LastUpdatedAt.IsZero }} - <span>(Updated {{ .LastUpdatedAt.Format "2006-01-02" }})</span> + + <ul id="posts-list"> + + {{ range .Posts }} + <li> + <h2> + <a href="posts/{{ .HTTPPath }}">{{ .Title }}</a> + </h2> + <span>{{ .PublishedAt.Format "2006-01-02" }}</span> + {{ if not .LastUpdatedAt.IsZero }} + <span>(Updated {{ .LastUpdatedAt.Format "2006-01-02" }})</span> + {{ end }} + <p>{{ .Description }}</p> + </li> {{ end }} - <p>{{ .Description }}</p> - </li> - {{ end }} -</ul> -{{ end }} + </ul> -{{ if ge .PrevPage 0 }} -<a href="?p={{ .PrevPage}}">Previous</a> -{{ end }} + {{ if or (ge .PrevPage 0) (ge .NextPage 0) }} + <div id="page-turner"> + + {{ if ge .PrevPage 0 }} + <a style="float: left;" href="?p={{ .PrevPage}}">Newer</a> + {{ end }} + + {{ if ge .NextPage 0 }} + <a style="float:right;" href="?p={{ .NextPage}}">Older</a> + {{ end }} + + </div> + {{ end }} -{{ if ge .NextPage 0 }} -<a href="?p={{ .NextPage}}">Next</a> {{ end }} {{ template "base.html" . }} |