diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2022-05-20 08:36:52 -0600 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2022-05-20 08:42:54 -0600 |
commit | 1242be7cfec1faa6a880d625307e32a1a91937ac (patch) | |
tree | c0dc03c6d384b7e6757eb6076d9208c7c038cb3f /srv/src/api/tpl | |
parent | 5a997781871db4c1f504e2f59e14541bb1e62dcb (diff) |
Implement posts index page
Diffstat (limited to 'srv/src/api/tpl')
-rw-r--r-- | srv/src/api/tpl/assets.html | 2 | ||||
-rw-r--r-- | srv/src/api/tpl/index.html | 2 | ||||
-rw-r--r-- | srv/src/api/tpl/post.html | 8 | ||||
-rw-r--r-- | srv/src/api/tpl/posts.html | 61 |
4 files changed, 67 insertions, 6 deletions
diff --git a/srv/src/api/tpl/assets.html b/srv/src/api/tpl/assets.html index b8d51a2..aa5e422 100644 --- a/srv/src/api/tpl/assets.html +++ b/srv/src/api/tpl/assets.html @@ -33,7 +33,7 @@ <td><a href="{{ AssetURL . }}" target="_blank">{{ . }}</a></td> <td> <form - action="{{ BlogURL "assets/" }}{{ . }}?method=delete" + action="{{ AssetURL . }}?method=delete" method="POST" style="margin-bottom: 0;" > diff --git a/srv/src/api/tpl/index.html b/srv/src/api/tpl/index.html index b634169..946a3e4 100644 --- a/srv/src/api/tpl/index.html +++ b/srv/src/api/tpl/index.html @@ -5,7 +5,7 @@ {{ range .Payload.Posts }} <li> <h2> - <a href="posts/{{ .HTTPPath }}">{{ .Title }}</a> + <a href="{{ PostURL .ID }}">{{ .Title }}</a> </h2> <span>{{ .PublishedAt.Format "2006-01-02" }}</span> {{ if not .LastUpdatedAt.IsZero }} diff --git a/srv/src/api/tpl/post.html b/srv/src/api/tpl/post.html index c5c3c96..fadab3c 100644 --- a/srv/src/api/tpl/post.html +++ b/srv/src/api/tpl/post.html @@ -19,10 +19,10 @@ <p class="light"><em> This post is part of a series:<br/> {{ if .Payload.SeriesPrevious }} - Previously: <a href="{{ .Payload.SeriesPrevious.HTTPPath }}">{{ .Payload.SeriesPrevious.Title }}</a></br> + Previously: <a href="{{ PostURL .Payload.SeriesPrevious.ID }}">{{ .Payload.SeriesPrevious.Title }}</a></br> {{ end }} {{ if .Payload.SeriesNext }} - Next: <a href="{{ .Payload.SeriesNext.HTTPPath }}">{{ .Payload.SeriesNext.Title }}</a></br> + Next: <a href="{{ PostURL .Payload.SeriesNext.ID }}">{{ .Payload.SeriesNext.Title }}</a></br> {{ end }} </em></p> {{ end }} @@ -35,10 +35,10 @@ <p class="light"><em> If you liked this post, consider checking out other posts in the series:<br/> {{ if .Payload.SeriesPrevious }} - Previously: <a href="{{ .Payload.SeriesPrevious.HTTPPath }}">{{ .Payload.SeriesPrevious.Title }}</a></br> + Previously: <a href="{{ PostURL .Payload.SeriesPrevious.ID }}">{{ .Payload.SeriesPrevious.Title }}</a></br> {{ end }} {{ if .Payload.SeriesNext }} - Next: <a href="{{ .Payload.SeriesNext.HTTPPath }}">{{ .Payload.SeriesNext.Title }}</a></br> + Next: <a href="{{ PostURL .Payload.SeriesNext.ID }}">{{ .Payload.SeriesNext.Title }}</a></br> {{ end }} </em></p> {{ end }} diff --git a/srv/src/api/tpl/posts.html b/srv/src/api/tpl/posts.html new file mode 100644 index 0000000..e701f59 --- /dev/null +++ b/srv/src/api/tpl/posts.html @@ -0,0 +1,61 @@ +{{ 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/" }}?method=new"> + <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 }}?method=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" . }} + +{{ end }} + +{{ template "base.html" . }} |