Initial commit
This commit is contained in:
89
main/templates/main/dashboard.html
Normal file
89
main/templates/main/dashboard.html
Normal file
@@ -0,0 +1,89 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="max-w-4xl mx-auto py-8">
|
||||
<h1 class="text-3xl font-bold mb-6">您的仪表板</h1>
|
||||
|
||||
<div class="mb-8">
|
||||
<h2 class="text-xl font-semibold mb-4">您的文件</h2>
|
||||
<div class="bg-white p-6 rounded-lg shadow">
|
||||
{% if files %}
|
||||
<ul class="divide-y divide-gray-200">
|
||||
{% for file in files %}
|
||||
<li class="py-4 flex items-center justify-between">
|
||||
<div>
|
||||
<a href="{{ file.file.url }}" class="text-blue-500 hover:text-blue-700">
|
||||
{{ file.file.name }}
|
||||
</a>
|
||||
<p class="text-gray-600 text-sm">{{ file.description }}</p>
|
||||
</div>
|
||||
<form action="{% url 'delete_file' file.id %}" method="post">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="text-red-500 hover:text-red-700">
|
||||
Delete
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="text-gray-600">尚未上传文件。</p>
|
||||
{% endif %}
|
||||
<div class="mt-4 flex space-x-4">
|
||||
<a href="{% url 'upload' %}" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
|
||||
上传新文件
|
||||
</a>
|
||||
<a href="{% url 'send_message' %}" class="bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded">
|
||||
发送消息
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-8">
|
||||
<h2 class="text-xl font-semibold mb-4">共享文件</h2>
|
||||
<div class="bg-white p-6 rounded-lg shadow">
|
||||
{% if shared_files %}
|
||||
<ul class="divide-y divide-gray-200">
|
||||
{% for file in shared_files %}
|
||||
<li class="py-4">
|
||||
<a href="{{ file.file.url }}" class="text-blue-500 hover:text-blue-700">
|
||||
{{ file.file.name }}
|
||||
</a>
|
||||
<p class="text-gray-600 text-sm">Shared by {{ file.owner.username }}</p>
|
||||
<p class="text-gray-600 text-sm">{{ file.description }}</p>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="text-gray-600">没有共享文件。</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2 class="text-xl font-semibold mb-4">消息</h2>
|
||||
<div class="bg-white p-6 rounded-lg shadow">
|
||||
{% if messages %}
|
||||
<ul class="divide-y divide-gray-200">
|
||||
{% for message in messages %}
|
||||
<li class="py-4">
|
||||
<p class="text-gray-800">{{ message.content }}</p>
|
||||
<p class="text-gray-600 text-sm">From {{ message.sender.username }}</p>
|
||||
{% if message.file %}
|
||||
<p class="text-gray-600 text-sm">
|
||||
File: <a href="{{ message.file.file.url }}" class="text-blue-500 hover:text-blue-700">
|
||||
{{ message.file.file.name }}
|
||||
</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="text-gray-600">没有消息。</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
132
main/templates/main/home.html
Normal file
132
main/templates/main/home.html
Normal file
@@ -0,0 +1,132 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="max-w-4xl mx-auto py-8">
|
||||
<h1 class="text-3xl font-bold mb-6">欢迎使用文件共享系统</h1>
|
||||
|
||||
<div class="mb-8">
|
||||
<h2 class="text-xl font-semibold mb-4">公共留言</h2>
|
||||
<div class="bg-gray-50 p-6 rounded-lg shadow mb-8">
|
||||
{% if public_messages %}
|
||||
<ul class="divide-y divide-gray-200">
|
||||
{% for message in public_messages %}
|
||||
<li class="py-4">
|
||||
<div class="flex justify-between items-start">
|
||||
<div>
|
||||
<p class="font-medium">{{ message.name|default:"匿名" }}</p>
|
||||
<p class="text-gray-600">{{ message.content }}</p>
|
||||
<p class="text-xs text-gray-400 mt-1">IP: {{ message.ip_address }}</p>
|
||||
{% if message.file %}
|
||||
<a href="{{ message.file.url }}" class="text-blue-500 hover:text-blue-700 mt-2 inline-block">
|
||||
下载附件: {{ message.file.name }}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<span class="text-sm text-gray-500">{{ message.created_at|date:"Y-m-d H:i" }}</span>
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="text-gray-600">还没有留言。</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<h2 class="text-xl font-semibold mb-4">公共文件</h2>
|
||||
<div class="bg-gray-50 p-6 rounded-lg shadow">
|
||||
{% if public_files %}
|
||||
<ul class="divide-y divide-gray-200">
|
||||
{% for file in public_files %}
|
||||
<li class="py-4">
|
||||
<div class="flex justify-between items-start">
|
||||
<div>
|
||||
<a href="{{ file.file.url }}" class="text-blue-500 hover:text-blue-700">
|
||||
{{ file.file.name }}
|
||||
</a>
|
||||
<p class="text-gray-600 text-sm">上传者:{{ file.name|default:"匿名用户" }}</p>
|
||||
<p class="text-gray-600 text-sm">{{ file.description }}</p>
|
||||
<p class="text-xs text-gray-400 mt-1">IP: {{ file.ip_address }}</p>
|
||||
</div>
|
||||
<span class="text-sm text-gray-500">{{ file.created_at|date:"Y-m-d H:i" }}</span>
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="text-gray-600">没有可用的公共文件。</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<h2 class="text-xl font-semibold mb-4">提交留言</h2>
|
||||
<div class="bg-blue-50 p-6 rounded-lg shadow mb-8">
|
||||
<form method="post" class="space-y-4">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="submit_message" value="1">
|
||||
|
||||
<div>
|
||||
<label for="id_name" class="block text-sm font-medium text-gray-700 mb-1">
|
||||
姓名
|
||||
</label>
|
||||
<input type="text" name="name" id="id_name" required
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="id_content" class="block text-sm font-medium text-gray-700 mb-1">
|
||||
留言内容
|
||||
</label>
|
||||
<textarea name="content" id="id_content" rows="4" required
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"></textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit"
|
||||
class="w-full bg-blue-500 text-white py-2 px-4 rounded-md hover:bg-blue-600 transition-colors duration-300">
|
||||
提交留言
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<h2 class="text-xl font-semibold mb-4">提交文件</h2>
|
||||
<div class="bg-blue-50 p-6 rounded-lg shadow mb-8">
|
||||
<form method="post" enctype="multipart/form-data" class="space-y-4">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="submit_file" value="1">
|
||||
|
||||
<div>
|
||||
<label for="id_name" class="block text-sm font-medium text-gray-700 mb-1">
|
||||
姓名
|
||||
</label>
|
||||
<input type="text" name="name" id="id_name" required
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="id_description" class="block text-sm font-medium text-gray-700 mb-1">
|
||||
文件描述
|
||||
</label>
|
||||
<textarea name="description" id="id_description" rows="3" required
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"></textarea>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="id_file" class="block text-sm font-medium text-gray-700 mb-1">
|
||||
选择文件
|
||||
</label>
|
||||
<input type="file" name="file" id="id_file" required
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500
|
||||
file:mr-4 file:py-2 file:px-4
|
||||
file:rounded-md file:border-0
|
||||
file:text-sm file:font-semibold
|
||||
file:bg-blue-50 file:text-blue-700
|
||||
hover:file:bg-blue-100">
|
||||
</div>
|
||||
|
||||
<button type="submit"
|
||||
class="w-full bg-blue-500 text-white py-2 px-4 rounded-md hover:bg-blue-600 transition-colors duration-300">
|
||||
提交文件
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
77
main/templates/main/manage_friends.html
Normal file
77
main/templates/main/manage_friends.html
Normal file
@@ -0,0 +1,77 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="max-w-4xl mx-auto py-8">
|
||||
<h1 class="text-2xl font-bold mb-6">好友管理</h1>
|
||||
|
||||
<div class="space-y-8">
|
||||
<!-- 待处理的好友请求 -->
|
||||
<div class="bg-white p-6 rounded-lg shadow">
|
||||
<h2 class="text-xl font-semibold mb-4">待处理的好友请求</h2>
|
||||
{% if pending_requests %}
|
||||
<ul class="divide-y divide-gray-200">
|
||||
{% for request in pending_requests %}
|
||||
<li class="py-4">
|
||||
<div class="flex justify-between items-center">
|
||||
<div>
|
||||
<p class="font-medium">{{ request.from_user.username }}</p>
|
||||
<p class="text-sm text-gray-500">{{ request.created_at|date:"Y-m-d H:i" }}</p>
|
||||
</div>
|
||||
<form method="post" action="{% url 'handle_friend_request' request.id %}">
|
||||
{% csrf_token %}
|
||||
<div class="flex space-x-2">
|
||||
<button type="submit" name="action" value="accept"
|
||||
class="bg-green-500 text-white px-3 py-1 rounded hover:bg-green-600">
|
||||
接受
|
||||
</button>
|
||||
<button type="submit" name="action" value="reject"
|
||||
class="bg-red-500 text-white px-3 py-1 rounded hover:bg-red-600">
|
||||
拒绝
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="text-gray-600">没有待处理的好友请求。</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- 好友列表 -->
|
||||
<div class="bg-white p-6 rounded-lg shadow">
|
||||
<h2 class="text-xl font-semibold mb-4">好友列表</h2>
|
||||
{% if friends %}
|
||||
<ul class="divide-y divide-gray-200">
|
||||
{% for friend in friends %}
|
||||
<li class="py-4">
|
||||
<div class="flex justify-between items-center">
|
||||
<div>
|
||||
<p class="font-medium">
|
||||
{% if friend.from_user == request.user %}
|
||||
{{ friend.to_user.username }}
|
||||
{% else %}
|
||||
{{ friend.from_user.username }}
|
||||
{% endif %}
|
||||
</p>
|
||||
<p class="text-sm text-gray-500">成为好友时间:{{ friend.created_at|date:"Y-m-d H:i" }}</p>
|
||||
</div>
|
||||
<form method="post" action="{% url 'remove_friend' friend.id %}">
|
||||
{% csrf_token %}
|
||||
<button type="submit"
|
||||
class="bg-red-500 text-white px-3 py-1 rounded hover:bg-red-600">
|
||||
删除好友
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="text-gray-600">您还没有好友。</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
37
main/templates/main/search.html
Normal file
37
main/templates/main/search.html
Normal file
@@ -0,0 +1,37 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="max-w-4xl mx-auto py-8">
|
||||
<h1 class="text-2xl font-bold mb-6">Search Files</h1>
|
||||
|
||||
<form method="get" class="mb-8">
|
||||
<div class="flex">
|
||||
<input type="text" name="q" value="{{ query }}"
|
||||
class="flex-1 px-4 py-2 border rounded-l-lg focus:outline-none"
|
||||
placeholder="搜索文件名...">
|
||||
<button type="submit"
|
||||
class="bg-blue-500 hover:bg-blue-700 text-white font-bold px-4 rounded-r-lg">
|
||||
Search
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{% if results %}
|
||||
<div class="bg-white p-6 rounded-lg shadow">
|
||||
<ul class="divide-y divide-gray-200">
|
||||
{% for file in results %}
|
||||
<li class="py-4">
|
||||
<a href="{{ file.file.url }}" class="text-blue-500 hover:text-blue-700">
|
||||
{{ file.file.name }}
|
||||
</a>
|
||||
<p class="text-gray-600 text-sm">Uploaded by {{ file.owner.username }}</p>
|
||||
<p class="text-gray-600 text-sm">{{ file.description }}</p>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% elif query %}
|
||||
<p class="text-gray-600">No files found matching "{{ query }}".</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
20
main/templates/main/send_friend_request.html
Normal file
20
main/templates/main/send_friend_request.html
Normal file
@@ -0,0 +1,20 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="max-w-4xl mx-auto py-8">
|
||||
<h1 class="text-2xl font-bold mb-6">发送好友请求</h1>
|
||||
|
||||
<div class="bg-white p-6 rounded-lg shadow">
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<div class="space-y-4">
|
||||
{{ form.as_p }}
|
||||
</div>
|
||||
<button type="submit"
|
||||
class="mt-4 bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600">
|
||||
发送请求
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
34
main/templates/main/send_message.html
Normal file
34
main/templates/main/send_message.html
Normal file
@@ -0,0 +1,34 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="max-w-4xl mx-auto py-8">
|
||||
<h1 class="text-2xl font-bold mb-6">Send Message</h1>
|
||||
<form method="post" class="bg-white p-6 rounded-lg shadow">
|
||||
{% csrf_token %}
|
||||
<div class="mb-4">
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2">
|
||||
收件人
|
||||
</label>
|
||||
{{ form.recipients }}
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2">
|
||||
消息内容
|
||||
</label>
|
||||
{{ form.content }}
|
||||
</div>
|
||||
<div class="mb-6">
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2">
|
||||
附加文件(可选)
|
||||
</label>
|
||||
{{ form.file }}
|
||||
</div>
|
||||
<div class="flex items-center justify-between">
|
||||
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
|
||||
type="submit">
|
||||
Send
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
41
main/templates/main/upload.html
Normal file
41
main/templates/main/upload.html
Normal file
@@ -0,0 +1,41 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="max-w-4xl mx-auto py-8">
|
||||
<h1 class="text-2xl font-bold mb-6">Upload File</h1>
|
||||
<form method="post" enctype="multipart/form-data" class="bg-white p-6 rounded-lg shadow">
|
||||
{% csrf_token %}
|
||||
<div class="mb-4">
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2">
|
||||
文件
|
||||
</label>
|
||||
{{ form.file }}
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2">
|
||||
描述
|
||||
</label>
|
||||
{{ form.description }}
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2">
|
||||
与特定用户共享(可选)
|
||||
</label>
|
||||
{{ form.shared_with }}
|
||||
</div>
|
||||
<div class="mb-6">
|
||||
<label class="flex items-center space-x-2">
|
||||
{{ form.is_public }}
|
||||
<span class="text-gray-700 text-sm">设为公开文件</span>
|
||||
</label>
|
||||
<p class="text-gray-500 text-xs mt-1">公开文件对所有用户可见</p>
|
||||
</div>
|
||||
<div class="flex items-center justify-between">
|
||||
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
|
||||
type="submit">
|
||||
Upload
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user