Skip to content

Commit 80a8fbd

Browse files
author
zjtang
committed
fix posts_by_author bug, add wechat QR code on post and about page
1 parent a933825 commit 80a8fbd

File tree

7 files changed

+49
-11
lines changed

7 files changed

+49
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ static/upload/*.jpeg
88
static/upload/*.git
99
static/upload/*.bmp
1010
static/upload/*.webp
11+
.DS_Store

ezBlog.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
app.config["SECRET_KEY"] = "ezBlog" # for WTF-forms and login
2121
app.config["BLOGGING_URL_PREFIX"] = "/blog"
2222
app.config["BLOGGING_SITEURL"] = "http://traceme.space"
23-
app.config["BLOGGING_AUTHOR"] = "Ziv"
23+
app.config["BLOGGING_AUTHOR"] = "Ziv & Ada"
2424
app.config["BLOGGING_SITENAME"] = "ezBlog"
2525
app.config["FILEUPLOAD_IMG_FOLDER"] = "data/img" #img will not upload here, i do not know why
2626
app.config["FILEUPLOAD_PREFIX"] = "/fileupd"
@@ -120,4 +120,4 @@ def logout():
120120
context = ('server.crt', 'server.key')
121121
app.run(debug=True, host='::', port=443, use_reloader=True, ssl_context=context)
122122
else:
123-
app.run(debug=True, host='::', port=8000, use_reloader=True)
123+
app.run(debug=True, host='::', port=80, use_reloader=True)

flask_blogging/views.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,20 @@ def archives(count, page):
203203
all_posts = storage.get_posts(count=None, offset=None, include_draft=False,
204204
tag=None, user_id=None, recent=True)
205205
max_posts = meta["max_posts"]
206-
for post in all_posts:
207-
if meta["is_user_blogger"] is False and post["public"] is 0:
208-
max_posts -= 1
209-
meta["max_posts"] = max_posts
210206
uid = None
211207
try:
212208
uid = current_user.id
213209
except AttributeError:
214210
uid = None
211+
for post in all_posts:
212+
if int(post["user_id"]) != uid and post["public"] is 0:
213+
max_posts -= 1
214+
meta["max_posts"] = max_posts
215215
for post in posts:
216+
if int(post["user_id"]) != uid and post["public"] is 0:
217+
post["display"] = False
218+
else:
219+
post["display"] = True
216220
year = post["post_date"].strftime("%Y")
217221
if year not in year_dict:
218222
year_dict[year] = []
@@ -285,7 +289,7 @@ def page_by_id(post_id, slug):
285289
meta=meta, tags=tags, prev_post=prev_post,next_post=next_post)
286290
else:
287291
flash("You do not have the rights to view this post!", "warning")
288-
return redirect(url_for("blogging.archives"))
292+
return redirect(url_for("blogging.index"))
289293
else:
290294
flash("The page you are trying to access is not valid!", "warning")
291295
return redirect(url_for("blogging.index"))
@@ -348,9 +352,18 @@ def posts_by_author(user_id, count, page):
348352
render = config.get("BLOGGING_RENDER_TEXT", True)
349353
posts_by_author_fetched.send(blogging_engine.app, engine=blogging_engine,
350354
posts=posts, meta=meta)
355+
uid = None
356+
try:
357+
uid = current_user.id
358+
except AttributeError:
359+
uid = None
351360
if len(posts):
352361
for post in posts:
353362
blogging_engine.process_post(post, render=render)
363+
if int(post["user_id"]) != uid and post["public"] is 0:
364+
post["display"] = False
365+
else:
366+
post["display"] = True
354367
posts_by_author_processed.send(blogging_engine.app,
355368
engine=blogging_engine, posts=posts,
356369
meta=meta)

templates/blogging/about.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,19 @@ <h1 class="post-title">
2424
关于
2525
</h1>
2626
<div class="post-content">
27-
<h4>{{config.BLOGGING_AUTHOR}}</h4>
27+
<h4>Ziv</h4>
2828
<p>
29-
程序猿一枚。主攻C、Python、Go语言
29+
程序猿一枚。主攻C、Python、Go语言,目前从事SDN、NFV相关开发工作。
30+
<br />
31+
微信:
32+
<img src="/static/upload/Wechat-ziv.png" alt="" style="width:30%">
33+
</p>
34+
<h4>Ada</h4>
35+
<p>
36+
语音处理算法工程师。熟悉Python、Shell、Kaldi。
37+
<br />
38+
微信:
39+
<img src="/static/upload/Wechat-ada.png" alt="" style="width:30%">
3040
</p>
3141
</div>
3242
</div>

templates/blogging/archives.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ <h2>{{ year.year }}</h2>
3636
<ul class="listing">
3737
{% for post in year.posts %}
3838
{% if ((meta.is_user_blogger) or (post.public)) %}
39+
{% if post.display %}
3940
<li>
4041
<span class="date">{{post.post_date.strftime('%Y.%m.%d')}}</span>
4142
<a href="{{post.url}}"
4243
title="{{post.title}}">{{post.title}}</a>
4344
</li>
4445
{% endif %}
46+
{% endif %}
4547
{% endfor %}
4648
</ul>
4749
{% endfor %}

templates/blogging/base.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,17 @@ <h1 class="hidden">ezBlog</h1>
6161
{% block sidebar %}
6262
{% endblock sidebar %}
6363
<div class="pure-u-1">
64+
<br />
6465
<div id="footer">
65-
Copyright © 2018 <a href="/" rel="nofollow" style="color:gray">{{config.BLOGGING_AUTHOR}}</a> |
66-
<a rel="nofollow" target="_blank" href="{{config.BLOGGING_SITEURL}}" style="color:gray">Personal BLog</a>
66+
Copyright © 2018
67+
<a href="{{url_for("blogging.about")}}" rel="nofollow" style="color:gray">{{config.BLOGGING_AUTHOR}}</a>
68+
| Powered by
69+
<a href="http://flask.pocoo.org/" rel="nofollow" target="_blank" style="color:gray">flask</a>
70+
&
71+
<a href="https://flask-blogging.readthedocs.io/en/latest/" rel="nofollow" target="_blank" style="color:gray">flask_blogging</a>
72+
&
73+
<a href="http://pandao.github.io/editor.md/" rel="nofollow" target="_blank" style="color:gray">editor.md</a>
74+
| Theme maupassant
6775
<br>
6876
</div>
6977
</div>

templates/blogging/page.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ <h1 class="post-title">
6868
{% endif %}
6969
</div>
7070
<hr>
71+
<div style="text-align:center">
72+
<p>如果你喜欢本篇文章,欢迎赞赏作者请他(她)喝杯咖啡!</p>
73+
<img src="/static/upload/Wechat-zs-{{post.user_name}}.png" alt="">
74+
</div>
7175
<nav class="page-navigator">
7276
{% if prev_post %}
7377
<a class="extend prev" rel="prev" href="{{prev_post.url}}">上一篇:{{prev_post.title}}</a>

0 commit comments

Comments
 (0)