Browse Source

分页,界面

fudan
欧醚 3 years ago
parent
commit
cfbbd925dd
Signed by: OmmyZhang GPG Key ID: 757D312E7C9D13F7
2 changed files with 37 additions and 21 deletions
  1. +5
    -20
      app.py
  2. +32
    -1
      templates/list.html

+ 5
- 20
app.py View File

@ -37,24 +37,10 @@ class Candidate(db.Model):
db.create_all()
@app.route('/js/<path:path>')
def send_js(path):
return send_from_directory('static/js', path)
@app.route('/img/<path:path>')
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())

templates/inbox.html → templates/list.html View File

@ -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 @@
<br/>
<h3>已有的报名</h3>
{% for c in cans %}
{% for c in pagination.items %}
<div class="qbox">
<pre class="inner">{{c.content}}</pre>
{% if c.url %}
@ -145,6 +152,30 @@
</div>
{% endfor %}
<nav>
<ul class="pagination">
{%- for page in pagination.iter_pages() %}
{% if page %}
{% if page != pagination.page %}
<li class="page-item"><a class="page-link" href="{{ url_for('list', page=page, per_page=pagination.per_page ) }}">{{ page }}</a></li>
{% else %}
<li class="page-item active">
<a class="page-link" href="#">{{ page }}<span class="sr-only">(current)</span></a>
</li>
{% endif %}
{% else %}
<li class="page-item"><span class=ellipsis></span></li>
{% endif %}
{%- endfor %}
</div>
<div class="footer">
<p>
<a href="//closed.social" target="_blank">闭社</a>提供技术支持。本报名系统以AGPL协议开源于<a href="//git.closed.social/closed-social/ordinary" target="_blank">碧茶</a>
</p>
<p> 🄯 2020 Copyleft: closed.social</p>
</div>
<script>
$('.timeago').timeago();
$('.collapse').on('show.bs.collapse', (e) => {

Loading…
Cancel
Save