| 1 | {{define "admin_post_form.html"}}{{template "admin_base.html" .}}{{end}} |
| 2 | {{define "title"}}Admin — {{if .Post}}Edit Post{{else}}New Post{{end}}{{end}} |
| 3 | {{define "content"}} |
| 4 | <h2>{{if .Post}}Edit Post{{else}}New Post{{end}}</h2> |
| 5 | {{if .Error}}<p class="error">{{.Error}}</p>{{end}} |
| 6 | {{$p := .Post}} |
| 7 | {{if $p}} |
| 8 | <form method="POST" action="/admin/posts/{{$p.ShortID}}" class="form post-form"> |
| 9 | <textarea name="attributes" class="attributes-textarea">title: {{$p.TitleStr}} |
| 10 | slug: {{$p.Slug}} |
| 11 | {{if $p.PublishedDate}}published_date: {{$p.PublishedDateStr}} |
| 12 | {{end}}{{if ne $p.Lang "en"}}lang: {{$p.Lang}} |
| 13 | {{end}}{{if $p.Tags}}tags: {{$p.TagsStr}} |
| 14 | {{end}}{{if $p.Alias}}alias: {{$p.AliasStr}} |
| 15 | {{end}}{{if $p.MetaImage}}meta_image: {{$p.MetaImageStr}} |
| 16 | {{end}}{{if $p.MetaDescription}}description: {{$p.MetaDescriptionStr}} |
| 17 | {{end}}{{if $p.Weather}}weather: {{$p.Weather}}{{end}}</textarea> |
| 18 | <details class="available-fields"> |
| 19 | <summary>available fields</summary> |
| 20 | <div class="fields-list"> |
| 21 | <span>title: My Post Title</span> |
| 22 | <span>slug: my-post-title</span> |
| 23 | <span>published_date: 2025-01-15T14:30:00Z</span> |
| 24 | <span>lang: en</span> |
| 25 | <span>tags: rust, web, tutorial</span> |
| 26 | <span>alias: /old/path</span> |
| 27 | <span>meta_image: https://example.com/image.jpg</span> |
| 28 | <span>description: A short summary of the post</span> |
| 29 | <span>weather: Conditions,Degrees,City,State<span> |
| 30 | </div> |
| 31 | </details> |
| 32 | <label for="content">content</label> |
| 33 | <textarea id="content" name="content" class="post-content">{{$p.Content}}</textarea> |
| 34 | <div class="form-actions"> |
| 35 | {{if eq $p.Status "published"}} |
| 36 | <button type="submit" name="action" value="publish">update</button> |
| 37 | <button type="submit" name="action" value="draft">unpublish</button> |
| 38 | {{else}} |
| 39 | <button type="submit" name="action" value="draft">save draft</button> |
| 40 | <button type="submit" name="action" value="publish">publish</button> |
| 41 | {{end}} |
| 42 | </div> |
| 43 | </form> |
| 44 | {{else}} |
| 45 | <form method="POST" action="/admin/posts" class="form post-form"> |
| 46 | <textarea name="attributes" class="attributes-textarea">title: </textarea> |
| 47 | <details class="available-fields"> |
| 48 | <summary>available fields</summary> |
| 49 | <div class="fields-list"> |
| 50 | <span>title: My Post Title</span> |
| 51 | <span>slug: my-post-title</span> |
| 52 | <span>published_date: 2025-01-15T14:30:00Z</span> |
| 53 | <span>lang: en</span> |
| 54 | <span>tags: rust, web, tutorial</span> |
| 55 | <span>alias: /old/path</span> |
| 56 | <span>meta_image: https://example.com/image.jpg</span> |
| 57 | <span>description: A short summary of the post</span> |
| 58 | <span>weather: Conditions,Degrees,City,State<span> |
| 59 | </div> |
| 60 | </details> |
| 61 | <label for="content">content</label> |
| 62 | <textarea id="content" name="content" class="post-content" placeholder="write markdown here..."></textarea> |
| 63 | <div class="form-actions"> |
| 64 | <button type="submit" name="action" value="draft">save draft</button> |
| 65 | <button type="submit" name="action" value="publish">publish</button> |
| 66 | </div> |
| 67 | </form> |
| 68 | {{end}} |
| 69 | {{end}} |