From 8520ad6777b6784cbfb45d94326a026478a31cfd Mon Sep 17 00:00:00 2001 From: cube Date: Fri, 8 May 2026 20:20:20 +0100 Subject: [PATCH] a bunch of updates CHECK CONFIG --- README.md | 20 ++++++++++ myriad/__init__.py | 8 +++- myriad/home.py | 8 +++- myriad/manage.py | 37 +++++++++++++++++-- myriad/static/style.css | 10 ++++- myriad/templates/base.html | 13 ++++++- myriad/templates/blog/blog.html | 2 +- myriad/templates/custom_page.html | 14 +++++++ myriad/templates/manage/admin.html | 15 ++++++++ myriad/templates/manage/edit_custom_page.html | 30 +++++++++++++++ myriad/utilities.py | 8 +++- 11 files changed, 153 insertions(+), 12 deletions(-) create mode 100644 myriad/templates/custom_page.html create mode 100644 myriad/templates/manage/edit_custom_page.html diff --git a/README.md b/README.md index fa89f45..815f5ca 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,26 @@ the blinkies and stamps stuff is literally just because i want an easy way to up make sure blinkies are actually blinkie-sized, and stamps are likewise stamp-sized. too much variation in size will make the layout weird. there's not validation because its designed just to make uploading the images not require ftp + manual code as i had been doing before. +# Config + +this is how your config should look at the latest update + +``` +REGISTRATION = True # Make sure to disable in production +ICON_UPLOAD_FOLDER = 'myriad/static/icons' # where member icons will be stored +BLINKIES_UPLOAD_FOLDER = 'myriad/static/blinkies' # where blinkies will be stored +STAMPS_UPLOAD_FOLDER = 'myriad/static/stamps' # where stamps will be stored +MISC_UPLOAD_FOLDER = 'myriad/static/misc' # where misc image uploads will be stored +THEMES_FOLDER = 'myriad/static/themes' # all the theme css files are here +TMP_FOLDER = 'myriad/static/tmp' # required for exports +SYSTEM_NAME = 'Myriad' # will be shown in the title bar +PAGES_NAME = 'Read More...' # will be shown in the nav bar if using custom pages +SECRET_KEY = "dev" # CHANGE THIS - see wiki for details + +``` + +most likely if you get an error after updating, you need to make sure your config has all the fields as sampled above. we may have added something that you now need. + # A note on data export/import there are currently various ways to export and import data for use within myriad. individual member exports and imports deal only with the fields (though icons, stamps, and blinkies can be exported to a zip folder). they're designed to be used with an active database for whatever purpose the user requires. diff --git a/myriad/__init__.py b/myriad/__init__.py index b7a70dd..66be3d6 100644 --- a/myriad/__init__.py +++ b/myriad/__init__.py @@ -1,7 +1,7 @@ import os, datetime from flask import Flask -from myriad.utilities import server_time, get_datetime_str, remove_html +from myriad.utilities import server_time, get_datetime_str, remove_html, get_pages from myriad.db import get_db @@ -43,8 +43,12 @@ def create_app(): db = get_db() member = db.execute("SELECT * FROM member WHERE id=(?)",(mid,)).fetchone() return member + def get_system_name(): + return app.config["SYSTEM_NAME"] + def get_pages_name(): + return app.config["PAGES_NAME"] - return dict(get_themes=get_themes, server_time=w_server_time, get_datetime_str=w_get_datetime_str, get_member=get_member, remove_html=remove_html) + return dict(get_themes=get_themes, server_time=w_server_time, get_datetime_str=w_get_datetime_str, get_member=get_member, remove_html=remove_html, get_pages=get_pages, get_system_name=get_system_name, get_pages_name=get_pages_name) return app diff --git a/myriad/home.py b/myriad/home.py index 8cfcdb2..4d110ec 100644 --- a/myriad/home.py +++ b/myriad/home.py @@ -93,4 +93,10 @@ def groups(): else: group_members[gid]=[member] - return render_template("groups.html", groups=groups, group_members=group_members) \ No newline at end of file + return render_template("groups.html", groups=groups, group_members=group_members) + +@bp.route("/page/") +def custom_page(pid): + db = get_db() + page = db.execute("SELECT * FROM pages WHERE id=(?)",(pid,)).fetchone() + return render_template('custom_page.html', page=page) \ No newline at end of file diff --git a/myriad/manage.py b/myriad/manage.py index 36f310c..2b637df 100644 --- a/myriad/manage.py +++ b/myriad/manage.py @@ -462,10 +462,18 @@ def admin(): return "go home" + elif "new_page" in request.form: + page_title = request.form["page_title"] + page_content = request.form["page_content"] + + db.execute("INSERT INTO pages (title, content) VALUES (?, ?)", (page_title, page_content)) + db.commit() + users = db.execute("SELECT * FROM user").fetchall() front_log = db.execute("SELECT * FROM front_log ORDER BY start_time DESC").fetchall() + pages = db.execute("SELECT * FROM pages").fetchall() - return render_template("manage/admin.html", users=users, front_log=front_log) + return render_template("manage/admin.html", users=users, front_log=front_log, pages=pages) @@ -892,7 +900,30 @@ def group_delete(gid): return redirect(url_for("manage.groups")) - - +@bp.route("/edit_page/", methods=("GET", "POST")) +@login_required +def edit_page(pid): + db = get_db() + + if request.method == "POST": + content = request.form["content"] + title = request.form["title"] + + db.execute("UPDATE pages SET content=(?), title=(?)",(content, title)) + db.commit() + + page = db.execute("SELECT * FROM pages WHERE id=(?)",(pid,)).fetchone() + + return render_template("manage/edit_custom_page.html", page=page) + +@bp.route("/delete_page/") +@login_required +def delete_page(pid): + db = get_db() + + db.execute("DELETE FROM pages WHERE id=(?)",(pid,)) + db.commit() + + return redirect(url_for("manage.admin")) diff --git a/myriad/static/style.css b/myriad/static/style.css index e9dabde..b4e48d8 100644 --- a/myriad/static/style.css +++ b/myriad/static/style.css @@ -25,6 +25,7 @@ a:hover{ form{ margin:20px; + max-width:800px; } label,input{ margin:10px; @@ -41,8 +42,6 @@ form textarea{ } - - .profile{ margin:15px; border-style:solid; @@ -283,6 +282,13 @@ form textarea{ padding: 10px; } + + + + + + + .mobile{ display:none; } diff --git a/myriad/templates/base.html b/myriad/templates/base.html index 97a7ca0..24e7ba2 100644 --- a/myriad/templates/base.html +++ b/myriad/templates/base.html @@ -1,6 +1,6 @@ -{% block title %}{% endblock %} - Myriad +{% block title %}{% endblock %} - {{ get_system_name() }} {% set themes = get_themes() %} @@ -16,7 +16,7 @@ +
Custom Pages
+
+ +
+ +

+ +
+ +
+ + {% for page in pages %} +

{{page[1]}} - Edit PageDelete Page

+ {% endfor %} +
Backup
Export entire system as JSON (without images)
diff --git a/myriad/templates/manage/edit_custom_page.html b/myriad/templates/manage/edit_custom_page.html new file mode 100644 index 0000000..46a1797 --- /dev/null +++ b/myriad/templates/manage/edit_custom_page.html @@ -0,0 +1,30 @@ + + + + + + + + + + + + + +{% extends 'base.html' %} +{% block title %}{{ remove_html(page[1]) }}{% endblock %} + +{% block content %} + +
+ +
+ +
+ + +
+ +
+ +{% endblock %} \ No newline at end of file diff --git a/myriad/utilities.py b/myriad/utilities.py index 4a2b03d..4580522 100644 --- a/myriad/utilities.py +++ b/myriad/utilities.py @@ -1,4 +1,5 @@ import datetime, re +from myriad.db import get_db def server_time(): raw = datetime.datetime.now() @@ -22,4 +23,9 @@ def get_datetime_str(dt_obj): def remove_html(mystring): newstring = re.sub('<[^<]+?>', '', mystring) - return newstring \ No newline at end of file + return newstring + +def get_pages(): + db = get_db() + pages = db.execute("SELECT * FROM pages ORDER BY position").fetchall() + return pages \ No newline at end of file