Files
vps_web/templates/forum/index.html
ddrwode 036a19f28c 哈哈
2026-02-10 13:48:58 +08:00

227 lines
13 KiB
HTML

<!DOCTYPE html>
<html lang="{{ 'zh-CN' if lang == 'zh' else 'en' }}">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ l('论坛', 'Forum') }} - {{ l('云价眼', 'VPS Price') }}</title>
<link rel="icon" type="image/svg+xml" href="{{ url_for('static', filename='img/site-logo-mark.svg') }}">
<link rel="stylesheet" href="/static/css/style.css">
<link rel="stylesheet" href="/static/css/forum.css">
</head>
<body class="forum-page">
{% set cards = post_cards if post_cards is defined else [] %}
{% set sb = sidebar if sidebar is defined else {'total_users': 0, 'total_posts': 0, 'total_comments': 0, 'category_counts': [], 'active_users': []} %}
<header class="forum-header">
<div class="forum-header-inner">
<div class="forum-header-left">
<a href="{{ url_for('forum_index') }}" class="forum-logo">
<img src="{{ url_for('static', filename='img/site-logo-mark.svg') }}" alt="{{ l('云价眼 Logo', 'VPS Price Logo') }}">
<span>{{ l('云价眼论坛', 'VPS Price Forum') }}</span>
</a>
<nav class="forum-primary-nav">
{% for item in tab_links %}
<a href="{{ item.url }}" class="{{ 'active' if item.active else '' }}">{{ item.label }}</a>
{% endfor %}
<a href="{{ category_nav_url }}" class="{{ 'active' if selected_category else '' }}">{{ l('分类', 'Categories') }}</a>
<a href="{{ url_for('index') }}">{{ l('价格表', 'Pricing') }}</a>
</nav>
</div>
<div class="forum-header-right">
<span class="lang-switch">
<a href="{{ lang_url('zh') }}" class="{{ 'active' if lang == 'zh' else '' }}" title="切换到中文">中文</a>
<span class="lang-sep">|</span>
<a href="{{ lang_url('en') }}" class="{{ 'active' if lang == 'en' else '' }}" title="Switch to English">English</a>
</span>
{% if current_user %}
<span class="forum-user-chip">{{ current_user.username }}{% if current_user.is_banned %}{{ l('(封禁)', ' (Banned)') }}{% endif %}</span>
<a href="{{ url_for('user_profile') }}" class="forum-link">{{ l('个人中心', 'Profile') }}</a>
<a href="{{ url_for('user_notifications') }}" class="forum-link nav-link-with-badge">{{ l('通知', 'Notifications') }}{% if notifications_unread_count %}<span class="nav-badge">{{ notifications_unread_count }}</span>{% endif %}</a>
<a href="{{ url_for('user_logout') }}" class="forum-link">{{ l('退出', 'Logout') }}</a>
{% else %}
<a href="{{ url_for('user_login') }}" class="forum-link">{{ l('登录', 'Login') }}</a>
<a href="{{ url_for('user_register') }}" class="forum-link">{{ l('注册', 'Register') }}</a>
{% endif %}
</div>
</div>
</header>
<main class="forum-shell">
<section class="forum-topline">
<div class="forum-tabs">
{% for item in tab_links %}
<a class="{{ 'active' if item.active else '' }}" href="{{ item.url }}">{{ item.label }}</a>
{% endfor %}
<a class="{{ 'active' if selected_category else '' }}" href="{{ category_nav_url }}">{{ l('分类', 'Categories') }}</a>
</div>
<div class="forum-actions">
{% if current_user and not current_user.is_banned %}
<a href="{{ url_for('forum_post_new') }}" class="forum-btn-primary">+ {{ l('发布主题', 'New Topic') }}</a>
{% elif current_user and current_user.is_banned %}
<span class="forum-btn-muted">{{ l('账号封禁中', 'Account banned') }}</span>
{% else %}
<a href="{{ url_for('user_login', next='/forum/post/new') }}" class="forum-btn-primary">{{ l('登录后发帖', 'Login to post') }}</a>
{% endif %}
</div>
</section>
{% if message %}
<p class="form-success">{{ message }}</p>
{% endif %}
{% if error %}
<p class="form-error">{{ error }}</p>
{% endif %}
<section class="forum-tools">
<form method="get" action="{{ url_for('forum_index') }}" class="forum-search-form">
<input type="hidden" name="tab" value="{{ active_tab }}">
<input type="hidden" name="per_page" value="{{ per_page }}">
{% if selected_category %}
<input type="hidden" name="category" value="{{ selected_category }}">
{% endif %}
<input type="text" name="q" value="{{ search_query or '' }}" placeholder="{{ l('搜索标题、正文、作者', 'Search title, content, author') }}" maxlength="80">
<button type="submit" class="forum-btn-primary">{{ l('搜索', 'Search') }}</button>
{% if search_query %}
<a href="{{ clear_search_url }}" class="forum-btn-muted">{{ l('清空搜索', 'Clear Search') }}</a>
{% endif %}
{% if has_filters %}
<a href="{{ clear_all_url }}" class="forum-btn-muted">{{ l('重置全部', 'Reset All') }}</a>
{% endif %}
</form>
<div class="category-bar">
{% for item in category_links %}
<a href="{{ item.url }}" class="category-chip {{ 'active' if item.active else '' }}">
<span>{{ item.name }}</span>
{% if item.count is not none %}
<strong>{{ item.count }}</strong>
{% endif %}
</a>
{% endfor %}
</div>
</section>
<section class="forum-layout">
<div class="topic-stream">
<div class="topic-head">
<div class="topic-col-main">{{ l('主题', 'Topic') }}</div>
<div class="topic-col-mini">{{ l('回复', 'Replies') }}</div>
<div class="topic-col-mini">{{ l('浏览', 'Views') }}</div>
<div class="topic-col-mini">{{ l('活动', 'Activity') }}</div>
</div>
{% if cards %}
<ul class="topic-list">
{% for item in cards %}
{% set post = item.post %}
<li class="topic-row">
<div class="topic-main">
<div class="topic-avatar">{{ item.author_initial }}</div>
<div class="topic-content">
<a href="{{ url_for('forum_post_detail', post_id=post.id) }}" class="topic-title">
{% if post.is_pinned %}<span class="topic-flag flag-pinned">{{ l('置顶', 'Pinned') }}</span>{% endif %}
{% if post.is_featured %}<span class="topic-flag flag-featured">{{ l('精华', 'Featured') }}</span>{% endif %}
{% if post.is_locked %}<span class="topic-flag flag-locked">{{ l('锁帖', 'Locked') }}</span>{% endif %}
{{ post.title }}
</a>
<div class="topic-meta">
<span class="topic-category">{{ post.category or l('综合讨论', 'General') }}</span>
<span>{{ item.author_name }}</span>
<span>{{ post.created_at.strftime('%Y-%m-%d %H:%M') if post.created_at else '' }}</span>
<span>{{ l('点赞', 'Likes') }} {{ item.like_count }}</span>
<span>{{ l('收藏', 'Bookmarks') }} {{ item.bookmark_count }}</span>
</div>
</div>
</div>
<div class="topic-stat">{{ item.reply_count }}</div>
<div class="topic-stat">{{ item.view_count }}</div>
<div class="topic-stat topic-activity">{{ item.latest_activity_text }}</div>
</li>
{% endfor %}
</ul>
{% if total_pages > 1 %}
<nav class="forum-pagination" aria-label="{{ l('帖子分页', 'Post pagination') }}">
{% if has_prev %}
<a href="{{ prev_page_url }}" class="page-link">{{ l('上一页', 'Prev') }}</a>
{% else %}
<span class="page-link disabled">{{ l('上一页', 'Prev') }}</span>
{% endif %}
{% for item in page_links %}
<a href="{{ item.url }}" class="page-link {{ 'active' if item.active else '' }}">{{ item.num }}</a>
{% endfor %}
{% if has_next %}
<a href="{{ next_page_url }}" class="page-link">{{ l('下一页', 'Next') }}</a>
{% else %}
<span class="page-link disabled">{{ l('下一页', 'Next') }}</span>
{% endif %}
</nav>
{% endif %}
{% else %}
<div class="topic-empty">{{ empty_hint }}</div>
{% endif %}
{% if total_posts %}
<div class="topic-footer">
<div class="topic-result">
{% if lang == 'en' %}
Page {{ current_page }} / {{ total_pages }} · Showing {{ result_start }} - {{ result_end }} of {{ total_posts }}
{% else %}
第 {{ current_page }} / {{ total_pages }} 页 · 显示 {{ result_start }} - {{ result_end }} / 共 {{ total_posts }} 条
{% endif %}
</div>
<form method="get" action="{{ url_for('forum_index') }}" class="page-size-form">
<input type="hidden" name="tab" value="{{ active_tab }}">
{% if selected_category %}
<input type="hidden" name="category" value="{{ selected_category }}">
{% endif %}
{% if search_query %}
<input type="hidden" name="q" value="{{ search_query }}">
{% endif %}
<label for="per-page-select">{{ l('每页', 'Per page') }}</label>
<select id="per-page-select" name="per_page" onchange="this.form.submit()">
{% for size in per_page_options %}
<option value="{{ size }}" {{ 'selected' if size == per_page else '' }}>{{ size }}</option>
{% endfor %}
</select>
<span>{{ l('条', 'items') }}</span>
<noscript><button type="submit" class="forum-btn-muted">{{ l('应用', 'Apply') }}</button></noscript>
</form>
</div>
{% endif %}
</div>
<aside class="forum-sidebar">
<div class="side-card">
<h3>{{ l('社区统计', 'Community Stats') }}</h3>
<div class="side-stats">
<div><span>{{ l('用户', 'Users') }}</span><strong>{{ sb.total_users }}</strong></div>
<div><span>{{ l('帖子', 'Posts') }}</span><strong>{{ sb.total_posts }}</strong></div>
<div><span>{{ l('评论', 'Comments') }}</span><strong>{{ sb.total_comments }}</strong></div>
</div>
</div>
<div class="side-card">
<h3>{{ l('分类热度', 'Category Heat') }}</h3>
{% if sb.category_counts %}
<ul class="side-list">
{% for name, count in sb.category_counts %}
<li><span>{{ name }}</span><strong>{{ count }}</strong></li>
{% endfor %}
</ul>
{% else %}
<p class="side-empty">{{ l('暂无分类数据', 'No category data') }}</p>
{% endif %}
</div>
<div class="side-card">
<h3>{{ l('活跃作者', 'Active Authors') }}</h3>
{% if sb.active_users %}
<ul class="side-list">
{% for username, post_count in sb.active_users %}
<li><span>{{ username }}</span><strong>{{ post_count }}</strong></li>
{% endfor %}
</ul>
{% else %}
<p class="side-empty">{{ l('暂无活跃作者', 'No active authors') }}</p>
{% endif %}
</div>
</aside>
</section>
</main>
</body>
</html>