summaryrefslogtreecommitdiff
path: root/src/http/tpl/post-edit.html
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-11-29 20:59:31 +0100
committerBrian Picciano <mediocregopher@gmail.com>2022-11-29 20:59:31 +0100
commit1f3ae665ed2e58ca572678ce7caf8b711f226392 (patch)
treee023602e07e2a80d24ef9d9527ddca0e1640e929 /src/http/tpl/post-edit.html
parent31f8f37c5ad3ad4ac7b3cc93d0257dd80c877c7c (diff)
Introduce EDIT and MANAGE methods
All admin "index" pages are moved under MANAGE, so that we can have (for example) and normal "GET /posts" page later which would replace the current index page, and potentially corresponding pages for the other categories. The EDIT method replaces the old `?edit` pattern, which normalizes how we differentiate page functionality generally.
Diffstat (limited to 'src/http/tpl/post-edit.html')
-rw-r--r--src/http/tpl/post-edit.html142
1 files changed, 142 insertions, 0 deletions
diff --git a/src/http/tpl/post-edit.html b/src/http/tpl/post-edit.html
new file mode 100644
index 0000000..2813754
--- /dev/null
+++ b/src/http/tpl/post-edit.html
@@ -0,0 +1,142 @@
+{{ define "body" }}
+
+<p>
+ {{ if .Payload.IsDraft }}
+ <a href="{{ BlogURL "drafts?method=manage" }}">
+ Back to Drafts
+ </a>
+ {{ else }}
+ <a href="{{ BlogURL "posts?method=manage" }}">
+ Back to Posts
+ </a>
+ {{ end }}
+</p>
+
+<form method="POST" action="{{ BlogURL "posts/" }}">
+
+ <table>
+
+ <tr>
+ <td>
+ Unique ID
+ </td>
+ <td>
+ {{ if eq .Payload.Post.ID "" }}
+ <input
+ name="id"
+ type="text"
+ placeholder="e.g. how-to-fly-a-kite"
+ value="{{ .Payload.Post.ID }}" />
+ {{ else if .Payload.IsDraft }}
+ {{ .Payload.Post.ID }}
+ <input name="id" type="hidden" value="{{ .Payload.Post.ID }}" />
+ {{ else }}
+ <a href="{{ PostURL .Payload.Post.ID }}">{{ .Payload.Post.ID }}</a>
+ <input name="id" type="hidden" value="{{ .Payload.Post.ID }}" />
+ {{ end }}
+ </td>
+ </tr>
+
+ <tr>
+ <td>Tags (space separated)</td>
+ <td>
+ <input
+ name="tags"
+ type="text"
+ value="{{- range $i, $tag := .Payload.Post.Tags -}}
+ {{- if ne $i 0 }} {{ end }}{{ $tag -}}
+ {{- end -}}
+ "/>
+
+ {{ if gt (len .Payload.Tags) 0 }}
+ <em>
+ Existing tags:
+ {{ range $i, $tag := .Payload.Tags }}
+ {{ if ne $i 0 }} {{ end }}{{ $tag }}
+ {{ end }}
+ </em>
+ {{ end }}
+ </td>
+ </tr>
+
+ <tr>
+ <td>Series</td>
+ <td>
+ <input
+ name="series"
+ type="text"
+ value="{{ .Payload.Post.Series }}" />
+ </td>
+ </tr>
+
+ <tr>
+ <td>Title</td>
+ <td>
+ <input
+ name="title"
+ type="text"
+ value="{{ .Payload.Post.Title }}" />
+ </td>
+ </tr>
+
+ <tr>
+ <td>Description</td>
+ <td>
+ <input
+ name="description"
+ type="text"
+ value="{{ .Payload.Post.Description }}" />
+ </td>
+ </tr>
+
+ </table>
+
+ <p>
+ <textarea
+ name="body"
+ placeholder="Blog body"
+ style="width:100%;height: 75vh;"
+ >
+ {{- .Payload.Post.Body -}}
+ </textarea>
+ </p>
+
+ <p>
+
+ <input
+ type="submit"
+ value="Preview"
+ formaction="{{ BlogURL "posts/" }}{{ .Payload.Post.ID }}?method=preview"
+ formtarget="_blank"
+ />
+
+ {{ if .Payload.IsDraft }}
+ <input type="submit" value="Save" formaction="{{ BlogURL "drafts/" }}" />
+
+
+ <script>
+ function confirmPublish(event) {
+ if (!confirm("Are you sure you're ready to publish?"))
+ event.preventDefault();
+ }
+ </script>
+
+
+ <input
+ type="submit"
+ value="Publish"
+ formaction="{{ BlogURL "posts/" }}"
+ onclick="confirmPublish(event)"
+ />
+
+ {{ else }}
+ <input type="submit" value="Update" formaction="{{ BlogURL "posts/" }}" />
+ {{ end }}
+
+ </p>
+
+</form>
+
+{{ end }}
+
+{{ template "base.html" . }}