diff --git a/.gitignore b/.gitignore index 75569aa..5cbe4d1 100755 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ databases/* # flask folder -mirrors/* +folders/* blueprint/kami_views.py blueprint/massage_views.py templates/kami/* diff --git a/blueprint/blog_views.py b/blueprint/blog_views.py index d41e8a1..74d6762 100755 --- a/blueprint/blog_views.py +++ b/blueprint/blog_views.py @@ -21,21 +21,21 @@ def get_message_db_conn(): blog_bp = Blueprint('blog', __name__) -index_path = '/var/open-ww3-project-ww3-tw/mirrors/' +index_path = '/var/open-ww3-project-ww3-tw/folders/' index = AutoIndex(blog_bp, browse_root=index_path, add_url_rules=False) # 重定向 -@blog_bp.route('/mirrors/re/') +@blog_bp.route('/folders/re/') def re(): return('404 not found
这是你不该知道的地方
') -@blog_bp.route('/mirrors/paint/2024.2.13/临摹出来的乐色/不好说的人物/') -@blog_bp.route('/mirrors/paint/2024.2.13/临摹出来的乐色/不好说的人物/') +@blog_bp.route('/folders/paint/2024.2.13/临摹出来的乐色/不好说的人物/') +@blog_bp.route('/folders/paint/2024.2.13/临摹出来的乐色/不好说的人物/') def no_say_man(subpath=None): return redirect(url_for('blog.re')) -@blog_bp.route('/mirrors/game/') -@blog_bp.route('/mirrors/game/') +@blog_bp.route('/folders/game/') +@blog_bp.route('/folders/game/') def no_game(subpath=None): return redirect(url_for('blog.re')) # 重定向 @@ -143,11 +143,11 @@ def test_db(): @blog_bp.route('/robots.txt/') def robots(): - return send_from_directory(current_app.static_folder, 'robots.txt') + return send_from_directory(current_app.static_folders, 'robots.txt') @blog_bp.route('/google02f6a3f6004a32c6.html') def google02f6a3f6004a32c6(): - return send_from_directory(blog_bp.static_folder, 'google02f6a3f6004a32c6.html') + return send_from_directory(blog_bp.static_folders, 'google02f6a3f6004a32c6.html') @blog_bp.route('/sitemap.xml/') @@ -165,10 +165,10 @@ def sitemap(): def kami(): return redirect(url_for('kami.home')) -@blog_bp.route('/mirrors/') -@blog_bp.route('/mirrors/') +@blog_bp.route('/folders/') +@blog_bp.route('/folders/') def autoindex(path='.'): - return index.render_autoindex(path, template='blog/mirrors.html') + return index.render_autoindex(path, template='blog/folders.html') @blog_bp.route('/upload/', methods=['POST' , 'GET']) @@ -187,19 +187,8 @@ def upload(): def messages(): return render_template('message/home.html') -@blog_bp.route('/paint/') -def paint(): - paint_path = "/var/open-ww3-project-ww3-tw/static/upload/paint_data" - paint_json = f"{paint_path}/paint.json" - paint_open = json.load(open(paint_json, 'r', encoding='utf-8')) - return render_template('blog/paint.html', paint_open=paint_open) -@blog_bp.route('/paint/upload/', methods=['POST',]) -def paint_upload(): - if request.method == "POST": - return "POST" - -@blog_bp.route('/new_page/') -@blog_bp.route('/new_page//') -def new_page(page_name=None): - return send_from_directory(os.path.join(current_app.static_folder, 'new_page'), f'{page_name}.html') +@blog_bp.route('/class') +def class_page(): +# return ("this is Class_page") + return render_template('blog/class.html') diff --git a/blueprint/index_views.py b/blueprint/index_views.py index 2ea4b18..51ccf60 100644 --- a/blueprint/index_views.py +++ b/blueprint/index_views.py @@ -4,6 +4,15 @@ import os index_bp = Blueprint('/', __name__) +db_path = "/var/open-ww3-project-ww3-tw/databases/sqlite/owp.db" + +def get_paint_db_conn(): + conn = sqlite3.connect(db_path) + conn.row_factory = sqlite3.Row + return conn + + + @index_bp.route('/') def repage(): return redirect(url_for('blog.home')) @@ -14,4 +23,23 @@ def mirrors(): @index_bp.route('/greet//') def greet(name): - return f'Hello, {name}!' \ No newline at end of file + return f'Hello, {name}!' + +@index_bp.route('/paint/') +def paint_home(): + conn = get_paint_db_conn() + select_sql = "SELECT * FROM paint;" + data = conn.execute(select_sql).fetchall() + conn.close() + + # 展示图片 + img_url = "https://open-ww3-project.ww3.tw/blog/folders/paint/new/" + + # 查询tags和class + db_cursor = sqlite3.connect(db_path).cursor() + tags_sql = "SELECT DISTINCT tags FROM paint;" + class_sql = "SELECT DISTINCT class FROM paint;" + + for class_data in db_cursor.execute(class_sql).fetchall(): + for tags_data in db_cursor.execute(tags_sql).fetchall(): + return render_template('paint/home.html', data = data, tags_data = tags_data[0], class_data = class_data[0], img_url = img_url) \ No newline at end of file diff --git a/static/new_page/home.html b/static/new_page/home.html deleted file mode 100644 index 497db5c..0000000 --- a/static/new_page/home.html +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - Document - - - - - - - \ No newline at end of file diff --git a/templates/blog/class.html b/templates/blog/class.html new file mode 100644 index 0000000..86d836f --- /dev/null +++ b/templates/blog/class.html @@ -0,0 +1,24 @@ + + + 分类页面 | ww3 + + + this is Class_Page +
+
+ 这里是用来存放关于分类的页面 +
+
+ lfs +
+ 自建linux +
+ + + + diff --git a/templates/blog/mirrors.html b/templates/blog/folders.html similarity index 100% rename from templates/blog/mirrors.html rename to templates/blog/folders.html diff --git a/templates/blog/home.html b/templates/blog/home.html index 6018842..504be7a 100644 --- a/templates/blog/home.html +++ b/templates/blog/home.html @@ -102,7 +102,7 @@
来源: https://greendam.icu/ - +

diff --git a/templates/blog/include/navbar.html b/templates/blog/include/navbar.html index 6a5990a..f4a9965 100644 --- a/templates/blog/include/navbar.html +++ b/templates/blog/include/navbar.html @@ -4,7 +4,7 @@ {"id":1, "name": "首页", "url": url_for('blog.home')}, {"id":2, "name": "关于", "url": url_for('blog.about')}, {"id":3, "name": "文章", "url": url_for('blog.posts_list')}, - {"id":4, "name": "mirrors", "url": url_for('blog.autoindex')}, + {"id":4, "name": "folders", "url": url_for('blog.autoindex')}, {"id":5, "name": "study", "url": url_for('study.home')}, ]%}

\ No newline at end of file + class + diff --git a/templates/blog/include/navbar2.html b/templates/blog/include/navbar2.html new file mode 100644 index 0000000..707e944 --- /dev/null +++ b/templates/blog/include/navbar2.html @@ -0,0 +1,20 @@ +{# navbar 部分 #} + +{% set navbar_list = [ + {"id":1, "name": "首页", "url": url_for('blog.home')}, + {"id":2, "name": "关于", "url": url_for('blog.about')}, + {"id":3, "name": "文章", "url": url_for('blog.posts_list')}, + {"id":4, "name": "folders", "url": url_for('blog.autoindex')}, + {"id":5, "name": "study", "url": url_for('study.home')}, +]%} + + diff --git a/templates/blog/include/wallpaper.html b/templates/blog/include/wallpaper.html index 20d3fa8..cb39ea1 100644 --- a/templates/blog/include/wallpaper.html +++ b/templates/blog/include/wallpaper.html @@ -1,8 +1,6 @@ {# 壁纸部分 #} {% set wallpaper_apis =[ - 'https://www.loliapi.com/acg/pc/', - 'https://api.sretna.cn/api/pc.php', - 'https://www.api.plus/api/dongman', + 'https://www.loliapi.com/acg/pc/', 'https://moe.jitsu.top/img/?sort=pc', 'https://www.dmoe.cc/random.php', 'https://api.mtyqx.cn/tapi/random.php'] %} diff --git a/templates/paint/home.html b/templates/paint/home.html new file mode 100644 index 0000000..03a95ac --- /dev/null +++ b/templates/paint/home.html @@ -0,0 +1,53 @@ +{# 引入base #} +{% extends 'blog/extension/base.html' %} + +{% include 'blog/include/head.html' %} + + + + +{# 引入标题 #} +{% block title %}paint{% endblock %} + +{% block content %} + + + + +
+ {% include 'blog/include/navbar2.html' %} +
+ 返回主页 +

这里是关于本人的绘画学习及其临摹的记录和展示页面

+
+ 旧作列表 +
+ {% for data in data %} +
+ {{data['name']}} +
+ {{data['name']}}__ + {{data['date']}} + {% endfor %} +
+
+ + + + +{% endblock %} \ No newline at end of file