Compare commits

...

3 Commits

Author SHA1 Message Date
8eff8e990e add logo 2025-05-19 15:23:28 +01:00
16a2d8a53d docker 2025-04-25 10:22:18 +01:00
630410797b minor patches 2025-04-25 09:51:01 +01:00
10 changed files with 120 additions and 17 deletions

1
.gitignore vendored
View File

@@ -4,3 +4,4 @@ __pycache__/
database.db database.db
.env .env
flask_session flask_session
temp

View File

@@ -8,12 +8,16 @@ COPY requirements.txt .
# Install the required packages # Install the required packages
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
RUN pip install gunicorn
# Copy the rest of the application code into the container # Copy the rest of the application code into the container
COPY src src COPY src .
# Expose the port the app runs on # Expose the port the app runs on
EXPOSE 5000 EXPOSE 5000
# Set environment variables
ENV FLASK_APP=main.py
# run the application # run the application
CMD ["python", "src/main.py"] ENTRYPOINT [ "gunicorn", "-b", ":5000", "--access-logfile", "-", "--error-logfile", "-", "main:app" ]

View File

@@ -9,6 +9,8 @@
<p>{{ board.description }}</p> <p>{{ board.description }}</p>
{% if board.owner_id == session.user_id %} {% if board.owner_id == session.user_id %}
<h6><a href="/boards/delete/{{ board.id }}">Delete Board</a></h6> <h6><a href="/boards/delete/{{ board.id }}">Delete Board</a></h6>
{% elif session.perms == "admin" %}
<h6><a href="/boards/delete/{{ board.id }}">Delete Board</a></h6>
{% endif %} {% endif %}
{% if session.user_id %} {% if session.user_id %}
<br> <br>

View File

@@ -34,7 +34,7 @@
{% endif %} {% endif %}
<p>{{post.content}}</p> <p>{{post.content}}</p>
<h6> <h6>
{% if session.name == "SYSTEM" %} {% if session.perms == "admin" %}
<a href="/delete/post/{{ post.id }}">Delete</a> <a href="/delete/post/{{ post.id }}">Delete</a>
{% elif session.name == post.user.name %} {% elif session.name == post.user.name %}
<a href="/delete/post/{{ post.id }}">Delete</a> <a href="/delete/post/{{ post.id }}">Delete</a>

View File

@@ -11,6 +11,7 @@
<body> <body>
<header> <header>
<div id="title"> <div id="title">
<img src="../../static/content/prismic_logo.svg" alt="">
<h1>Prismic</h1> <h1>Prismic</h1>
<h2>ver: 2.0</h2> <h2>ver: 2.0</h2>
</div> </div>

View File

@@ -20,7 +20,7 @@
{% if post.replies > 0 %} {% if post.replies > 0 %}
({{ post.replies }} replies) ({{ post.replies }} replies)
{% endif %} {% endif %}
{% if session.name == "SYSTEM" %} {% if session.perms == "admin" %}
| <a href="/delete/post/{{ post.id }}">Delete</a> | <a href="/delete/post/{{ post.id }}">Delete</a>
{% elif session.name == post.user.name %} {% elif session.name == post.user.name %}
| <a href="/delete/post/{{ post.id }}">Delete</a> | <a href="/delete/post/{{ post.id }}">Delete</a>

View File

@@ -20,7 +20,7 @@
{% if post.replies > 0 %} {% if post.replies > 0 %}
({{ post.replies }} replies) ({{ post.replies }} replies)
{% endif %} {% endif %}
{% if session.name == "SYSTEM" %} {% if session.perms == "admin" %}
| <a href="/delete/post/{{ post.id }}">Delete</a> | <a href="/delete/post/{{ post.id }}">Delete</a>
{% elif session.name == post.user.name %} {% elif session.name == post.user.name %}
| <a href="/delete/post/{{ post.id }}">Delete</a> | <a href="/delete/post/{{ post.id }}">Delete</a>

View File

