nirvash/templates/cms_edit.html

51 lines
1.8 KiB
HTML

{{ $slug := ((.Context).Value "params").Slug }}
{{ $page := ((.Context).Value "adapter").GetPage $slug }}
{{ $editableSlugs := ((.Context).Value "adapter").EditableSlugs }}
{{ $csrfToken := (.Context).Value "csrfToken" }}
{{ $noEmpty := .FormValue "no-empty" }}
{{ template "header" . }}
{{ if ($page).Error }}
<h2>Page Error</h2>
<span class="adapter-error">{{($page).Error}}</span>
{{ else }}
<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}}"/>
<label for="title">Title</label><br/>
<input class="title-input" id="title" type="text" name="title" value="{{($page).Title}}" required/><br/>
{{ if $editableSlugs }}
<label for="slug">Slug</label><br/>
<input class="slug-input" id="slug" type="text" name="slug" value="{{$slug}}" required/><br/>
{{ end }}
<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/>
<a target="_blank" class="fmt-help" href="/fmt-help">Formatting help</a>
<input type="submit" value="Save"/>
</form>
<details class="danger-zone wide"><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>
{{ end }}
{{ template "footer" . }}