From 93a8843e2e3391459fd333aef9e5c7617608c2b3 Mon Sep 17 00:00:00 2001
From: Brian Picciano
Date: Sat, 18 May 2024 15:55:59 +0200
Subject: Remove most rendering related querying from go http handlers
---
src/http/tpl/draft-posts-manage.html | 26 ++++++++++++++++++++------
src/http/tpl/post-assets-manage.html | 6 ++++--
src/http/tpl/post-edit.html | 34 +++++++++++++++++++---------------
src/http/tpl/posts-manage.html | 14 +++++++++-----
src/http/tpl/posts.html | 15 +++++++++------
5 files changed, 61 insertions(+), 34 deletions(-)
(limited to 'src/http/tpl')
diff --git a/src/http/tpl/draft-posts-manage.html b/src/http/tpl/draft-posts-manage.html
index 5454f24..b1b4362 100644
--- a/src/http/tpl/draft-posts-manage.html
+++ b/src/http/tpl/draft-posts-manage.html
@@ -1,5 +1,15 @@
{{ define "body" }}
+ {{ $page := .GetQueryIntValue "p" 0 -}}
+ {{ $getPostsRes := .GetDraftPosts $page 20 -}}
+
+
+
Back to Admin
@@ -10,15 +20,15 @@
New Draft
- {{ if ge .Payload.PrevPage 0 }}
+ {{ if gt $page 0 }}
- < < Previous Page
+ < < Previous Page
{{ end }}
- {{ if ge .Payload.NextPage 0 }}
+ {{ if $getPostsRes.HasMore }}
- Next Page > >
+ Next Page > >
{{ end }}
diff --git a/src/http/tpl/post-assets-manage.html b/src/http/tpl/post-assets-manage.html
index f21717a..a0b0da0 100644
--- a/src/http/tpl/post-assets-manage.html
+++ b/src/http/tpl/post-assets-manage.html
@@ -1,5 +1,7 @@
{{ define "body" }}
+{{ $assetIDs := .GetPostAssetIDs }}
+
Back to Admin
@@ -27,13 +29,13 @@
-{{ if gt (len .Payload.IDs) 0 }}
+{{ if $assetIDs }}
Existing Assets
- {{ range .Payload.IDs }}
+ {{ range $assetIDs }}
{{ . }} |
diff --git a/src/http/tpl/post-edit.html b/src/http/tpl/post-edit.html
index c66b60a..28dcd0e 100644
--- a/src/http/tpl/post-edit.html
+++ b/src/http/tpl/post-edit.html
@@ -1,5 +1,9 @@
{{ define "body" }}
+{{ $tags := .GetTags }}
+
+{{ $post := (or (and .Payload.IsDraft .GetThisDraftPost) .GetThisPost) }}
+
{{ if .Payload.IsDraft }}
@@ -21,19 +25,19 @@
Unique ID
|
- {{ if eq .Payload.Post.ID "" }}
+ {{ if eq $post.ID "" }}
+ value="{{ $post.ID }}" />
{{ else if .Payload.IsDraft }}
- {{ .Payload.Post.ID }}
-
+ {{ $post.ID }}
+
{{ else }}
- {{ .Payload.Post.ID }}
-
+ {{ $post.ID }}
+
{{ end }}
|
@@ -45,15 +49,15 @@
name="tags"
type="text"
required
- value="{{- range $i, $tag := .Payload.Post.Tags -}}
+ value="{{- range $i, $tag := $post.Tags -}}
{{- if ne $i 0 }} {{ end }}{{ $tag -}}
{{- end -}}
"/>
- {{ if gt (len .Payload.Tags) 0 }}
+ {{ if $tags }}
Existing tags:
- {{ range $i, $tag := .Payload.Tags }}
+ {{ range $i, $tag := $tags }}
{{ if ne $i 0 }} {{ end }}{{ $tag }}
{{ end }}
@@ -67,7 +71,7 @@
+ value="{{ $post.Series }}" />
@@ -78,7 +82,7 @@
name="title"
type="text"
required
- value="{{ .Payload.Post.Title }}" />
+ value="{{ $post.Title }}" />
@@ -88,7 +92,7 @@
+ value="{{ $post.Description }}" />
@@ -98,7 +102,7 @@