Refactor: Recover middleware now uses RenderError + add full notifications view

- Replaced http.Error with helpers.RenderError in Recover middleware
- Custom 500.html now rendered with layout and topbar on panic
- RenderError gracefully checks template existence and falls back to plain response
- Added /account/notifications full view page (index)
- Linked "Back to notifications" from notification read view
- Fixed typo in template path for notifications/index.html
- Improved layout consistency across error and account pages
This commit is contained in:
2025-04-02 09:54:20 +01:00
parent 2498b33a9c
commit ab1d9abc72
6 changed files with 49 additions and 22 deletions

View File

@@ -1,23 +1,29 @@
{{ define "notifications" }}
{{ define "content" }}
<div class="container py-4">
<h2 class="mb-4">Notifications</h2>
<h2 class="mb-4">Your Notifications</h2>
{{ if .Notifications }}
<ul class="list-group">
{{ range .Notifications }}
<li class="list-group-item d-flex justify-content-between align-items-start {{ if not .IsRead }}fw-bold{{ end }}">
<div class="ms-2 me-auto">
<div class="fw-semibold">{{ .Title }}</div>
<small class="text-muted">{{ .Message }}</small>
</div>
{{ if not .IsRead }}
<a href="/account/notifications/read?id={{ .ID }}" class="badge bg-primary text-decoration-none">Mark as read</a>
<ul class="list-group">
{{ range .Notifications }}
<li class="list-group-item d-flex justify-content-between align-items-start {{ if not .IsRead }}bg-light{{ end }}">
<div class="ms-2 me-auto">
<div class="fw-bold">
<a href="/account/notifications/read?id={{ .ID }}" class="{{ if not .IsRead }}text-primary fw-bold{{ end }}">
{{ .Subject }}
</a>
</div>
<small class="text-muted">{{ .CreatedAt.Format "Jan 2, 2006 15:04" }}</small>
</div>
{{ if not .IsRead }}
<span class="badge bg-warning text-dark">New</span>
{{ end }}
</li>
{{ end }}
</li>
{{ end }}
</ul>
</ul>
{{ else }}
<div class="alert alert-info">You have no notifications.</div>
<div class="alert alert-info text-center">
You dont have any notifications.
</div>
{{ end }}
</div>
{{ end }}