- Comment model with nested replies (ParentID), dual authorship (logged-in UserID / anonymous GuestToken cookie), email hash for Gravatar, private flag, and moderation status - CommentConfig singleton (enabled / allow guest / guest-require-approval / use Gravatar) cached like the other platform config - Markdown comments with built-in emoji picker, preview, and markdown help; rendered client-side via marked + DOMPurify, with server-side HTML/dangerous-scheme stripping as a first XSS defense - Private comments visible only to admin and the author; pending comments visible only to admin and the author - Admin moderation list (pending/approved/rejected/all tabs) with approve/reject/delete and a pending-count badge - Comment settings page with the four toggles - One-time session flash notice (auto-dismissed after 4s) so the "comment posted" banner no longer persists across refreshes Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
112 lines
5.9 KiB
HTML
112 lines
5.9 KiB
HTML
{{define "header"}}
|
|
<!DOCTYPE html>
|
|
<html lang="{{.Lang}}">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>{{.Title}} - {{index .Tr "site_title"}}</title>
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.6.2/cropper.min.css">
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.6.2/cropper.min.js"></script>
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.css">
|
|
<script src="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js"></script>
|
|
</head>
|
|
<body class="bg-gray-50 min-h-screen flex flex-col">
|
|
<!-- Navigation -->
|
|
<nav class="bg-white shadow-sm border-b border-gray-200">
|
|
<div class="max-w-5xl mx-auto px-4 py-3 flex items-center justify-between">
|
|
<a href="/" class="text-xl font-bold text-gray-800 hover:text-blue-600 transition-colors flex items-center gap-2">
|
|
{{if .SiteLogo}}
|
|
{{if .SiteLogoIsURL}}
|
|
<img src="{{.SiteLogo}}" alt="logo" class="h-8 w-auto">
|
|
{{else}}
|
|
<img src="/uploads/logos/{{.SiteLogo}}" alt="logo" class="h-8 w-auto">
|
|
{{end}}
|
|
{{end}}
|
|
{{if .SiteLogoText}}{{.SiteLogoText}}{{else}}{{index .Tr "site_title"}}{{end}}
|
|
</a>
|
|
<div class="flex items-center gap-4">
|
|
<a href="/" class="text-gray-600 hover:text-blue-600 transition-colors">{{index .Tr "home"}}</a>
|
|
{{if .IsLoggedIn}}
|
|
<!-- Avatar Dropdown (click to toggle) -->
|
|
<div class="relative" id="avatarDropdown">
|
|
<button type="button" id="avatarBtn" class="w-9 h-9 rounded-full overflow-hidden border-2 border-gray-300 hover:border-blue-500 transition-colors flex items-center justify-center bg-gray-200 text-gray-600 font-bold text-sm cursor-pointer" onclick="toggleDropdown()">
|
|
{{if .Avatar}}
|
|
<img src="/uploads/avatars/{{.Avatar}}" alt="avatar" class="w-full h-full object-cover">
|
|
{{else}}
|
|
<svg class="w-5 h-5 text-gray-500 pointer-events-none" fill="currentColor" viewBox="0 0 24 24">
|
|
<path d="M12 12c2.7 0 4.8-2.1 4.8-4.8S14.7 2.4 12 2.4 7.2 4.5 7.2 7.2 9.3 12 12 12zm0 2.4c-3.2 0-9.6 1.6-9.6 4.8v1.2c0 .66.54 1.2 1.2 1.2h16.8c.66 0 1.2-.54 1.2-1.2v-1.2c0-3.2-6.4-4.8-9.6-4.8z"/>
|
|
</svg>
|
|
{{end}}
|
|
</button>
|
|
<div id="dropdownMenu" class="absolute right-0 mt-2 w-44 bg-white rounded-lg shadow-lg border border-gray-200 py-1 z-50 hidden">
|
|
<a href="/profile" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 transition-colors">
|
|
{{index .Tr "profile"}}
|
|
</a>
|
|
{{if eq .Role "admin"}}
|
|
<a href="/admin" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 transition-colors">
|
|
{{index .Tr "admin_panel"}}
|
|
</a>
|
|
<a href="/admin/articles" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 transition-colors">
|
|
{{index .Tr "article_manage"}}
|
|
</a>
|
|
<a href="/admin/comments" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 transition-colors">
|
|
{{index .Tr "admin_comments"}}
|
|
</a>
|
|
{{end}}
|
|
<div class="border-t border-gray-100 my-1"></div>
|
|
<form action="/logout" method="post" class="m-0">
|
|
<button type="submit" class="w-full text-left block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 transition-colors cursor-pointer bg-transparent border-none">
|
|
{{index .Tr "logout"}}
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
{{else}}
|
|
<a href="/login" class="text-gray-600 hover:text-blue-600 transition-colors">{{index .Tr "login"}}</a>
|
|
{{end}}
|
|
<!-- Language Switcher -->
|
|
<a href="?lang={{.SwitchLang}}" class="text-sm text-gray-400 hover:text-blue-600 transition-colors border border-gray-300 rounded px-2 py-1">
|
|
{{index .Tr "lang_switch"}}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<!-- Main Content -->
|
|
<main class="flex-1">
|
|
{{if .SiteHeaderText}}
|
|
<!-- Header banner -->
|
|
<div class="bg-blue-50 border-b border-blue-100 text-blue-800 text-sm text-center py-2 px-4">
|
|
{{.SiteHeaderText}}
|
|
</div>
|
|
{{end}}
|
|
{{end}}
|
|
|
|
{{define "footer"}}
|
|
</main>
|
|
|
|
<!-- Footer -->
|
|
<footer class="bg-white border-t border-gray-200 py-6 mt-auto">
|
|
<div class="max-w-5xl mx-auto px-4 text-center text-gray-500 text-sm">
|
|
{{if .SiteFooterText}}{{.SiteFooterText}}{{else}}{{index .Tr "footer_text"}}{{end}}
|
|
</div>
|
|
</footer>
|
|
<script>
|
|
function toggleDropdown() {
|
|
var menu = document.getElementById('dropdownMenu');
|
|
menu.classList.toggle('hidden');
|
|
}
|
|
// Close dropdown when clicking outside
|
|
document.addEventListener('click', function(e) {
|
|
var dropdown = document.getElementById('avatarDropdown');
|
|
var menu = document.getElementById('dropdownMenu');
|
|
if (dropdown && !dropdown.contains(e.target)) {
|
|
menu.classList.add('hidden');
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|
|
{{end}}
|