diff --git a/.gitignore b/.gitignore index 90ac1a7..d82a1b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -*.woff \ No newline at end of file +__pycache__ +*.md +!POST_TEMPLATE.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..963ed85 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# syntax=docker/dockerfile:1 + +FROM python:3.12.2-slim-bookworm + +RUN apt-get update && apt-get upgrade -y + +RUN useradd -m app + +USER app + +COPY . . + +RUN python3 -m pip install --upgrade pip +RUN python3 -m pip install -r requirements.txt + +WORKDIR ./app + +CMD ["python3", "-u", "./app.py"] diff --git a/app/post.py b/app/post.py new file mode 100644 index 0000000..16d54cf --- /dev/null +++ b/app/post.py @@ -0,0 +1,25 @@ +import markdown +import datetime + +class Post: + + category : str + author : str + date : datetime.datetime + body : str + file : str + + def __init__(self, file_path): + self.file = file_path + + with open(file_path, 'r') as file: + lines = file.readlines() + + self.category = lines[1].split(":")[1].strip() + self.author = lines[2].split(":")[1].strip() + + date = lines[3].split(":")[1].strip() + self.date = datetime.datetime.strptime(date, "%d-%m-%Y") + + self.body = markdown.markdown(''.join(lines[6:])) + diff --git a/app/posts/POST_TEMPLATE.md b/app/posts/POST_TEMPLATE.md new file mode 100644 index 0000000..9d1363d --- /dev/null +++ b/app/posts/POST_TEMPLATE.md @@ -0,0 +1,9 @@ +# Metadata +category: category +author: author +date: date + +# POST +## TITLE +### DATE OR SUBTITLE +POST TEXT diff --git a/app/static/IBMPlexMono-Regular.woff b/app/static/IBMPlexMono-Regular.woff new file mode 100644 index 0000000..dd3070d Binary files /dev/null and b/app/static/IBMPlexMono-Regular.woff differ diff --git a/index_style.css b/app/static/index_style.css similarity index 94% rename from index_style.css rename to app/static/index_style.css index 89e3df0..e769f78 100644 --- a/index_style.css +++ b/app/static/index_style.css @@ -12,7 +12,6 @@ body { a { color: black; - text-decoration: none; } a:hover { @@ -70,11 +69,15 @@ a:hover { line-height: 30pt; } +.sidebar a { + text-decoration: none; +} + .dlog { order: 2; flex: 3; - text-align: center; + /* text-align: center; */ display: flex; flex-direction: column; @@ -104,3 +107,7 @@ a:hover { background-color: #C9D6DF; } + +.post p { + text-indent: 3em; +} diff --git a/app/templates/index.html b/app/templates/index.html new file mode 100644 index 0000000..f697cd3 --- /dev/null +++ b/app/templates/index.html @@ -0,0 +1,31 @@ + + +
+ + + 0x01fe.net +
+ +
+

0x01fe.net

+

Catchy Right‽

+
+
+ + + + + +
+ {% for post in posts %} +
{{ post|safe }}
+ {% endfor %} +
+
+ + diff --git a/app/website.py b/app/website.py new file mode 100644 index 0000000..86c2cc5 --- /dev/null +++ b/app/website.py @@ -0,0 +1,53 @@ +import glob +import configparser + +import flask + +from post import Post + +app = flask.Flask(__name__, static_url_path='', static_folder='static') + +config = configparser.ConfigParser() +config.read("config.ini") + +POSTS_FOLDER = config['POSTS']['POSTS_FOLDER'] + +def get_posts() -> list[Post]: + post_files= glob.glob(f'{POSTS_FOLDER}/*') + post_files.remove(f'{POSTS_FOLDER}\\POST_TEMPLATE.md') + + posts: list[Post] = [] + for post_file in post_files: + post = Post(post_file) + + posts.append(post) + + # Order Posts by Date + ordered_posts = [] + for i in range(len(posts)): + + most_recent = posts[0] + for p in posts: + if p.date < most_recent.date: + most_recent = p + + ordered_posts.append(most_recent) + posts.remove(most_recent) + + return reversed(ordered_posts) + +@app.route('/') +def index(): + + # Get posts + posts = get_posts() + + post_bodies = [] + for post in posts: + post_bodies.append(post.body) + + return flask.render_template('index.html', posts=post_bodies) + + +if __name__ == "__main__": + app.run() diff --git a/config.ini b/config.ini new file mode 100644 index 0000000..1d1d915 --- /dev/null +++ b/config.ini @@ -0,0 +1,5 @@ +[POSTS] +posts_folder=./posts + +[NETWORK] +PORT=1111 diff --git a/index.html b/index.html deleted file mode 100644 index f71eae4..0000000 --- a/index.html +++ /dev/null @@ -1,41 +0,0 @@ - - -
- - - 0x01fe.net -
- -
-

0x01fe.net

-

Catchy Right‽

-
-
- - - - - -
-
-

It's Peaks, Peaks of Yore

-

March 8th, 2024

-

Excuse the awful title please, but it truly is peak. Peaks of Yore has been a more enjoyable title than I could've ever expected. At first glance it seems like a "rage bait" game akin to the likes of Getting Over It With Bennett Foddy or Super Meatboy, but after the first few fundamental courses you realize the controls aren't fighting you, you just haven't mastered them yet.

-
-
-

Post Title

-

foobar

-
-
-

Post Title

-

foobar

-
-
-
- - diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..67443c6 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +Markdown==3.5.2 +Flask==2.2.3 \ No newline at end of file