diff --git a/app.py b/app.py index bf32961..bf82dd0 100644 --- a/app.py +++ b/app.py @@ -37,24 +37,10 @@ class Candidate(db.Model): db.create_all() -@app.route('/js/') -def send_js(path): - return send_from_directory('static/js', path) -@app.route('/img/') -def send_img(path): - return send_from_directory('static/img', path) - @app.route('/ordinary/') -def inbox(): - - cans = [{ - 'content': c.content, - 'url' : c.url, - 'toot': c.toot, - 'time': c.time.replace(tzinfo=tzlocal()) - } for c in Candidate.query.all() - ] - +def list(): + pag = Candidate.query.order_by(db.desc('id')).paginate(max_per_page=100) + vs = [{ 'name': name, 'ques': ques, @@ -62,7 +48,7 @@ def inbox(): } for name, ques, hint, ans in C.verify ] - return render_template('inbox.html', cans=cans, vs=vs) + return render_template('list.html', pagination=pag, vs=vs) @app.route('/ordinary/new', methods=['POST']) @limiter.limit("5 / hour; 1 / 2 second") @@ -78,10 +64,9 @@ def new_one(): if url and not re.match('https://(cloud\.tsinghua\.edu\.cn/f/[0-9a-z]+/(\?dl=1)?)|(closed\.social/safeShare/\d([a-zA-Z]+)?)', url): abort(422) if not Candidate.query.filter_by(content=content).first(): - toot = th.status_post( f"叮~ 有新的自荐报名(大家可以直接在此处评论):\n\n{content}", - visibility='unlisted' + visibility='unlisted' ) c = Candidate(content=content, url=url, toot=toot.id, time = datetime.now()) diff --git a/templates/inbox.html b/templates/list.html similarity index 87% rename from templates/inbox.html rename to templates/list.html index 05fc3fa..17d1ca9 100644 --- a/templates/inbox.html +++ b/templates/list.html @@ -49,6 +49,13 @@ padding-top: 110px; width: 100%; } + .footer { + background: #3338; + text-align: center; + font-size: 80%; + border-top: solid 1px white; + padding-top: 10px; + } @keyframes downn { 0% { transform: translate(0px, -5px); @@ -124,7 +131,7 @@

已有的报名

- {% for c in cans %} + {% for c in pagination.items %}
{{c.content}}
{% if c.url %} @@ -145,6 +152,30 @@
{% endfor %} +