File size: 13,061 Bytes
91073d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
{% extends "layout.html" %}

{% block title %}{{ user.username }}'s Profile - Community Forum{% endblock %}

{% block breadcrumb %}
<a href="{{ url_for('forum.index') }}" class="hover:text-blue-600">Home</a>
<span class="mx-2">/</span>
<span>Profile: {{ user.username }}</span>
{% endblock %}

{% block content %}
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
    <!-- User Information Card -->
    <div class="lg:col-span-1">
        <div class="bg-white rounded-lg shadow overflow-hidden">
            <div class="px-6 py-4 border-b border-gray-200 bg-blue-50">
                <h2 class="text-xl font-bold text-gray-800">User Profile</h2>
            </div>
            
            <div class="p-6">
                <div class="flex flex-col items-center">
                    <img 
                        src="{{ url_for('static', filename='uploads/avatars/' + user.avatar) if user.avatar else url_for('static', filename='uploads/avatars/default.png') }}" 
                        alt="{{ user.username }}" 
                        class="w-32 h-32 rounded-full object-cover border-4 border-white shadow"
                    >
                    
                    <h1 class="mt-4 text-2xl font-bold text-gray-800">{{ user.username }}</h1>
                    
                    <div class="mt-2">
                        {% if user.role == 'admin' %}
                        <span class="inline-block bg-red-100 text-red-800 text-sm px-3 py-1 rounded-full">Administrator</span>
                        {% elif user.role == 'moderator' %}
                        <span class="inline-block bg-green-100 text-green-800 text-sm px-3 py-1 rounded-full">Moderator</span>
                        {% else %}
                        <span class="inline-block bg-blue-100 text-blue-800 text-sm px-3 py-1 rounded-full">Member</span>
                        {% endif %}
                    </div>
                </div>
                
                <div class="mt-6 space-y-4 text-gray-700">
                    <div class="flex items-center">
                        <i data-feather="calendar" class="w-5 h-5 text-gray-400 mr-3"></i>
                        <span>Joined {{ user.created_at.strftime('%B %d, %Y') }}</span>
                    </div>
                    
                    <div class="flex items-center">
                        <i data-feather="clock" class="w-5 h-5 text-gray-400 mr-3"></i>
                        <span>Last seen {{ user.last_seen.strftime('%B %d, %Y') }}</span>
                    </div>
                    
                    {% if user.location %}
                    <div class="flex items-center">
                        <i data-feather="map-pin" class="w-5 h-5 text-gray-400 mr-3"></i>
                        <span>{{ user.location }}</span>
                    </div>
                    {% endif %}
                    
                    {% if user.website %}
                    <div class="flex items-center">
                        <i data-feather="globe" class="w-5 h-5 text-gray-400 mr-3"></i>
                        <a href="{{ user.website }}" target="_blank" class="text-blue-600 hover:underline truncate">{{ user.website }}</a>
                    </div>
                    {% endif %}
                </div>
                
                {% if user.bio %}
                <div class="mt-6 pt-6 border-t border-gray-200">
                    <h3 class="text-lg font-medium text-gray-800 mb-2">About</h3>
                    <p class="text-gray-700">{{ user.bio }}</p>
                </div>
                {% endif %}
                
                {% if user.signature %}
                <div class="mt-6 pt-6 border-t border-gray-200">
                    <h3 class="text-lg font-medium text-gray-800 mb-2">Signature</h3>
                    <p class="text-gray-700 text-sm italic">{{ user.signature }}</p>
                </div>
                {% endif %}
                
                {% if current_user.is_authenticated and current_user.id == user.id %}
                <div class="mt-6 pt-6 border-t border-gray-200">
                    <a href="{{ url_for('user.edit_profile') }}" class="w-full block text-center px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors">
                        Edit Profile
                    </a>
                    <a href="{{ url_for('user.change_password') }}" class="w-full block text-center mt-2 px-4 py-2 bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 transition-colors">
                        Change Password
                    </a>
                </div>
                {% endif %}
            </div>
        </div>
    </div>
    
    <!-- User Activity -->
    <div class="lg:col-span-2 space-y-6">
        <!-- Topics Created -->
        <div class="bg-white rounded-lg shadow overflow-hidden">
            <div class="px-6 py-4 border-b border-gray-200 bg-blue-50 flex justify-between items-center">
                <h2 class="text-xl font-bold text-gray-800">Topics Started</h2>
                <span class="text-gray-600">{{ topics.total }} total</span>
            </div>
            
            {% if topics.items %}
            <div class="divide-y divide-gray-200">
                {% for topic in topics.items %}
                <div class="p-4 hover:bg-gray-50">
                    <a href="{{ url_for('forum.topic_view', id=topic.id) }}" class="block">
                        <div class="flex justify-between items-start">
                            <div>
                                <h3 class="text-lg font-medium text-gray-800 hover:text-blue-600">{{ topic.title }}</h3>
                                <div class="flex items-center text-sm text-gray-500 mt-1">
                                    <span>{{ topic.created_at.strftime('%b %d, %Y') }}</span>
                                    <span class="mx-2"></span>
                                    <span>{{ topic.reply_count() }} replies</span>
                                    <span class="mx-2"></span>
                                    <span>{{ topic.views }} views</span>
                                </div>
                                
                                {% if topic.tags %}
                                <div class="mt-2 flex flex-wrap">
                                    {% for tag in topic.tags %}
                                    <a href="{{ url_for('forum.tag_view', tag_name=tag.name) }}" class="tag">
                                        {{ tag.name }}
                                    </a>
                                    {% endfor %}
                                </div>
                                {% endif %}
                            </div>
                            
                            <div class="text-xs text-gray-500 whitespace-nowrap ml-4">
                                <div>In: <a href="{{ url_for('forum.category_view', id=topic.category_id) }}" class="text-blue-600 hover:underline">{{ topic.category.name }}</a></div>
                            </div>
                        </div>
                    </a>
                </div>
                {% endfor %}
            </div>
            
            <!-- Pagination -->
            {% if topics.pages > 1 %}
            <div class="px-6 py-4 bg-gray-50 border-t border-gray-200">
                <div class="flex justify-center">
                    <nav class="inline-flex rounded-md shadow">
                        {% if topics.has_prev %}
                        <a href="{{ url_for('user.profile', username=user.username, page=topics.prev_num) }}" class="px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-l-md hover:bg-gray-50">
                            Previous
                        </a>
                        {% else %}
                        <span class="px-4 py-2 text-sm font-medium text-gray-400 bg-gray-100 border border-gray-300 rounded-l-md cursor-not-allowed">
                            Previous
                        </span>
                        {% endif %}
                        
                        {% for page_num in topics.iter_pages(left_edge=1, right_edge=1, left_current=2, right_current=2) %}
                            {% if page_num %}
                                {% if page_num == topics.page %}
                                <span class="px-4 py-2 text-sm font-medium text-blue-600 bg-blue-50 border border-gray-300">
                                    {{ page_num }}
                                </span>
                                {% else %}
                                <a href="{{ url_for('user.profile', username=user.username, page=page_num) }}" class="px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 hover:bg-gray-50">
                                    {{ page_num }}
                                </a>
                                {% endif %}
                            {% else %}
                            <span class="px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300"></span>
                            {% endif %}
                        {% endfor %}
                        
                        {% if topics.has_next %}
                        <a href="{{ url_for('user.profile', username=user.username, page=topics.next_num) }}" class="px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-r-md hover:bg-gray-50">
                            Next
                        </a>
                        {% else %}
                        <span class="px-4 py-2 text-sm font-medium text-gray-400 bg-gray-100 border border-gray-300 rounded-r-md cursor-not-allowed">
                            Next
                        </span>
                        {% endif %}
                    </nav>
                </div>
            </div>
            {% endif %}
            
            {% else %}
            <div class="p-6 text-center text-gray-500">
                This user hasn't created any topics yet.
            </div>
            {% endif %}
        </div>
        
        <!-- Recent Posts -->
        <div class="bg-white rounded-lg shadow overflow-hidden">
            <div class="px-6 py-4 border-b border-gray-200 bg-blue-50">
                <h2 class="text-xl font-bold text-gray-800">Recent Posts</h2>
            </div>
            
            {% if recent_posts %}
            <div class="divide-y divide-gray-200">
                {% for post in recent_posts %}
                <div class="p-4 hover:bg-gray-50">
                    <div>
                        <div class="flex justify-between items-start mb-2">
                            <div>
                                <a href="{{ url_for('forum.topic_view', id=post.topic_id) }}" class="text-lg font-medium text-gray-800 hover:text-blue-600">
                                    Re: {{ post.topic.title }}
                                </a>
                            </div>
                            <div class="text-xs text-gray-500">
                                {{ post.created_at.strftime('%b %d, %Y %H:%M') }}
                            </div>
                        </div>
                        
                        <div class="text-gray-700 line-clamp-2 text-sm mb-2">
                            {{ post.content|striptags|truncate(150) }}
                        </div>
                        
                        <div class="text-xs text-gray-500">
                            Posted in: <a href="{{ url_for('forum.category_view', id=post.topic.category_id) }}" class="text-blue-600 hover:underline">{{ post.topic.category.name }}</a>
                            <a href="{{ url_for('forum.topic_view', id=post.topic_id) }}#post-{{ post.id }}" class="text-blue-600 hover:underline ml-2">
                                View Post <i data-feather="arrow-right" class="w-3 h-3 inline"></i>
                            </a>
                        </div>
                    </div>
                </div>
                {% endfor %}
            </div>
            
            {% if current_user.id == user.id %}
            <div class="px-6 py-4 bg-gray-50 border-t border-gray-200">
                <a href="{{ url_for('user.user_posts') }}" class="inline-flex items-center text-blue-600 hover:underline">
                    View all my posts
                    <i data-feather="arrow-right" class="w-4 h-4 ml-1"></i>
                </a>
            </div>
            {% endif %}
            
            {% else %}
            <div class="p-6 text-center text-gray-500">
                This user hasn't made any posts yet.
            </div>
            {% endif %}
        </div>
    </div>
</div>
{% endblock %}