From ce8b6facfa447c9b1af1ad83d34f5ffe17c4f718 Mon Sep 17 00:00:00 2001 From: cube Date: Sat, 21 Mar 2026 00:30:47 +0000 Subject: [PATCH] fix #4 --- .gitignore | 2 ++ README.md | 2 ++ myriad/home.py | 4 ++- myriad/manage.py | 52 ++++++++++++++++++++++++++--- myriad/schema.sql | 16 +++++++++ myriad/templates/manage/assets.html | 2 ++ myriad/templates/manage/edit.html | 41 +++++++++++++++++++---- myriad/templates/page.html | 18 +++++++++- 8 files changed, 124 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 84fddc9..2a919ee 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ dist/ build/ *.egg-info/ /myriad/static/icons +/myriad/static/blinkies +/myriad/static/stamps diff --git a/README.md b/README.md index 7c9d7d4..1e7813f 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ logged in users are presumed to all be admins with distinction only between bein in the blog view, member privacy outweighs individual post privacy. if a private member makes a public post, it will not show up in the public feed. however, if that member switches to public, their public posts will all become publicly viewable (but private posts will remain private). +the blinkies and stamps stuff is literally just because i want an easy way to upload them when i find them. and im the dev so i get to decide mwa ha ha + # dev set up (windows) - after cloning, run `py -3 -m venv .venv` in the root directory and then `.venv\Scripts\activate` diff --git a/myriad/home.py b/myriad/home.py index 163fcfb..7dbd7de 100644 --- a/myriad/home.py +++ b/myriad/home.py @@ -50,8 +50,10 @@ def page(mid): blog = db.execute("SELECT * FROM blog WHERE member_id=(?) ORDER BY created DESC",(mid,)).fetchall() icon = db.execute("SELECT icon_location FROM icons WHERE id=(?)",(member[6],)).fetchone() all_icons = db.execute("SELECT icon_location FROM icons WHERE member_id=(?)",(mid,)).fetchall() + 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() - return render_template('page.html', member=member, blog=blog, icon=icon, all_icons=all_icons) + return render_template('page.html', member=member, blog=blog, icon=icon, all_icons=all_icons, blinkies=blinkies, stamps=stamps) @bp.route("/groups") def groups(): diff --git a/myriad/manage.py b/myriad/manage.py index 80c9801..4788d7a 100644 --- a/myriad/manage.py +++ b/myriad/manage.py @@ -38,8 +38,10 @@ def delete(mid): @login_required def edit(mid): db = get_db() + edit_location=None if request.method == "POST": + if "name" in request.form: name = request.form['name'] bio = request.form['bio'] @@ -49,6 +51,8 @@ def edit(mid): db.execute("UPDATE member SET member_name=(?), bio=(?), subtitle=(?), public=(?), theme=(?) WHERE id=(?)",(name, bio, subtitle, privacy, theme, mid)) db.commit() + edit_location="details" + if "file" in request.files: # here we are just saving the uploaded file to the icons folder. # we're not going hard on security because we expect there to only be 1 admin @@ -56,22 +60,48 @@ def edit(mid): file = request.files["file"] filename = str(uuid.uuid4()) + "." + file.filename.split(".")[1] file.save(os.path.join(current_app.config["ICON_UPLOAD_FOLDER"], filename)) - db.execute("INSERT INTO icons (member_id, icon_location) VALUES (?, ?)", (mid, filename),) + db.execute("INSERT INTO icons (member_id, icon_location) VALUES (?, ?)", (mid, filename)) db.commit() + edit_location="icons" + if "gid_add" in request.form: gid = request.form["gid_add"] db.execute("INSERT INTO group_members (group_id,member_id) VALUES (?,?)",(gid,mid)) db.commit() + edit_location="groups" + elif "gid_remove" in request.form: gid = request.form["gid_remove"] db.execute("DELETE FROM group_members WHERE group_id=(?) AND member_id=(?)",(gid,mid)) db.commit() + edit_location="groups" + + if "blinkie" in request.files: + file = request.files["blinkie"] + filename = str(uuid.uuid4()) + "." + file.filename.split(".")[1] + file.save(os.path.join(current_app.config["BLINKIES_UPLOAD_FOLDER"], filename)) + db.execute("INSERT INTO blinkies (member_id, blinkie_location) VALUES (?, ?)", (mid, filename)) + db.commit() + + edit_location="blinkies" + + if "stamp" in request.files: + file = request.files["stamp"] + filename = str(uuid.uuid4()) + "." + file.filename.split(".")[1] + file.save(os.path.join(current_app.config["STAMPS_UPLOAD_FOLDER"], filename)) + db.execute("INSERT INTO stamps (member_id, stamp_location) VALUES (?, ?)", (mid, filename)) + db.commit() + + edit_location="stamps" + 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() groups = db.execute("SELECT * FROM groups").fetchall() member_groups = db.execute("SELECT * FROM group_members WHERE member_id=(?)",(mid,)).fetchall() @@ -91,7 +121,7 @@ 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) + 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) @bp.route("/set_main_icon//") @login_required @@ -164,10 +194,21 @@ def remove_home(mid,location): return redirect(url_for('home.full_list')) -@bp.route("/assets") +@bp.route("/assets", methods=('GET', 'POST')) @login_required def assets(): db = get_db() + + if "blinkie" in request.files: + file = request.files["blinkie"] + filename = file.filename + file.save(os.path.join(current_app.config["BLINKIES_UPLOAD_FOLDER"], filename)) + + if "stamp" in request.files: + file = request.files["stamp"] + filename = file.filename + file.save(os.path.join(current_app.config["STAMPS_UPLOAD_FOLDER"], filename)) + icons = db.execute("SELECT * FROM icons").fetchall() icon_storage = os.listdir(current_app.config["ICON_UPLOAD_FOLDER"]) @@ -188,7 +229,10 @@ def assets(): if not in_storage: unlinked_icons.append(i) - return render_template("manage/assets.html", icons=unlinked_icons, icon_storage=i_storage) + blinkies = os.listdir(current_app.config["BLINKIES_UPLOAD_FOLDER"]) + stamps = os.listdir(current_app.config["STAMPS_UPLOAD_FOLDER"]) + + return render_template("manage/assets.html", icons=unlinked_icons, icon_storage=i_storage, blinkies=blinkies, stamps=stamps) @bp.route("/delete_idb") @login_required diff --git a/myriad/schema.sql b/myriad/schema.sql index a958978..c9f1dc5 100644 --- a/myriad/schema.sql +++ b/myriad/schema.sql @@ -4,6 +4,8 @@ DROP TABLE IF EXISTS icons; DROP TABLE IF EXISTS groups; DROP TABLE IF EXISTS group_members; DROP TABLE IF EXISTS blog; +DROP TABLE IF EXISTS blinkies; +DROP TABLE IF EXISTS stamps; CREATE TABLE user ( id INTEGER PRIMARY KEY AUTOINCREMENT, @@ -57,4 +59,18 @@ CREATE TABLE blog ( content TEXT, public BOOLEAN NOT NULL DEFAULT 1, FOREIGN KEY (member_id) REFERENCES member (id) +); + +CREATE TABLE blinkies ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + member_id INTEGER NOT NULL, + blinkie_location TEXT NOT NULL, + FOREIGN KEY (member_id) REFERENCES member (id) +); + +CREATE TABLE stamps ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + member_id INTEGER NOT NULL, + stamp_location TEXT NOT NULL, + FOREIGN KEY (member_id) REFERENCES member (id) ); \ No newline at end of file diff --git a/myriad/templates/manage/assets.html b/myriad/templates/manage/assets.html index 76e7d0a..7782816 100644 --- a/myriad/templates/manage/assets.html +++ b/myriad/templates/manage/assets.html @@ -36,8 +36,10 @@ {% endif %}
Blinkies
+
Stamps
+ {% endblock %} \ No newline at end of file diff --git a/myriad/templates/manage/edit.html b/myriad/templates/manage/edit.html index 92f42b2..d98b1ad 100644 --- a/myriad/templates/manage/edit.html +++ b/myriad/templates/manage/edit.html @@ -7,13 +7,12 @@ {% block content %}
- View {{member[3]}}'s page
Edit Details
-
+
@@ -36,9 +35,10 @@ Delete member - WARNING: this is permanent and cannot be undone! +
Manage groups
- +
-
+
{% for icon in icons %} -
Set Main IconDelete Icon

- {% endfor %}
+ + +
Manage Blinkies
+
+ + +
+ + {% for blinkie in blinkies %} + + {% endfor %} + + +
Manage Stamps
+
+ + +
+ + {% for stamp in stamps %} + + {% endfor %} + + + + {% if edit_location %} + + {% endif %} +
{% endblock %} \ No newline at end of file diff --git a/myriad/templates/page.html b/myriad/templates/page.html index ff1eda7..52bbfdd 100644 --- a/myriad/templates/page.html +++ b/myriad/templates/page.html @@ -47,11 +47,27 @@ {% endif %} {% if all_icons|length > 1 %} -
{{member[3]}}'s icons
+
Icons
{% for i in all_icons %} {% endfor %} {% endif %} +
+ + {% if blinkies|length > 0 %} +
Blinkies
+ {% for blinkie in blinkies %} + + {% endfor %} + {% endif %} +
+ + {% if stamps|length > 0 %} +
Stamps
+ {% for stamp in stamps %} + + {% endfor %} + {% endif %} {% endif %}