From d8daeff8fcc35dbdbcfc016f1a8b1c60001d481f Mon Sep 17 00:00:00 2001 From: Tdxdxoz Date: Sun, 16 Aug 2020 17:02:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=9F=BA=E6=9C=AC=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ask.py | 23 ++++++++++++++++++++--- templates/inbox.html | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/ask.py b/ask.py index 350e6c4..df5f617 100644 --- a/ask.py +++ b/ask.py @@ -116,8 +116,7 @@ def inbox(acct, secr): @app.route('/askMe///new', methods=['POST']) def new_question(acct, secr): - u = User.query.filter_by(acct=acct, secr=secr).first() - if not u: + if not User.query.filter_by(acct=acct, secr=secr).first(): abort(404) content = request.form.get('question') @@ -126,7 +125,7 @@ def new_question(acct, secr): abort(422) - toot = th.status_post(f"@{acct} 叮~ 有新提问了 回复“删除”以永久删除该提问(第一次被点开时实际执行删除),回复其他均视为回答该提问。可以回复多条,可以随时删除/重新编辑你的回复,可以@其他社友加入对话。\n\n{content}", visibility='direct') + toot = th.status_post(f"@{acct} 叮~ 有新提问 (戳我头像了解如何回复) 。\n\n{content}", visibility='direct') if not toot: abort(500) @@ -138,5 +137,23 @@ def new_question(acct, secr): return redirect(".") +@app.route('/askMe///') +def question_info(acct, secr, toot): + if not User.query.filter_by(acct=acct, secr=secr).first() or not Question.query.filter_by(acct=acct, toot=toot): + abort(404) + + context = th.status_context(toot) + replies = [ + { + 'disp': t.account.display_name, + 'url': t.account.url, + 'content': h2t.handle(t.content).replace(BOT_NAME,'').strip(), + 'time': str(t.created_at) + } + for t in context.descendants + ] + print(replies) + return {'replies': replies} + if __name__ == '__main__': app.run(debug=True) diff --git a/templates/inbox.html b/templates/inbox.html index bc60549..c6cef8a 100644 --- a/templates/inbox.html +++ b/templates/inbox.html @@ -18,6 +18,19 @@ border-radius: .5rem; margin: 25px 0; } + pre { + margin: 15px 0 0 15px; + } + .timeago { + font-size: 0.5em; + text-align: right; + } + .display_name { + margin: 0; + } + .card-body { + padding: 0.75em; + } @@ -53,7 +66,7 @@