threadr-rewritten/templates/pages/thread.html

57 lines
2.3 KiB
HTML

{{define "thread"}}
<!DOCTYPE html>
<html>
<head>
<title>{{.Title}}</title>
<link rel="stylesheet" href="{{.StaticPath}}/style.css">
</head>
<body>
{{template "navbar" .}}
<main>
<header>
<h2>{{.Thread.Title}}</h2>
</header>
<div class="thread-posts">
{{range .Posts}}
<article id="{{.ID}}" class="post-item" style="margin-left: {{if gt .ReplyTo 0}}20px{{else}}0px{{end}};">
<header>
<h3>{{if .Title}}{{.Title}}{{else}}Post #{{.ID}}{{end}}</h3>
<p>Posted on {{.PostTime.Format "02/01/2006 - 15:04"}}</p>
{{if gt .ReplyTo 0}}
<p>Reply to post <a href="#{{.ReplyTo}}">{{.ReplyTo}}</a></p>
{{end}}
</header>
<div class="post-content">{{.Content}}</div>
{{if $.LoggedIn}}
<div class="post-actions">
<form method="post" action="{{$.BasePath}}/like/" style="display:inline;">
<input type="hidden" name="post_id" value="{{.ID}}">
<input type="hidden" name="type" value="like">
<button type="submit">Like</button>
</form>
<form method="post" action="{{$.BasePath}}/like/" style="display:inline;">
<input type="hidden" name="post_id" value="{{.ID}}">
<input type="hidden" name="type" value="dislike">
<button type="submit">Dislike</button>
</form>
<a href="{{$.BasePath}}/thread/?id={{$.Thread.ID}}&action=submit&to={{.ID}}">Reply</a>
</div>
{{end}}
</article>
{{end}}
</div>
{{if .LoggedIn}}
<section>
<h3>Post a Message</h3>
<form method="post" action="{{.BasePath}}/thread/?id={{.Thread.ID}}&action=submit">
<label for="content">Content:</label>
<textarea id="content" name="content" required></textarea><br>
<input type="submit" value="Post">
</form>
</section>
{{end}}
</main>
{{template "cookie_banner" .}}
</body>
</html>
{{end}}