From a79dc7742bb75a5d4a105865ad9bf12e18a3b48f Mon Sep 17 00:00:00 2001 From: cube Date: Fri, 1 May 2026 00:37:20 +0100 Subject: [PATCH] fix #5 --- myriad/home.py | 3 ++- myriad/manage.py | 34 ++++++++++++++++++++++++++++++- myriad/templates/manage/edit.html | 30 +++++++++++++++++++++++++++ myriad/templates/page.html | 7 +++++++ 4 files changed, 72 insertions(+), 2 deletions(-) diff --git a/myriad/home.py b/myriad/home.py index b16fefd..8cfcdb2 100644 --- a/myriad/home.py +++ b/myriad/home.py @@ -70,12 +70,13 @@ def page(mid): blinkies = db.execute("SELECT blinkie_location FROM blinkies WHERE member_id=(?)",(mid,)).fetchall() stamps = db.execute("SELECT stamp_location FROM stamps WHERE member_id=(?)",(mid,)).fetchall() blog_public = db.execute("SELECT * FROM blog WHERE member_id=(?) AND public=(?)",(mid,1)).fetchall() + sections = db.execute("SELECT * FROM sections WHERE member_id=(?) ORDER BY position ASC",(mid,)).fetchall() blog_public_show = False if len(blog_public) > 0: blog_public_show = True - return render_template('page.html', member=member, blog=blog, icon=icon, all_icons=all_icons, blinkies=blinkies, stamps=stamps, blog_public_show=blog_public_show) + return render_template('page.html', member=member, blog=blog, icon=icon, all_icons=all_icons, blinkies=blinkies, stamps=stamps, blog_public_show=blog_public_show, sections=sections) @bp.route("/groups") def groups(): diff --git a/myriad/manage.py b/myriad/manage.py index 15dee7b..8e5001d 100644 --- a/myriad/manage.py +++ b/myriad/manage.py @@ -150,11 +150,32 @@ def edit(mid): edit_location = "stamps" + if "new_section" in request.form: + section_title = request.form["section_title"] + section_content = request.form["section_content"] + + db.execute("INSERT INTO sections (member_id, title, content) VALUES (?, ?, ?)", (mid, section_title, section_content)) + db.commit() + + edit_location = "sections" + + if "update_section" in request.form: + section_id = request.form["section_id"] + section_title = request.form["section_title"] + section_content = request.form["section_content"] + section_position = request.form["section_pos"] + + db.execute("UPDATE sections SET title=(?), content=(?), position=(?) WHERE id=(?)",(section_title, section_content, section_position, section_id)) + db.commit() + + edit_location = "sections" + member = db.execute("SELECT * FROM member WHERE id=(?)",(mid,)).fetchone() icons = db.execute("SELECT * FROM icons WHERE member_id=(?)",(mid,)).fetchall() blinkies = db.execute("SELECT * FROM blinkies WHERE member_id=(?)",(mid,)).fetchall() stamps = db.execute("SELECT * FROM stamps WHERE member_id=(?)",(mid,)).fetchall() + sections = db.execute("SELECT * FROM sections WHERE member_id=(?)",(mid,)).fetchall() groups = db.execute("SELECT * FROM groups").fetchall() member_groups = db.execute("SELECT * FROM group_members WHERE member_id=(?)",(mid,)).fetchall() @@ -174,7 +195,18 @@ def edit(mid): themes = os.listdir(current_app.config["THEMES_FOLDER"]) - return render_template("manage/edit.html", member=member, icons=icons, unjoined_groups=unjoined_groups, joined_groups=joined_groups, themes=themes, edit_location=edit_location, blinkies=blinkies, stamps=stamps) + return render_template("manage/edit.html", member=member, icons=icons, unjoined_groups=unjoined_groups, joined_groups=joined_groups, themes=themes, edit_location=edit_location, blinkies=blinkies, stamps=stamps, sections=sections) + + +@bp.route("/delete_section/") +@login_required +def delete_section(sid): + db = get_db() + mid = db.execute("SELECT member_id FROM sections WHERE id=(?)",(sid,)).fetchone()[0] + db.execute("DELETE FROM sections WHERE id=(?)",(sid,)) + db.commit() + + return redirect(url_for("manage.edit", mid=mid)) @bp.route("/set_main_icon//") @login_required diff --git a/myriad/templates/manage/edit.html b/myriad/templates/manage/edit.html index fda9bdc..a069203 100644 --- a/myriad/templates/manage/edit.html +++ b/myriad/templates/manage/edit.html @@ -147,6 +147,36 @@ +
+ +
Custom Page Sections
+

Here you can make sections for your page, embed whatever you like

+
+ +
+ +

+ +
+ +
+ + {% for section in sections %} +
+ +
+ +
+ +

+ + +
+ + Delete section + + {% endfor %} +
Manage Member Data
Export Fields
diff --git a/myriad/templates/page.html b/myriad/templates/page.html index 955c792..1645050 100644 --- a/myriad/templates/page.html +++ b/myriad/templates/page.html @@ -53,6 +53,13 @@ {% endif %} {% endif %} + {% for section in sections %} + {% if section[2] %}
{{ section[2] }}
{% endif %} +
+ {{ section[3].replace('\n', '
')|safe }} +
+ {% endfor %} +