diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2024-05-18 15:55:59 +0200 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2024-05-18 15:55:59 +0200 |
commit | 93a8843e2e3391459fd333aef9e5c7617608c2b3 (patch) | |
tree | 2e5615cd22d1b39c7d5f870b88e3f29b5c24a223 /src/http/tpl/posts-manage.html | |
parent | 8d7e708d98a3a46ba3ba08f9c8deeb4838bb8ca5 (diff) |
Remove most rendering related querying from go http handlers
Diffstat (limited to 'src/http/tpl/posts-manage.html')
-rw-r--r-- | src/http/tpl/posts-manage.html | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/http/tpl/posts-manage.html b/src/http/tpl/posts-manage.html index 96b30ca..f9adbc1 100644 --- a/src/http/tpl/posts-manage.html +++ b/src/http/tpl/posts-manage.html @@ -1,4 +1,8 @@ {{ define "body" }} + + {{ $page := .GetQueryIntValue "p" 0 -}} + {{ $getPostsRes := .GetPosts $page 20 -}} + <script> function confirmDelete(event) { if (!confirm("Are you sure you want to delete this post?")) @@ -12,9 +16,9 @@ <h1>Posts</h1> - {{ if ge .Payload.PrevPage 0 }} + {{ if gt $page 0 }} <p> - <a href="?method=manage&p={{ .Payload.PrevPage}}">< < Previous Page</a> + <a href="?method=manage&p={{ .Add $page -1 }}">< < Previous Page</a> </p> {{ end }} @@ -26,7 +30,7 @@ <col span="1" style="width: auto;"> </colgroup> - {{ range .Payload.Posts }} + {{ range $getPostsRes.Posts }} <tr> <td>{{ .PublishedAt.Local.Format "2006-01-02 15:04:05 MST" }}</td> <td><a href="{{ PostURL .ID }}">{{ .Title }}</a></td> @@ -52,9 +56,9 @@ </table> - {{ if ge .Payload.NextPage 0 }} + {{ if $getPostsRes.HasMore }} <p> - <a href="?method=manage&p={{ .Payload.NextPage}}">Next Page > ></a> + <a href="?method=manage&p={{ .Add $page 1 }}">Next Page > ></a> </p> {{ end }} |