Author
|
zPlus <zplus@peers.community>
2018-07-18 23:17:29
|
Committer
|
zPlus <zplus@peers.community>
2018-07-18 23:17:29
|
Commit
|
03779d5
(patch)
|
Tree
|
2f30169
|
Parent(s)
|
|
Add "topic" route.
modified: freepost/__init__.py
modified: freepost/templates/homepage.html
commits diff:
f67dca1..03779d5
2 files changed,
26 insertions,
1 deletion
—
download
Diffstat
Diff options
+25/-0
M freepost/__init__.py
143
|
143
|
|
posts=posts,
|
144
|
144
|
|
sorting='new')
|
145
|
145
|
|
|
|
146
|
+ |
# TODO implement this
|
|
147
|
+ |
@get ('/topic/<name>', name='topic')
|
|
148
|
+ |
def topic (name):
|
|
149
|
+ |
"""
|
|
150
|
+ |
Display posts by topic.
|
|
151
|
+ |
"""
|
|
152
|
+ |
|
|
153
|
+ |
return ""
|
|
154
|
+ |
|
|
155
|
+ |
# Page number
|
|
156
|
+ |
page = int (request.query.page or 0)
|
|
157
|
+ |
|
|
158
|
+ |
if page < 0:
|
|
159
|
+ |
redirect (application.get_url ('topic', name=name))
|
|
160
|
+ |
|
|
161
|
+ |
user = session.user ()
|
|
162
|
+ |
posts = database.get_topic_posts (page, user['id'] if user else None)
|
|
163
|
+ |
|
|
164
|
+ |
return template (
|
|
165
|
+ |
'homepage.html',
|
|
166
|
+ |
page_number=page,
|
|
167
|
+ |
posts=posts,
|
|
168
|
+ |
sorting='hot')
|
|
169
|
+ |
|
146
|
170
|
|
@get ('/about', name='about')
|
147
|
171
|
|
def about ():
|
148
|
172
|
|
"""
|
394
|
418
|
|
if about is None or email is None:
|
395
|
419
|
|
redirect (application.get_url ('user'))
|
396
|
420
|
|
|
|
421
|
+ |
# TODO check unique value of emails
|
397
|
422
|
|
database.update_user (user['id'], about, email, False)
|
398
|
423
|
|
|
399
|
424
|
|
redirect (application.get_url ('user'))
|
+1/-1
M freepost/templates/homepage.html
45
|
45
|
|
|
46
|
46
|
|
<div class="topics">
|
47
|
47
|
|
{% for topic in topics %}
|
48
|
|
- |
<a href="" class="topic">{{ topic }}</a>
|
|
48
|
+ |
<a href="{{ url ('topic', name=topic) }}" class="topic">{{ topic }}</a>
|
49
|
49
|
|
{% endfor %}
|
50
|
50
|
|
</div>
|
51
|
51
|
|
|