- Add AdminRequired middleware to all /admin routes for proper authorization - Restrict admin panel, comments, users, settings to admin role only - Create separate /my/articles routes for regular users to manage their own articles - Add MyArticlesPage handler for users to view/edit/delete their own content - Update navigation menus with role-based visibility - Admin dropdown shows only 'Admin Panel' link, other features in dashboard - Regular users see 'My Articles' link in profile dropdown - Add i18n translations for 'my_articles' and 'comment_manage' keys - Fix permission boundary issues where author role could access admin settings Security improvements: - Platform settings now require admin role - Comment moderation requires admin role - User management requires admin role - Regular users can only manage their own articles Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
72 lines
3.7 KiB
HTML
72 lines
3.7 KiB
HTML
{{define "dashboard"}}
|
|
{{template "header" .}}
|
|
<section class="max-w-5xl mx-auto px-4 py-12">
|
|
<div class="flex items-center justify-between mb-8">
|
|
<div>
|
|
<h2 class="text-3xl font-bold text-gray-900">{{index .Tr "dash_title"}}</h2>
|
|
<p class="text-gray-500 mt-1">{{index .Tr "dash_welcome"}} <span class="font-medium text-gray-700">{{.Username}}</span>!</p>
|
|
</div>
|
|
<form action="/logout" method="post" class="m-0">
|
|
<button
|
|
type="submit"
|
|
class="bg-gray-200 text-gray-700 px-4 py-2 rounded-lg font-medium hover:bg-gray-300 transition-colors cursor-pointer"
|
|
>
|
|
{{index .Tr "logout"}}
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Stats -->
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-10">
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
|
|
<p class="text-sm text-gray-500 uppercase tracking-wider">{{index .Tr "dash_posts"}}</p>
|
|
<p class="text-3xl font-bold text-gray-900 mt-1">{{.PostCount}}
|
|
<span class="text-sm font-normal text-gray-400">({{.PublishedCount}} {{index .Tr "dash_published"}})</span>
|
|
</p>
|
|
</div>
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
|
|
<p class="text-sm text-gray-500 uppercase tracking-wider">{{index .Tr "dash_pages"}}</p>
|
|
<p class="text-3xl font-bold text-gray-900 mt-1">0</p>
|
|
</div>
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
|
|
<p class="text-sm text-gray-500 uppercase tracking-wider">{{index .Tr "dash_users"}}</p>
|
|
<p class="text-3xl font-bold text-gray-900 mt-1">{{.UserCount}}</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Placeholder for future features -->
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-8 text-center">
|
|
<h3 class="text-xl font-semibold text-gray-800 mb-2">{{index .Tr "dash_mgmt_title"}}</h3>
|
|
<p class="text-gray-500 mb-6">{{index .Tr "dash_mgmt_desc"}}</p>
|
|
<div class="flex justify-center gap-3 flex-wrap">
|
|
<a href="/admin/articles/new"
|
|
class="inline-flex items-center gap-2 bg-blue-600 text-white px-6 py-3 rounded-lg font-medium hover:bg-blue-700 transition-colors">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
|
|
</svg>
|
|
{{index .Tr "dash_new_article"}}
|
|
</a>
|
|
<a href="/admin/articles"
|
|
class="inline-flex items-center gap-2 bg-gray-200 text-gray-700 px-6 py-3 rounded-lg font-medium hover:bg-gray-300 transition-colors">
|
|
{{index .Tr "article_manage"}}
|
|
</a>
|
|
{{if eq .Role "admin"}}
|
|
<a href="/admin/users"
|
|
class="inline-flex items-center gap-2 bg-gray-200 text-gray-700 px-6 py-3 rounded-lg font-medium hover:bg-gray-300 transition-colors">
|
|
{{index .Tr "dash_user_mgmt"}}
|
|
</a>
|
|
<a href="/admin/comments"
|
|
class="inline-flex items-center gap-2 bg-gray-200 text-gray-700 px-6 py-3 rounded-lg font-medium hover:bg-gray-300 transition-colors">
|
|
{{index .Tr "comment_manage"}}
|
|
</a>
|
|
<a href="/admin/settings/site"
|
|
class="inline-flex items-center gap-2 bg-gray-200 text-gray-700 px-6 py-3 rounded-lg font-medium hover:bg-gray-300 transition-colors">
|
|
{{index .Tr "settings_nav"}}
|
|
</a>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</section>
|
|
{{template "footer" .}}
|
|
{{end}}
|