48 lines
1.6 KiB
HTML
48 lines
1.6 KiB
HTML
{{define "news"}}
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>{{.Title}}</title>
|
|
<link rel="stylesheet" href="{{.StaticPath}}/style.css">
|
|
</head>
|
|
<body>
|
|
{{template "navbar" .}}
|
|
<main>
|
|
<header>
|
|
<h2>News</h2>
|
|
</header>
|
|
<section>
|
|
{{if .News}}
|
|
<ul>
|
|
{{range .News}}
|
|
<li><strong>{{.Title}}</strong> - Posted on {{.CreatedAt.Format "02/01/2006 - 15:04"}}
|
|
<p>{{.Content}}</p>
|
|
{{if $.IsAdmin}}
|
|
<form method="post" action="{{$.BasePath}}/news/?action=delete&id={{.ID}}" style="display:inline;">
|
|
<button type="submit" onclick="return confirm('Are you sure you want to delete this news item?')">Delete</button>
|
|
</form>
|
|
{{end}}
|
|
</li>
|
|
{{end}}
|
|
</ul>
|
|
{{else}}
|
|
<p>No news items available at the moment.</p>
|
|
{{end}}
|
|
</section>
|
|
{{if .IsAdmin}}
|
|
<section>
|
|
<h3>Post New Announcement</h3>
|
|
<form method="post" action="{{.BasePath}}/news/">
|
|
<label for="title">Title:</label>
|
|
<input type="text" id="title" name="title" required><br>
|
|
<label for="content">Content:</label>
|
|
<textarea id="content" name="content" required></textarea><br>
|
|
<input type="submit" value="Post News">
|
|
</form>
|
|
</section>
|
|
{{end}}
|
|
</main>
|
|
{{template "cookie_banner" .}}
|
|
</body>
|
|
</html>
|
|
{{end}} |