From 7c6aabb1aa5ed61669d0737172258d5075fb7e61 Mon Sep 17 00:00:00 2001 From: cube Date: Wed, 18 Mar 2026 02:36:25 +0000 Subject: [PATCH] basic member blogs still trying to figure out how to maximize customisability (html & css) of member pages as much as how we have them on neocities --- README.md | 16 ++++++------- myriad/__init__.py | 3 +++ myriad/blog.py | 41 +++++++++++++++++++++++++++++++++ myriad/home.py | 10 +++++++- myriad/schema.sql | 8 ++++--- myriad/templates/base.html | 5 ++++ myriad/templates/blog/blog.html | 19 +++++++++++++++ myriad/templates/blog/new.html | 24 +++++++++++++++++++ myriad/templates/full.html | 2 +- myriad/templates/index.html | 7 ++++-- myriad/templates/page.html | 21 +++++++++++++++++ 11 files changed, 140 insertions(+), 16 deletions(-) create mode 100644 myriad/blog.py create mode 100644 myriad/templates/blog/blog.html create mode 100644 myriad/templates/blog/new.html create mode 100644 myriad/templates/page.html diff --git a/README.md b/README.md index 457e1dc..aa69018 100644 --- a/README.md +++ b/README.md @@ -24,17 +24,15 @@ do not deploy this way, the packaged flask server is not secure. production inst - create `config.py` in the instance folder and customise the following settings to your needs ``` -REGISTRATION = True -ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'} -ICON_UPLOAD_FOLDER = 'myriad/static/icons' -BLINKIES_UPLOAD_FOLDER = 'myriad/static/blinkies' -STAMPS_UPLOAD_FOLDER = 'myriad/static/stamps' +REGISTRATION = True # Make sure to disable in production +ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'} # Can be anything you want +ICON_UPLOAD_FOLDER = 'myriad/static/icons' # where member icons will be stored +BLINKIES_UPLOAD_FOLDER = 'myriad/static/blinkies' # where site assets "blinkies" will be stored +STAMPS_UPLOAD_FOLDER = 'myriad/static/stamps' # where site assets "stamps" will be stored +INLINE_UPLOAD_FOLDER = 'myriad/static/inline' # where site assets "misc inline" will be stored +MISC_UPLOAD_FOLDER = 'myriad/static/misc' # where other small images will be stored ``` -- registration should only be set to True in a development situation (in production set it to False one you have set up your administration account). this would mean that anyone can make an account and edit your system -- feel free to adjust allowed file extensions however you choose -- upload folders don't need to be changed - # usage - the software here is free to use, and there's no requirement to link back diff --git a/myriad/__init__.py b/myriad/__init__.py index b0a954c..11302f1 100644 --- a/myriad/__init__.py +++ b/myriad/__init__.py @@ -30,4 +30,7 @@ def create_app(test_config=None): from . import manage app.register_blueprint(manage.bp) + from . import blog + app.register_blueprint(blog.bp) + return app diff --git a/myriad/blog.py b/myriad/blog.py new file mode 100644 index 0000000..0a2a5ec --- /dev/null +++ b/myriad/blog.py @@ -0,0 +1,41 @@ +from flask import ( + Blueprint, flash, g, redirect, render_template, request, session, url_for, current_app +) +from werkzeug.utils import secure_filename +import os, uuid + +from myriad.auth import login_required +from myriad.db import get_db + +bp = Blueprint('blog', __name__, url_prefix='/blog') + +@bp.route('/') +def blog(): + db = get_db() + posts = db.execute("SELECT * FROM blog ORDER BY created DESC").fetchall() + members = db.execute("SELECT id,member_name FROM member").fetchall() + member_ids={} + for member in members: + member_ids[member[0]] = member[1] + + return render_template('blog/blog.html', blog=posts, member_ids=member_ids) + +@bp.route('/new', methods=('GET', 'POST')) +@login_required +def new(): + db = get_db() + members = db.execute("SELECT id,member_name FROM member").fetchall() + + if request.method == 'POST': + title = request.form['title'] + content = request.form['content'] + mid = request.form["mid"] + + db.execute("INSERT INTO blog (member_id, title, content) VALUES (?, ?, ?)",(mid, title, content)) + db.commit() + + return redirect(url_for('blog.blog')) + + + return render_template('blog/new.html', members=members) + diff --git a/myriad/home.py b/myriad/home.py index 141e4f5..f67da24 100644 --- a/myriad/home.py +++ b/myriad/home.py @@ -41,4 +41,12 @@ def full_list(): else: icons[member[0]] = None - return render_template('full.html', memberlist=members, icons=icons) \ No newline at end of file + return render_template('full.html', memberlist=members, icons=icons) + +@bp.route('/member/') +def page(mid): + db = get_db() + member = db.execute("SELECT * FROM member WHERE id=(?)",(mid,)).fetchone() + blog = db.execute("SELECT * FROM blog WHERE member_id=(?) ORDER BY created DESC",(mid,)).fetchall() + + return render_template('page.html', member=member, blog=blog) \ No newline at end of file diff --git a/myriad/schema.sql b/myriad/schema.sql index db2df72..18e54eb 100644 --- a/myriad/schema.sql +++ b/myriad/schema.sql @@ -3,7 +3,7 @@ DROP TABLE IF EXISTS member; DROP TABLE IF EXISTS icons; DROP TABLE IF EXISTS groups; DROP TABLE IF EXISTS group_members; -DROP TABLE IF EXISTS pages; +DROP TABLE IF EXISTS blog; CREATE TABLE user ( id INTEGER PRIMARY KEY AUTOINCREMENT, @@ -60,9 +60,11 @@ CREATE TABLE group_members ( FOREIGN KEY (member_id) REFERENCES member (id) ); -CREATE TABLE pages ( +CREATE TABLE blog ( id INTEGER PRIMARY KEY AUTOINCREMENT, member_id INTEGER NOT NULL, - page_location TEXT NOT NULL, + created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + title TEXT, + content TEXT, FOREIGN KEY (member_id) REFERENCES member (id) ); \ No newline at end of file diff --git a/myriad/templates/base.html b/myriad/templates/base.html index eb974c6..a3c1778 100644 --- a/myriad/templates/base.html +++ b/myriad/templates/base.html @@ -14,8 +14,13 @@ {% if g.user %}
Manage
+ {% endif %} +
Blog
+ {% if g.user %}{% endif %} + +
Administration
{% if g.user %} diff --git a/myriad/templates/blog/blog.html b/myriad/templates/blog/blog.html new file mode 100644 index 0000000..6f8a2c3 --- /dev/null +++ b/myriad/templates/blog/blog.html @@ -0,0 +1,19 @@ +{% extends 'base.html' %} + +{% block header %} +
{% block title %}System Blog{% endblock %}
+{% endblock %} + +{% block content %} + + {% for post in blog %} +
+
{{post[3]}}
+ +
+ {{post[4]}} +
+
+ {% endfor %} + +{% endblock %} \ No newline at end of file diff --git a/myriad/templates/blog/new.html b/myriad/templates/blog/new.html new file mode 100644 index 0000000..1e06a32 --- /dev/null +++ b/myriad/templates/blog/new.html @@ -0,0 +1,24 @@ +{% extends 'base.html' %} + +{% block header %} +
{% block title %}New Blog Post{% endblock %}
+{% endblock %} + +{% block content %} +
+ +
+ +
+ + + +
+ + {{ error }} + +{% endblock %} \ No newline at end of file diff --git a/myriad/templates/full.html b/myriad/templates/full.html index 6e0fe02..6dbc1f5 100644 --- a/myriad/templates/full.html +++ b/myriad/templates/full.html @@ -63,7 +63,7 @@ {{ member[5]|safe }}
- {% if g.user %}{% endif %} +
diff --git a/myriad/templates/index.html b/myriad/templates/index.html index d59dac8..9edfc66 100644 --- a/myriad/templates/index.html +++ b/myriad/templates/index.html @@ -2,9 +2,12 @@ {% block title %}Welcome{% endblock %} {% block content %} + + {% if front_list|length > 0 %}
- currently fronting: {% for member in front_list %} {{ member[3] }} {% if front_list.index(member) != front_list|length -1 %}&{% endif %} {% endfor %} + currently fronting: {% for member in front_list %} {{ member[3] }} {% if front_list.index(member) != front_list|length -1 %}&{% endif %} {% endfor %}
+ {% endif %} {% for member in home_pins %} @@ -57,7 +60,7 @@ {{ member[5]|safe }}
- {% if g.user %}{% endif %} +
diff --git a/myriad/templates/page.html b/myriad/templates/page.html new file mode 100644 index 0000000..3f53cdb --- /dev/null +++ b/myriad/templates/page.html @@ -0,0 +1,21 @@ +{% extends 'base.html' %} +{% block title %}{{ member[3] }}{% endblock %} + +{% block content %} + +
{{member[3]}}'s blog
+
+ + {% for post in blog %} +
+
{{post[3]}}
+
{{post[2]}}
+
+ {{post[4]}} +
+
+ {% endfor %} + +
+ +{% endblock %} \ No newline at end of file