@@ -20,7 +20,7 @@ console_log.setFormatter(logging.Formatter("\033[1;32m%(asctime)s\033[0m - \033[
console_log.setLevel(logging.INFO) console_log.setLevel(logging.INFO)
# Create file handler with a specific format # Create file handler with a specific format
file_log = logging.FileHandler(env('LOG_FILE', default='app.log')) file_log = logging.FileHandler(env('LOG_FILE', default='app.log'), mode=env('LOG_MODE', default='a'))
file_log.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(name)s - %(message)s")) file_log.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(name)s - %(message)s"))
file_log.setLevel(logging.DEBUG) file_log.setLevel(logging.DEBUG)
@@ -63,6 +63,8 @@ except:
# Configure utils # Configure utils
log.info("Configuring utils") log.info("Configuring utils")
conv = utils.data_converter(db) conv = utils.data_converter(db)
log.info("Configuration complete")
# Define routes # Define routes
@@ -550,6 +552,16 @@ def delete_board(board_id):
return redirect('/login') return redirect('/login')
log.debug(f"Token validated for user {user[1]}") log.debug(f"Token validated for user {user[1]}")
# Check if user owns the board or is admin
board = db.execute_query("SELECT * FROM boards WHERE id = ?", (board_id,), fetch_type=FETCHONE)
if not board:
log.error("Board not found")
return render_template('error.html', error="Board not found")
if board[4] != user[0] and session['perms'] != 'admin':
log.error("User does not have permission to delete this board")
return render_template('error.html', error="You do not have permission to delete this board")
# Delete the board # Delete the board
db.execute_query("DELETE FROM boards WHERE id = ?", (board_id,)) db.execute_query("DELETE FROM boards WHERE id = ?", (board_id,))
log.info(f"Board ID {board_id} deleted successfully") log.info(f"Board ID {board_id} deleted successfully")
@@ -598,6 +610,10 @@ def new_post():
log.error("No post content provided") log.error("No post content provided")
return render_template('error.html', error="No post content provided") return render_template('error.html', error="No post content provided")
if len(content) > 10000:
log.error("Post content is too long")
return render_template('error.html', error="Post content is too long")
attachments = request.files.getlist('attachments') attachments = request.files.getlist('attachments')
reference = request.form.get('reference') reference = request.form.get('reference')
@@ -675,6 +691,16 @@ def delete_post(post_id):
return redirect('/login') return redirect('/login')
log.debug(f"Token validated for user {user[1]}") log.debug(f"Token validated for user {user[1]}")
# Check if user owns the post or is admin
post = db.execute_query("SELECT * FROM posts WHERE id = ?", (post_id,), fetch_type=FETCHONE)
if not post:
log.error("Post not found")
return render_template('error.html', error="Post not found")
if post[1] != user[0] and session['perms'] != 'admin':
log.error("User does not have permission to delete this post")
return render_template('error.html', error="You do not have permission to delete this post")
# Delete the post # Delete the post
db.execute_query("DELETE FROM posts WHERE id = ?", (post_id,)) db.execute_query("DELETE FROM posts WHERE id = ?", (post_id,))
log.info(f"Post ID {post_id} deleted successfully") log.info(f"Post ID {post_id} deleted successfully")
@@ -694,4 +720,9 @@ def error(error_message):
# Run the app # Run the app
if __name__ == '__main__': if __name__ == '__main__':
pass log.info("Starting development server")
app.run(
host=env('HOST', default='0.0.0.0'),
port=env('PORT', default=5000),
debug=env('DEBUG', default=True)
)

View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="180"
height="180"
viewBox="0 0 180 180"
version="1.1"
id="svg1"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1">
<linearGradient
id="linearGradient1">
<stop
style="stop-color:#7139f3;stop-opacity:1;"
offset="0.24761663"
id="stop1" />
<stop
style="stop-color:#5b6dd4;stop-opacity:1;"
offset="0.25"
id="stop4" />
<stop
style="stop-color:#5b6dd4;stop-opacity:1;"
offset="0.5"
id="stop7" />
<stop
style="stop-color:#39f3da;stop-opacity:1;"
offset="0.5"
id="stop9" />
<stop
style="stop-color:#39f3da;stop-opacity:1;"
offset="0.75"
id="stop8" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="0.75"
id="stop2" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient1"
id="linearGradient2"
x1="21.343988"
y1="147.61742"
x2="158.85297"
y2="32.233677"
gradientUnits="userSpaceOnUse" />
</defs>
<g
id="layer1">
<ellipse
style="fill:url(#linearGradient2)"
id="path1"
cx="90.098473"
cy="89.925537"
rx="89.752602"
ry="89.579666" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -31,8 +31,18 @@ header {
header #title { header #title {
display: flex; display: flex;
align-items: baseline; align-items: center;
gap: 2px; gap: 4px;
background: linear-gradient(90deg, var(--accent), var(--admin));
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
#title img {
width: 50px;
height: 50px;
border-radius: 50%;
} }
header h1 { header h1 {
@@ -134,13 +144,6 @@ ul.post-list {
color: var(--time); color: var(--time);
} }
#title {
background: linear-gradient(90deg, var(--accent), var(--admin));
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.attachments { .attachments {
display: flex; display: flex;
gap: 10px; gap: 10px;