Compare commits
3 Commits
439975ce96
...
main
Author | SHA1 | Date | |
---|---|---|---|
8eff8e990e | |||
16a2d8a53d | |||
630410797b |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@ __pycache__/
|
||||
database.db
|
||||
.env
|
||||
flask_session
|
||||
temp
|
@@ -8,12 +8,16 @@ COPY requirements.txt .
|
||||
|
||||
# Install the required packages
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
RUN pip install gunicorn
|
||||
|
||||
# Copy the rest of the application code into the container
|
||||
COPY src src
|
||||
COPY src .
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 5000
|
||||
|
||||
# Set environment variables
|
||||
ENV FLASK_APP=main.py
|
||||
|
||||
# run the application
|
||||
CMD ["python", "src/main.py"]
|
||||
ENTRYPOINT [ "gunicorn", "-b", ":5000", "--access-logfile", "-", "--error-logfile", "-", "main:app" ]
|
@@ -9,6 +9,8 @@
|
||||
<p>{{ board.description }}</p>
|
||||
{% if board.owner_id == session.user_id %}
|
||||
<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 %}
|
||||
{% if session.user_id %}
|
||||
<br>
|
||||
|
@@ -34,7 +34,7 @@
|
||||
{% endif %}
|
||||
<p>{{post.content}}</p>
|
||||
<h6>
|
||||
{% if session.name == "SYSTEM" %}
|
||||
{% if session.perms == "admin" %}
|
||||
<a href="/delete/post/{{ post.id }}">Delete</a>
|
||||
{% elif session.name == post.user.name %}
|
||||
<a href="/delete/post/{{ post.id }}">Delete</a>
|
||||
|
@@ -11,6 +11,7 @@
|
||||
<body>
|
||||
<header>
|
||||
<div id="title">
|
||||
<img src="../../static/content/prismic_logo.svg" alt="">
|
||||
<h1>Prismic</h1>
|
||||
<h2>ver: 2.0</h2>
|
||||
</div>
|
||||
|
@@ -20,7 +20,7 @@
|
||||
{% if post.replies > 0 %}
|
||||
({{ post.replies }} replies)
|
||||
{% endif %}
|
||||
{% if session.name == "SYSTEM" %}
|
||||
{% if session.perms == "admin" %}
|
||||
| <a href="/delete/post/{{ post.id }}">Delete</a>
|
||||
{% elif session.name == post.user.name %}
|
||||
| <a href="/delete/post/{{ post.id }}">Delete</a>
|
||||
|
@@ -20,7 +20,7 @@
|
||||
{% if post.replies > 0 %}
|
||||
({{ post.replies }} replies)
|
||||
{% endif %}
|
||||
{% if session.name == "SYSTEM" %}
|
||||
{% if session.perms == "admin" %}
|
||||
| <a href="/delete/post/{{ post.id }}">Delete</a>
|
||||
{% elif session.name == post.user.name %}
|
||||
| <a href="/delete/post/{{ post.id }}">Delete</a>
|
||||
|
35
src/main.py
35
src/main.py
@@ -20,7 +20,7 @@ console_log.setFormatter(logging.Formatter("\033[1;32m%(asctime)s\033[0m - \033[
|
||||
console_log.setLevel(logging.INFO)
|
||||
|
||||
# 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.setLevel(logging.DEBUG)
|
||||
|
||||
@@ -63,6 +63,8 @@ except:
|
||||
# Configure utils
|
||||
log.info("Configuring utils")
|
||||
conv = utils.data_converter(db)
|
||||
log.info("Configuration complete")
|
||||
|
||||
|
||||
|
||||
# Define routes
|
||||
@@ -550,6 +552,16 @@ def delete_board(board_id):
|
||||
return redirect('/login')
|
||||
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
|
||||
db.execute_query("DELETE FROM boards WHERE id = ?", (board_id,))
|
||||
log.info(f"Board ID {board_id} deleted successfully")
|
||||
@@ -598,6 +610,10 @@ def new_post():
|
||||
log.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')
|
||||
|
||||
reference = request.form.get('reference')
|
||||
@@ -675,6 +691,16 @@ def delete_post(post_id):
|
||||
return redirect('/login')
|
||||
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
|
||||
db.execute_query("DELETE FROM posts WHERE id = ?", (post_id,))
|
||||
log.info(f"Post ID {post_id} deleted successfully")
|
||||
@@ -694,4 +720,9 @@ def error(error_message):
|
||||
|
||||
# Run the app
|
||||
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)
|
||||
)
|
61
src/static/content/prismic_logo.svg
Normal file
61
src/static/content/prismic_logo.svg
Normal 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 |
@@ -31,8 +31,18 @@ header {
|
||||
|
||||
header #title {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 2px;
|
||||
align-items: center;
|
||||
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 {
|
||||
@@ -134,13 +144,6 @@ ul.post-list {
|
||||
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 {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
|
Reference in New Issue
Block a user