summaryrefslogtreecommitdiff
path: root/src/http/tpl/posts-manage.html
blob: f9adbc15ac251a62988b404bac05cb468b937652 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{{ define "body" }}

  {{ $page := .GetQueryIntValue "p" 0 -}}
  {{ $getPostsRes := .GetPosts $page 20 -}}

  <script>
    function confirmDelete(event) {
      if (!confirm("Are you sure you want to delete this post?"))
        event.preventDefault();
    }
  </script>

  <p>
    <a href="{{ BlogURL "admin" }}">Back to Admin</a>
  </p>

  <h1>Posts</h1>

  {{ if gt $page 0 }}
  <p>
    <a href="?method=manage&p={{ .Add $page -1 }}">&lt; &lt; Previous Page</a>
  </p>
  {{ end }}

  <table>
    <colgroup>
      <col span="1" style="width: auto;">
      <col span="1" style="width: auto;">
      <col span="1" style="width: 5rem;">
      <col span="1" style="width: auto;">
    </colgroup>

    {{ range $getPostsRes.Posts }}
      <tr>
        <td>{{ .PublishedAt.Local.Format "2006-01-02 15:04:05 MST" }}</td>
        <td><a href="{{ PostURL .ID }}">{{ .Title }}</a></td>
        <td>
          <a href="{{ PostURL .ID }}?method=edit">
            Edit
          </a>
        </td>
        <td>
          <form
            action="{{ PostURL .ID }}?method=delete"
            method="POST"
            >
            <input
              type="submit"
              value="Delete"
              onclick="confirmDelete(event)"
              />
          </form>
        </td>
      </tr>
    {{ end }}

  </table>

  {{ if $getPostsRes.HasMore }}
  <p>
    <a href="?method=manage&p={{ .Add $page 1 }}">Next Page &gt; &gt;</a>
  </p>
  {{ end }}

{{ end }}

{{ template "base.html" . }}