From c4fbc62ec195c1fdea622a9b2c7593f8ad87fcef Mon Sep 17 00:00:00 2001
From: 0x01FE <0x10FE@0x01fe.net>
Date: Tue, 26 Mar 2024 18:40:38 -0500
Subject: [PATCH 01/18] minor css and gitignore changes (again)
---
.gitignore | 1 +
app/static/style.css | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 9fe92d2..46a471d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ docker-compose.yaml
# Ignore images in posts
*.jpg
*.png
+*.gif
diff --git a/app/static/style.css b/app/static/style.css
index 3ba8574..d657243 100644
--- a/app/static/style.css
+++ b/app/static/style.css
@@ -158,7 +158,7 @@ a:hover {
text-decoration: underline;
text-decoration-style: solid;
text-decoration-thickness: 0.25em;
- text-underline-offset: 6px;
+ text-underline-offset: 7px;
text-decoration-color: var(--primary);
}
From 52800a249d0fb36d9a7bd97b6192ee6a724a29c3 Mon Sep 17 00:00:00 2001
From: 0x01FE <0x10FE@0x01fe.net>
Date: Fri, 29 Mar 2024 11:30:53 -0500
Subject: [PATCH 02/18] added the writing page
---
.gitignore | 4 ++++
Dockerfile | 6 +++---
app/static/writing.html | 9 +++++++++
app/templates/index.html | 11 ++++++-----
4 files changed, 22 insertions(+), 8 deletions(-)
create mode 100644 app/static/writing.html
diff --git a/.gitignore b/.gitignore
index 46a471d..8726ba8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,7 @@ docker-compose.yaml
*.jpg
*.png
*.gif
+
+# Writing
+writing
+
diff --git a/Dockerfile b/Dockerfile
index 67b613a..9360969 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,9 +4,7 @@ FROM python:3.12.2-slim-bookworm
RUN apt-get update && apt-get upgrade -y
-RUN useradd -m app
-
-USER app
+RUN groupadd -r app && useradd -r -g app app
COPY . .
@@ -15,4 +13,6 @@ RUN python3 -m pip install -r requirements.txt
WORKDIR ./app
+USER app
+
CMD ["python3", "-u", "app.py"]
diff --git a/app/static/writing.html b/app/static/writing.html
new file mode 100644
index 0000000..44de92c
--- /dev/null
+++ b/app/static/writing.html
@@ -0,0 +1,9 @@
+
+
+
+ home
+
+
+ Scream March 27th, 2024
+
+
\ No newline at end of file
diff --git a/app/templates/index.html b/app/templates/index.html
index a5bfb0c..51412b8 100644
--- a/app/templates/index.html
+++ b/app/templates/index.html
@@ -14,11 +14,12 @@
From 3fefdcc7d8da82e38147e298b34bcec0c670f501 Mon Sep 17 00:00:00 2001
From: 0x01FE <0x10FE@0x01fe.net>
Date: Fri, 29 Mar 2024 11:45:00 -0500
Subject: [PATCH 03/18] remove config from tracking
---
.gitignore | 2 ++
app/config.ini | 9 ---------
2 files changed, 2 insertions(+), 9 deletions(-)
delete mode 100644 app/config.ini
diff --git a/.gitignore b/.gitignore
index 8726ba8..05a0f7a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,8 @@ __pycache__
docker-compose.yaml
*.sh
+*.ini
+
# Ignore images in posts
*.jpg
*.png
diff --git a/app/config.ini b/app/config.ini
deleted file mode 100644
index 8d00b71..0000000
--- a/app/config.ini
+++ /dev/null
@@ -1,9 +0,0 @@
-[POSTS]
-posts_folder=./posts
-
-[STATUS]
-status_file=./resources/status.text
-
-[NETWORK]
-PORT=1111
-DEV=0
From 75260fac0e30aa9d3dac14ad82da70c6472c94bc Mon Sep 17 00:00:00 2001
From: 0x01fe
Date: Wed, 3 Apr 2024 16:32:27 -0500
Subject: [PATCH 04/18] started album squared thing
---
app/app.py | 56 +++++++++++++++++-
.../2029240f6d1128be89ddc32729463129 | Bin 0 -> 9 bytes
.../aa43147407c8a8c678cd91f678f2a023 | Bin 0 -> 90 bytes
app/data/comments.json | 8 +++
app/data/users.json | 5 ++
app/static/albumsquare.css | 31 ++++++++++
app/static/style.css | 38 ++++++++++++
app/templates/album_square.html | 20 +++++++
app/templates/music.html | 12 ++++
9 files changed, 169 insertions(+), 1 deletion(-)
create mode 100644 app/data/.flask_session/2029240f6d1128be89ddc32729463129
create mode 100644 app/data/.flask_session/aa43147407c8a8c678cd91f678f2a023
create mode 100644 app/data/comments.json
create mode 100644 app/data/users.json
create mode 100644 app/static/albumsquare.css
create mode 100644 app/templates/album_square.html
diff --git a/app/app.py b/app/app.py
index 3492a78..d3f6ba5 100644
--- a/app/app.py
+++ b/app/app.py
@@ -2,6 +2,7 @@ import glob
import configparser
import random
+import requests
import flask
import waitress
import markdown
@@ -19,6 +20,9 @@ STATUS_FILE = config['STATUS']['STATUS_FILE']
PORT = int(config['NETWORK']['PORT'])
DEV = int(config['NETWORK']['DEV'])
+MUSIC_API_TOKEN = config['AUTH']['MUSIC_API_TOKEN']
+MUSIC_API_URL = config['NETWORK']['MUSIC_API_URL']
+
def get_posts(category_filter : str | None = None) -> list[Post]:
post_files = glob.glob(f'{POSTS_FOLDER}/*')
try:
@@ -105,7 +109,25 @@ def music():
# Get status
status = get_status()
- return flask.render_template('music.html', posts=post_bodies, status=status)
+ # Get top albums
+ r = requests.get(
+ MUSIC_API_URL +'/top/albums',
+ headers={
+ 'token' : MUSIC_API_TOKEN,
+ 'user' : '1',
+ 'limit' : '9'
+ })
+
+ top_albums = r.json()['top']
+ for album_index in range(0, len(top_albums)):
+ album = top_albums[album_index]
+
+ time = int(album['listen_time'])
+ hours = round(time/1000/60/60, 1)
+
+ top_albums[album_index]['listen_time'] = hours
+
+ return flask.render_template('music.html', posts=post_bodies, status=status, top_albums=top_albums)
# Motion Pictures Page
@app.route('/motion-pictures/')
@@ -148,6 +170,38 @@ def about():
return flask.render_template('about.html', status=status)
+# MISC
+
+@app.route('/albumsquare//')
+def album_square(user_id, rows : int):
+
+ limit = rows ** 2
+
+ res = 100/(rows+2)
+
+ # Get top albums
+ r = requests.get(
+ MUSIC_API_URL +'/top/albums',
+ headers={
+ 'token' : MUSIC_API_TOKEN,
+ 'user' : user_id,
+ 'limit' : str(limit)
+ })
+
+ top_albums = r.json()['top']
+ for album_index in range(0, len(top_albums)):
+ album = top_albums[album_index]
+
+ time = int(album['listen_time'])
+ hours = round(time/1000/60/60, 1)
+
+ top_albums[album_index]['listen_time'] = hours
+
+
+ return flask.render_template('album_square.html', top_albums=top_albums, limit=rows, res=res)
+
+
+
if __name__ == "__main__":
if DEV:
app.run(port=PORT)
diff --git a/app/data/.flask_session/2029240f6d1128be89ddc32729463129 b/app/data/.flask_session/2029240f6d1128be89ddc32729463129
new file mode 100644
index 0000000000000000000000000000000000000000..7f5741f13017ee705ea34021d222a06a6ee2a6c9
GIT binary patch
literal 9
QcmZQzU|?uq^=8ro00XcA0RR91
literal 0
HcmV?d00001
diff --git a/app/data/.flask_session/aa43147407c8a8c678cd91f678f2a023 b/app/data/.flask_session/aa43147407c8a8c678cd91f678f2a023
new file mode 100644
index 0000000000000000000000000000000000000000..d818306312c02b6939f76f09975e7cd3b355c42e
GIT binary patch
literal 90
zcmeB))lF+)o$Ad10ku;!dbr{XQj2mE^HTFlrgZdhB^MW^#h2t~r{+!R(J-_yH#Sa5
oH8xK%HZ!wKO-(j2Ha1VQ1o9116D`cmEmPBs%u|z-r
+
+
+
+
+ {% for album in top_albums %}
+
+
+
+ {% if loop.index % limit == 0 %}
+
+ {% endif %}
+ {% endfor %}
+
+
+
diff --git a/app/templates/music.html b/app/templates/music.html
index 9a00a11..5e35363 100644
--- a/app/templates/music.html
+++ b/app/templates/music.html
@@ -28,6 +28,18 @@
{{ post|safe }}
{% endfor %}
+
+
+
Top Albums
+ {% for album in top_albums %}
+
+
+
+ {% if loop.index % 3 == 0 %}
+
+ {% endif %}
+ {% endfor %}
+