nirvash/templates/cms_edit.html

42 lines
1.6 KiB
HTML
Raw Normal View History

2022-06-03 04:56:38 +00:00
{{ $slug := ((.Context).Value "params").Slug }}
{{ $page := ((.Context).Value "adapter").GetPage $slug }}
2022-06-05 04:34:20 +00:00
{{ $editableSlugs := ((.Context).Value "adapter").EditableSlugs }}
{{ $csrfToken := (.Context).Value "csrfToken" }}
{{ $noEmpty := .FormValue "no-empty" }}
2022-06-03 04:56:38 +00:00
{{ template "header" . }}
2022-06-07 06:59:41 +00:00
<h2>Edit Page</h2>
<form class="editor" method="POST" action="/save/{{$slug}}">
{{ if $noEmpty }}
<span class="edit-error">Empty fields are not allowed - please try again</span><br/>
{{ end }}
<input hidden name="csrfToken" value="{{$csrfToken}}"/>
<input hidden name="oldSlug" value="{{$slug}}"/>
2022-06-05 04:34:20 +00:00
{{ if $editableSlugs }}
2022-06-07 06:59:41 +00:00
<label for="slug">Slug</label><br/>
<input class="slug-input" id="slug" type="text" name="slug" value="{{$slug}}" required/><br/>
2022-06-05 04:34:20 +00:00
{{ end }}
2022-06-07 06:59:41 +00:00
<label for="title">Title</label><br/>
<input class="title-input" id="title" type="text" name="title" value="{{($page).Title}}" required/><br/>
<span class="edited-time">last edited {{($page).Edited.Format "2006-01-02 15:04"}}</span><br/>
<label for="content">Content</label><br/>
<textarea class="content-input" id="content" name="content" required>{{($page).Content}}</textarea><br/>
2022-06-05 04:34:20 +00:00
<input type="submit" value="Save"/>
2022-06-03 04:56:38 +00:00
</form>
2022-06-07 06:59:41 +00:00
<details class="danger-zone"><summary>Danger Zone</summary>
<form class="eraser" method="POST" action="/delete/{{$slug}}">
<input hidden name="csrfToken" value="{{$csrfToken}}"/>
<label>I want to delete this page
<input type="checkbox" required/>
</label><br/>
<label>Yes, I'm sure
<input type="checkbox" required/>
</label><br/>
<input type="submit" value="DELETE"/>
</form>
</details>
{{ template "footer" . }}