mediocre-blog/srv/src/http/tpl/edit-post.html

116 lines
2.3 KiB
HTML

{{ define "body" }}
{{ if gt (len .Payload.Tags) 0 }}
<p>
Existing tags:
<em>
{{ range $i, $tag := .Payload.Tags }}
{{ if ne $i 0 }} {{ end }}{{ $tag }}
{{ end }}
</em>
</p>
{{ end }}
<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 }}
<a href="{{ PostURL .Payload.Post.ID }}" target="_blank">{{ .Payload.Post.ID }}</a>
<input name="id" type="hidden" value="{{ .Payload.Post.ID }}" />
{{ end }}
</td>
</tr>
<tr>
<td>
<p>Tags (space separated)</p>
</td>
<td>
<input
name="tags"
type="text"
value="{{- range $i, $tag := .Payload.Post.Tags -}}
{{- if ne $i 0 }} {{ end }}{{ $tag -}}
{{- 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 eq .Payload.Post.ID "" }}
<input type="submit" value="Publish" formaction="{{ BlogURL "posts/" }}" />
{{ else }}
<input type="submit" value="Update" formaction="{{ BlogURL "posts/" }}" />
{{ end }}
<a href="{{ BlogURL "posts/" }}">
<button type="button">Back</button>
</a>
</p>
</form>
{{ end }}
{{ template "base.html" . }}