Author
|
zPlus <zplus@peers.community>
2019-01-11 20:34:14
|
Committer
|
zPlus <zplus@peers.community>
2019-01-11 20:34:14
|
Commit
|
885970c
(patch)
|
Tree
|
b18e436
|
Parent(s)
|
|
Fix #81 homepage link on top.
commits diff:
454d20a..885970c
6 files changed,
46 insertions,
16 deletions
โ
download
Diffstat
Diff options
+10/-3
M freepost/__init__.py
207
|
207
|
|
# Start new session
|
208
|
208
|
|
session.start (user['id'], remember)
|
209
|
209
|
|
|
210
|
|
- |
# Go to user homepage
|
211
|
|
- |
redirect (application.get_url ('homepage'))
|
|
210
|
+ |
# Redirect logged in user to preferred feed
|
|
211
|
+ |
if user['preferred_feed'] == 'new':
|
|
212
|
+ |
redirect (application.get_url ('homepage') + '?sort=new')
|
|
213
|
+ |
else:
|
|
214
|
+ |
redirect (application.get_url ('homepage'))
|
212
|
215
|
|
|
213
|
216
|
|
@get ('/register', name='register')
|
214
|
217
|
|
@requires_logout
|
406
|
409
|
|
|
407
|
410
|
|
about = request.forms.getunicode ('about')
|
408
|
411
|
|
email = request.forms.getunicode ('email')
|
|
412
|
+ |
preferred_feed = request.forms.getunicode ('preferred_feed')
|
409
|
413
|
|
|
410
|
414
|
|
if about is None or email is None:
|
411
|
415
|
|
redirect (application.get_url ('user_settings'))
|
412
|
416
|
|
|
|
417
|
+ |
if preferred_feed not in [ 'hot', 'new' ]:
|
|
418
|
+ |
preferred_feed = 'hot'
|
|
419
|
+ |
|
413
|
420
|
|
# Update user info in the database
|
414
|
|
- |
database.update_user (user['id'], about, email, False)
|
|
421
|
+ |
database.update_user (user['id'], about, email, False, preferred_feed)
|
415
|
422
|
|
|
416
|
423
|
|
redirect (application.get_url ('user_settings'))
|
417
|
424
|
|
|
+5/-3
M freepost/database.py
266
|
266
|
|
return cursor.fetchall ()
|
267
|
267
|
|
|
268
|
268
|
|
# Update user information
|
269
|
|
- |
def update_user (user_id, about, email, email_notifications):
|
|
269
|
+ |
def update_user (user_id, about, email, email_notifications, preferred_feed):
|
270
|
270
|
|
cursor = db.cursor (MySQLdb.cursors.DictCursor)
|
271
|
271
|
|
|
272
|
272
|
|
# Update user info, but not email address
|
274
|
274
|
|
"""
|
275
|
275
|
|
UPDATE user
|
276
|
276
|
|
SET about = %(about)s,
|
277
|
|
- |
email_notifications = %(notifications)s
|
|
277
|
+ |
email_notifications = %(notifications)s,
|
|
278
|
+ |
preferred_feed = %(preferred_feed)s
|
278
|
279
|
|
WHERE id = %(user)s
|
279
|
280
|
|
""",
|
280
|
281
|
|
{
|
281
|
282
|
|
'about': about,
|
282
|
283
|
|
'notifications': email_notifications,
|
283
|
|
- |
'user': user_id
|
|
284
|
+ |
'user': user_id,
|
|
285
|
+ |
'preferred_feed': preferred_feed
|
284
|
286
|
|
}
|
285
|
287
|
|
)
|
286
|
288
|
|
|
+9/-6
M freepost/templates/banner.html
2
|
2
|
|
# on special occasions.
|
3
|
3
|
|
#}
|
4
|
4
|
|
|
|
5
|
+ |
{#
|
5
|
6
|
|
<div class="bg-green" style="margin: 0 0 2em 0; padding: .5em;">
|
6
|
7
|
|
<img alt="" title="" src="images/pulse.gif" style="height: 1em;" />
|
7
|
8
|
|
<a href="https://fosdem.org/2018/schedule/streaming/">FOSDEM 2018</a>
|
8
|
9
|
|
</div>
|
|
10
|
+ |
#}
|
9
|
11
|
|
|
10
|
12
|
|
{# Welcome New Year.
|
11
|
13
|
|
# To maintain alignment, keep al lines below of the same length
|
12
|
14
|
|
# and with no padding.
|
13
|
15
|
|
#}
|
|
16
|
+ |
{#
|
14
|
17
|
|
<pre class="new_year">
|
15
|
18
|
|
.''.
|
16
|
19
|
|
. *''* :_\/_:
|
20
|
23
|
|
*_\/_* -= o =- /)\
|
21
|
24
|
|
* /\ * .'/.\'. '
|
22
|
25
|
|
*..* :
|
23
|
|
- |
___ ___ __ ___
|
24
|
|
- |
|__ \ / _ \/_ |/ _ \
|
25
|
|
- |
) | | | || | (_) |
|
26
|
|
- |
/ /| | | || |> _ <
|
27
|
|
- |
/ /_| |_| || | (_) |
|
28
|
|
- |
|____|\___/ |_|\___/
|
|
26
|
+ |
____ ___ _ ___
|
|
27
|
+ |
|___ \ / _ \/ |/ _ \
|
|
28
|
+ |
__) | | | | | (_) |
|
|
29
|
+ |
/ __/| |_| | |\__, |
|
|
30
|
+ |
|_____|\___/|_| /_/
|
29
|
31
|
|
</pre>
|
|
32
|
+ |
#}
|
+1/-1
M freepost/templates/homepage.html
6
|
6
|
|
|
7
|
7
|
|
{% block content %}
|
8
|
8
|
|
|
9
|
|
- |
{# include 'banner.html' #}
|
|
9
|
+ |
{% include 'banner.html' %}
|
10
|
10
|
|
|
11
|
11
|
|
{% include 'posts.html' %}
|
12
|
12
|
|
|
+3/-3
M freepost/templates/layout.html
29
|
29
|
|
topic / {{ topic }}
|
30
|
30
|
|
</a>
|
31
|
31
|
|
{% else %}
|
32
|
|
- |
<a href="{{ url ('homepage') }}" class="flex-item logo">
|
|
32
|
+ |
<a href="{{ url ('homepage') }}{{ '?sort=new' if user and user.preferred_feed == 'new' }}" class="flex-item logo">
|
33
|
33
|
|
free
|
34
|
34
|
|
<img alt="๐ต " title="freepost" src="/images/freepost.png" class="monkey" />
|
35
|
35
|
|
post
|
49
|
49
|
|
topic / {{ topic }}
|
50
|
50
|
|
</a>
|
51
|
51
|
|
{% else %}
|
52
|
|
- |
<a href="{{ url ('homepage') }}" class="flex-item logo">
|
|
52
|
+ |
<a href="{{ url ('homepage') }}{{ '?sort=new' if user and user.preferred_feed == 'new' }}" class="flex-item logo">
|
53
|
53
|
|
freepost
|
54
|
54
|
|
</a>
|
55
|
55
|
|
{% endif %}
|
56
|
56
|
|
|
57
|
|
- |
<a href="{{ url ('homepage') }}" class="flex-item logo">
|
|
57
|
+ |
<a href="{{ url ('homepage') }}{{ '?sort=new' if user and user.preferred_feed == 'new' }}" class="flex-item logo">
|
58
|
58
|
|
<img alt="๐ต " title="freepost" src="/images/freepost.png" class="monkey" />
|
59
|
59
|
|
</a>
|
60
|
60
|
|
</div>
|
+18/-0
M freepost/templates/user_settings.html
50
|
50
|
|
</div>
|
51
|
51
|
|
|
52
|
52
|
|
<div>
|
|
53
|
+ |
Preferred feed
|
|
54
|
+ |
</div>
|
|
55
|
+ |
<div>
|
|
56
|
+ |
<p>
|
|
57
|
+ |
<label>
|
|
58
|
+ |
<input type="radio" name="preferred_feed" value="hot" {{ 'checked="checked"' if user.preferred_feed == 'hot' }}>
|
|
59
|
+ |
Hot
|
|
60
|
+ |
</label>
|
|
61
|
+ |
</p>
|
|
62
|
+ |
<p>
|
|
63
|
+ |
<label>
|
|
64
|
+ |
<input type="radio" name="preferred_feed" value="new" {{ 'checked="checked"' if user.preferred_feed == 'new' }}>
|
|
65
|
+ |
New
|
|
66
|
+ |
</label>
|
|
67
|
+ |
</p>
|
|
68
|
+ |
</div>
|
|
69
|
+ |
|
|
70
|
+ |
<div>
|
53
|
71
|
|
</div>
|
54
|
72
|
|
<div>
|
55
|
73
|
|
<input type="submit" name="update" value="Update" class="button button_info" />
|