From 7941e5d1eb8526b38d8234127c66aa885f8df5c5 Mon Sep 17 00:00:00 2001 From: Awoodwhale Date: Thu, 23 Mar 2023 17:34:37 +0800 Subject: [PATCH] fix: fix the way to show article title --- app/admin_service.py | 16 ++++++++++------ app/templates/admin_manage_article.html | 16 +++++++++------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/app/admin_service.py b/app/admin_service.py index 35e032c..9cbb75e 100644 --- a/app/admin_service.py +++ b/app/admin_service.py @@ -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"), diff --git a/app/templates/admin_manage_article.html b/app/templates/admin_manage_article.html index d90af50..ed058de 100644 --- a/app/templates/admin_manage_article.html +++ b/app/templates/admin_manage_article.html @@ -66,14 +66,16 @@ {% for text in text_list %}
-
{{ text.source }}
- Date:{{ text.date }} Level:{{ text.level }} +
{{ text.title }}
+ 删除
-
- 删除文章 -
-

{{ text.text }}

+
{{ text.source }}
+
+ Level:{{text.level }} + Date:{{ text.date }} +
+

{{ text.text }}

{% endfor %}