Complete project files including setup.sh
This commit is contained in:
87
templates/index.html
Normal file
87
templates/index.html
Normal file
@@ -0,0 +1,87 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}首页 - 泸州高中摄影社论坛{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="page-header">
|
||||
<h1>📸 摄影作品分享</h1>
|
||||
<p class="subtitle">发现精彩瞬间</p>
|
||||
</div>
|
||||
|
||||
{% if posts %}
|
||||
<div class="posts-grid">
|
||||
{% for post in posts %}
|
||||
<div class="post-card">
|
||||
<div class="post-header">
|
||||
<div class="user-info">
|
||||
<a href="{{ url_for('users.profile', username=post.author.username) }}" class="user-avatar">
|
||||
{{ post.author.username[0].upper() }}
|
||||
</a>
|
||||
<div>
|
||||
<a href="{{ url_for('users.profile', username=post.author.username) }}" class="username">
|
||||
{{ post.author.username }}
|
||||
</a>
|
||||
<span class="post-time">{{ post.created_at.strftime('%Y-%m-%d %H:%M') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="{{ url_for('posts.post_detail', post_id=post.id) }}" class="post-image-link">
|
||||
<img src="{{ url_for('uploaded_file', filename=post.image_path) }}" alt="Post image" class="post-image"
|
||||
loading="lazy">
|
||||
</a>
|
||||
|
||||
{% if post.description %}
|
||||
<div class="post-description">
|
||||
{{ post.description }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="post-footer">
|
||||
<a href="{{ url_for('posts.post_detail', post_id=post.id) }}" class="comment-count">
|
||||
💬 {{ post.get_comment_count() }} 条评论
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<!-- 分页 -->
|
||||
{% if pagination.pages > 1 %}
|
||||
<div class="pagination">
|
||||
{% if pagination.has_prev %}
|
||||
<a href="{{ url_for('posts.index', page=pagination.prev_num) }}" class="page-link">上一页</a>
|
||||
{% endif %}
|
||||
|
||||
{% for page_num in pagination.iter_pages(left_edge=1, right_edge=1, left_current=2, right_current=2) %}
|
||||
{% if page_num %}
|
||||
{% if page_num == pagination.page %}
|
||||
<span class="page-link active">{{ page_num }}</span>
|
||||
{% else %}
|
||||
<a href="{{ url_for('posts.index', page=page_num) }}" class="page-link">{{ page_num }}</a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="page-link">...</span>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if pagination.has_next %}
|
||||
<a href="{{ url_for('posts.index', page=pagination.next_num) }}" class="page-link">下一页</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<div class="empty-icon">📷</div>
|
||||
<h2>还没有帖子</h2>
|
||||
<p>成为第一个分享摄影作品的人吧!</p>
|
||||
{% if current_user.is_authenticated %}
|
||||
<a href="{{ url_for('posts.create_post') }}" class="btn btn-primary">发布作品</a>
|
||||
{% else %}
|
||||
<a href="{{ url_for('auth.register') }}" class="btn btn-primary">立即注册</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user