summaryrefslogtreecommitdiff
path: root/srv/src/http/tpl/posts.html
blob: 0609ff639779582c4e03b579d28792a7f30b1648 (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
{{ define "posts-nextprev" }}

  {{ if or (ge .Payload.PrevPage 0) (ge .Payload.NextPage 0) }}
    <div id="page-turner">

    {{ if ge .Payload.PrevPage 0 }}
      <a style="float: left;" href="?p={{ .Payload.PrevPage}}">Newer</a>
    {{ end }}

    {{ if ge .Payload.NextPage 0 }}
      <a style="float:right;" href="?p={{ .Payload.NextPage}}">Older</a>
    {{ end }}

    </div>
  {{ end }}

{{ end }}

{{ define "body" }}

  {{ $csrfFormInput := .CSRFFormInput }}

  <p style="text-align: center;">
    <a href="{{ BlogURL "posts/" }}?edit">
      <button>New Post</button>
    </a>
  </p>

  {{ template "posts-nextprev" . }}

  <table style="margin-top: 2rem;">

    {{ range .Payload.Posts }}
      <tr>
        <td>{{ .PublishedAt }}</td>
        <td><a href="{{ PostURL .ID }}" target="_blank">{{ .Title }}</a></td>
        <td>
          <a href="{{ PostURL .ID }}?edit">
            <button>Edit</button>
          </a>
        </td>
        <td>
          <form
            action="{{ PostURL .ID }}?method=delete"
            method="POST"
            >
            {{ $csrfFormInput }}
            <input type="submit" value="Delete" />
          </form>
        </td>
      </tr>
    {{ end }}

  </table>

  {{ template "posts-nextprev" . }}

  {{ template "load-csrf.html" . }}

{{ end }}

{{ template "base.html" . }}