forked from mrlan/EnglishPal
fix: fix the way to show article title
parent
2cf65123e9
commit
7941e5d1eb
|
@ -43,20 +43,24 @@ def article():
|
|||
if is_admin != "pass":
|
||||
return is_admin
|
||||
|
||||
article_number = get_number_of_articles()
|
||||
_article_number = get_number_of_articles()
|
||||
try:
|
||||
_page_size = min(
|
||||
max(1, int(request.args.get("size", 5))), article_number
|
||||
max(1, int(request.args.get("size", 5))), _article_number
|
||||
) # 最小的size是1
|
||||
_cur_page = min(
|
||||
max(1, int(request.args.get("page", 1))), article_number // _page_size + 1
|
||||
max(1, int(request.args.get("page", 1))), _article_number // _page_size + 1
|
||||
) # 最小的page是1
|
||||
except ValueError:
|
||||
return "page parmas must be int!"
|
||||
|
||||
|
||||
_articles = get_page_articles(_cur_page, _page_size)
|
||||
for article in _articles: # 获取每篇文章的title
|
||||
article.title = article.text.split("\n")[0]
|
||||
|
||||
context = {
|
||||
"article_number": article_number,
|
||||
"text_list": get_page_articles(_cur_page, _page_size),
|
||||
"article_number": _article_number,
|
||||
"text_list": _articles,
|
||||
"page_size": _page_size,
|
||||
"cur_page": _cur_page,
|
||||
"username": session.get("username"),
|
||||
|
|
|
@ -66,14 +66,16 @@
|
|||
{% for text in text_list %}
|
||||
<div class="list-group-item list-group-item-action" aria-current="true">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h5 class="mb-1">{{ text.source }}</h5>
|
||||
<small>Date:{{ text.date }} Level:{{ text.level }}</small>
|
||||
<h5 class="mb-1">{{ text.title }}</h5>
|
||||
<a type="button" href="/admin/article?delete_id={{text.article_id}}"
|
||||
class="btn btn-outline-danger btn-sm">删除</a>
|
||||
</div>
|
||||
<div style="text-align: right; padding-bottom: 5px;"><a href="/admin/article?delete_id={{text.article_id}}"
|
||||
class="btn btn-outline-danger btn-sm">
|
||||
删除文章
|
||||
</a></div>
|
||||
<p class="mb-1">{{ text.text }}</p>
|
||||
<div><small>{{ text.source }}</small></div>
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<small>Level:{{text.level }}</small>
|
||||
<small>Date:{{ text.date }}</small>
|
||||
</div>
|
||||
<p style="padding-top: 5px;" class="mb-1">{{ text.text }}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue