From ec2a6a7a6dfa3071474eee847424038c47628b8b Mon Sep 17 00:00:00 2001 From: 0x01fe Date: Thu, 14 Mar 2024 14:44:33 -0500 Subject: [PATCH] redid all the css almost --- Dockerfile | 36 ++--- README.md | 18 +-- app/app.py | 159 ++++++++++----------- app/config.ini | 17 +-- app/post.py | 50 +++---- app/posts/POST_TEMPLATE.md | 18 +-- app/resources/status.text | 60 ++++---- app/static/index_style.css | 276 ++++++++++++++++++++----------------- app/templates/index.html | 62 ++++----- requirements.txt | 6 +- 10 files changed, 368 insertions(+), 334 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6a5b9c2..67b613a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +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"] +# 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/README.md b/README.md index 9368da6..d8282e3 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# My-Website - -Code of the website hosted at https://www.0x01fe.net - -Could I gitignore the config files? -Yes. -Do I? -no. - +# My-Website + +Code of the website hosted at https://www.0x01fe.net + +Could I gitignore the config files? +Yes. +Do I? +no. + diff --git a/app/app.py b/app/app.py index 9d93f70..5ec5bb0 100644 --- a/app/app.py +++ b/app/app.py @@ -1,77 +1,82 @@ -import glob -import configparser -import random - -import flask -import waitress -import markdown - -from post import Post - -app = flask.Flask(__name__, static_url_path='', static_folder='static') - -CONFIG_PATH = "./config.ini" -config = configparser.ConfigParser() -config.read(CONFIG_PATH) - -POSTS_FOLDER = config['POSTS']['POSTS_FOLDER'] -STATUS_FILE = config['STATUS']['STATUS_FILE'] -PORT = int(config['NETWORK']['PORT']) -DEV = int(config['NETWORK']['DEV']) - -def get_posts(category_filter : str | None = None) -> 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) - - if not category_filter: - posts.append(post) - elif category_filter == post.category: - 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) - -def get_status() -> str: - with open(STATUS_FILE, 'r', encoding='utf-8') as file: - statuses = file.readlines() - - status = random.randint(0, len(statuses) - 1) - - return markdown.markdown(statuses[status]) - -@app.route('/') -def index(): - - # Get posts - posts = get_posts() - - post_bodies = [] - for post in posts: - post_bodies.append(post.body) - - # Get status - status = get_status() - - return flask.render_template('index.html', posts=post_bodies, status=status) - - -if __name__ == "__main__": - if DEV: - app.run(port=PORT) - else: - waitress.serve(app, host='0.0.0.0', port=PORT) +import glob +import configparser +import random + +import flask +import waitress +import markdown + +from post import Post + +app = flask.Flask(__name__, static_url_path='', static_folder='static') + +CONFIG_PATH = "./config.ini" +config = configparser.ConfigParser() +config.read(CONFIG_PATH) + +POSTS_FOLDER = config['POSTS']['POSTS_FOLDER'] +STATUS_FILE = config['STATUS']['STATUS_FILE'] +PORT = int(config['NETWORK']['PORT']) +DEV = int(config['NETWORK']['DEV']) + +def get_posts(category_filter : str | None = None) -> list[Post]: + post_files = glob.glob(f'{POSTS_FOLDER}/*') + try: + post_files.remove(f'{POSTS_FOLDER}/POST_TEMPLATE.md') + except ValueError as e: + print(e) + print(f'Couldn\'t remove the template file probably; {post_files}') + exit() + + posts: list[Post] = [] + for post_file in post_files: + post = Post(post_file) + + if not category_filter: + posts.append(post) + elif category_filter == post.category: + 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) + +def get_status() -> str: + with open(STATUS_FILE, 'r', encoding='utf-8') as file: + statuses = file.readlines() + + status = random.randint(0, len(statuses) - 1) + + return markdown.markdown(statuses[status]) + +@app.route('/') +def index(): + + # Get posts + posts = get_posts() + + post_bodies = [] + for post in posts: + post_bodies.append(post.body) + + # Get status + status = get_status() + + return flask.render_template('index.html', posts=post_bodies, status=status) + + +if __name__ == "__main__": + if DEV: + app.run(port=PORT) + else: + waitress.serve(app, host='0.0.0.0', port=PORT) diff --git a/app/config.ini b/app/config.ini index 63cc0da..4485d75 100644 --- a/app/config.ini +++ b/app/config.ini @@ -1,8 +1,9 @@ -[POSTS] -posts_folder=./posts - -[STATUS] -status_file=./resources/status.text - -[NETWORK] -PORT=1111 +[POSTS] +posts_folder=./posts + +[STATUS] +status_file=./resources/status.text + +[NETWORK] +PORT=1111 +DEV=1 diff --git a/app/post.py b/app/post.py index c882e57..1de822a 100644 --- a/app/post.py +++ b/app/post.py @@ -1,25 +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', encoding='utf-8') 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:])) - +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', encoding='utf-8') 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 index 9d1363d..7fd0fb8 100644 --- a/app/posts/POST_TEMPLATE.md +++ b/app/posts/POST_TEMPLATE.md @@ -1,9 +1,9 @@ -# Metadata -category: category -author: author -date: date - -# POST -## TITLE -### DATE OR SUBTITLE -POST TEXT +# Metadata +category: category +author: author +date: date + +# POST +## TITLE +### DATE OR SUBTITLE +POST TEXT diff --git a/app/resources/status.text b/app/resources/status.text index a5bb9f4..3e80c49 100644 --- a/app/resources/status.text +++ b/app/resources/status.text @@ -1,31 +1,31 @@ -Catchy Right? -Everybody's lazy when they're tired -As long as there is delusion, there is hope -It's 510. -Mindful of the weary inkling that is lurking -Mortal traffic lights signaling when to stay or go -Cyber surgeon, Javascript person -Bone-dried swamplands swallow me -House of dust, land of bone -I ate dirt, I drank stone -Come on, snake, punish me -Drip, drip from the tap, don't slip on the drip -His name really is Tim. -Just wait until you see the 1 in 1000 message. -I'm open to suggestions on how to improve the look of the website -Open the curtains -Don't miss a moment of this experiment -Needles -Sally forth Rocinante! -The multitude tightens its hold. -It's amazing what you'll find face to face -It's not hard to go the distance, When you finally get involved face to face -A tourist in a dream, A visitor, it seems, A half-forgotten song, Where do I belong? -What do you mean ... You can't see it? -I don't believe you, your eyes deceive you, better check yourself in -You will say I'm crazy, I will go on my way 'cause it's what I need -I'd cross a thousand seas just to prove I'm not mad -I thought I saw a statue blink, and a bird with no head, Land on a golden thread, I rub my eyes, What am I saying? There's nothing there -Solar Sect of Mystic Wisdom -~ Nuclear Fusion +Catchy Right? +Everybody's lazy when they're tired +As long as there is delusion, there is hope +It's 510. +Mindful of the weary inkling that is lurking +Mortal traffic lights signaling when to stay or go +Cyber surgeon, Javascript person +Bone-dried swamplands swallow me +House of dust, land of bone +I ate dirt, I drank stone +Come on, snake, punish me +Drip, drip from the tap, don't slip on the drip +His name really is Tim. +Just wait until you see the 1 in 1000 message. +I'm open to suggestions on how to improve the look of the website +Open the curtains +Don't miss a moment of this experiment +Needles +Sally forth Rocinante! +The multitude tightens its hold. +It's amazing what you'll find face to face +It's not hard to go the distance, When you finally get involved face to face +A tourist in a dream, A visitor, it seems, A half-forgotten song, Where do I belong? +What do you mean ... You can't see it? +I don't believe you, your eyes deceive you, better check yourself in +You will say I'm crazy, I will go on my way 'cause it's what I need +I'd cross a thousand seas just to prove I'm not mad +I thought I saw a statue blink, and a bird with no head, Land on a golden thread, I rub my eyes, What am I saying? There's nothing there +Solar Sect of Mystic Wisdom +~ Nuclear Fusion Check out [NEUPINK](https://neupink.bandcamp.com/album/swordflower-hills-killer-2)! \ No newline at end of file diff --git a/app/static/index_style.css b/app/static/index_style.css index 215d546..15efd34 100644 --- a/app/static/index_style.css +++ b/app/static/index_style.css @@ -1,124 +1,152 @@ -/* Global Settings */ -@font-face { - font-family: ibmplexmono; - src: url(./IBMPlexMono-Regular.woff) format('woff'); -} - - -body { - /* font-family: 'Courier New', Courier, monospace; */ - font-family: ibmplexmono; -} - -a { - color: black; -} - -a:hover { - color: hotpink; -} - - - - -/* Other */ - -.header { - text-align: center; - - margin: 10pt; - - border-style: solid; - border-color: #1E2022; - background-color: #F0F5F9; - border-radius: 20px; -} - -.header h1 { - font-family: Arial, Helvetica, sans-serif; -} - -.header a { - text-decoration: none; - color: #703be7; -} - -.container { - - display: flex; - flex-direction: row; - - border-style: solid; - border-color: #1E2022; - background-color: #F0F5F9; - border-radius: 20px; -} - -.sidebar { - order: 1; - height: fit-content; - float: left; - - padding: 20pt; - padding-bottom: 5em; - - margin: 15pt; - - border-style: solid; - border-radius: 10px; - border-color: #1E2022; - background-color: #C9D6DF; - - opacity: 0.9; - - /* Text Settings */ - font-weight: bold; - line-height: 30pt; -} - -.sidebar a { - text-decoration: none; -} - - -.dlog { - order: 2; - flex: 3; - /* text-align: center; */ - - display: flex; - flex-direction: column; - - padding: 10pt; - margin: 15pt; - margin-left: 15%; - margin-right: 15%; - - border-style: solid; - border-radius: 20px; - border-color: #1E2022; - background-color: #C9D6DF; -} - -.post { - /* opacity: 0.9; */ - - border: 2px solid #52616B; - border-radius: 10px; - - padding: 10pt; - padding-left: 20pt; - padding-right: 20pt; - - margin: 10pt; - margin-left: 20pt; - margin-right: 20pt; - - background-color: #C9D6DF; - - line-height: 1.25em; -} - -.post p { - text-indent: 3em; -} +/* Global Stuff */ +@import url('https://fonts.googleapis.com/css?family=PT%20Mono:700|PT%20Mono:400'); + +body { + font-family: 'PT Mono'; + font-weight: 400; +} + +h1, h2, h3, h4, h5 { + font-family: 'PT Mono'; + font-weight: 700; +} + +html { + --text: hsl(224, 83%, 91%); + --background: hsl(224, 31%, 23%); + --primary: hsl(229, 81%, 73%); + --primary10: hsla(209, 61%, 71%, 10%); + --primary20: hsla(209, 61%, 71%, 20%); + --primary40: hsla(209, 61%, 71%, 40%); + --secondary: hsl(277, 81%, 33%); + --accent: hsl(291, 81%, 60%); + --accent75: hsla(291, 81%, 60%, 75%); + --accent50: hsla(291, 81%, 60%, 50%); + + --main-background: var(--primary10); + --borders-style: hidden; + --border-radius: 15px; +} + + +body { + color: var(--text); + background-color: var(--background); +} + +a { + color: var(--text); +} + +a:hover { + color: var(--accent); +} + + + + +/* Other */ + +.header { + text-align: center; + + margin: 0 30%; + padding: 2em; + + border-style: var(--borders-style); + border-color: #1E2022; + background-color: var(--background); + border-radius: var(--border-radius); +} + +.header a { + text-decoration: none; + color: var(--primary); +} + +.container { + + display: flex; + flex-direction: row; + + margin: 0px 20%; + + border-style: var(--borders-style); + border-color: #1E2022; + background-color: var(--main-background); + border-radius: var(--border-radius); +} + +.sidebar { + order: 1; + height: fit-content; + float: left; + + padding: 20pt; + + margin: 5em 0; + margin-left: 2em; + + border-style: var(--borders-style); + border-radius: var(--border-radius); + border-color: #1E2022; + background-color: var(--main-background); + + opacity: 0.9; + + /* Text Settings */ + font-weight: bold; + line-height: 30pt; +} + +.sidebar a { + text-decoration: none; +} + + +.dlog { + order: 2; + flex: 3; + /* text-align: center; */ + + display: flex; + flex-direction: column; + + padding: 10pt; + margin: 0 5%; + margin-left: 0; + + border-style: var(--borders-style); + border-radius: var(--border-radius); + border-color: #1E2022; + /* background-color: var(--main-background); */ +} + +.post { + + border-style: var(--borders-style); + border-radius: var(--border-radius); + + padding: 1.5em 2em; + margin: 1em 2em; + + /* background-color: var(--main-background); */ +} + +.post h2 { + text-decoration: underline; + text-decoration-style: solid; + text-decoration-thickness: 0.25em; + text-underline-offset: 6px; + text-decoration-color: var(--accent75); +} + +.post h3 { + font-weight: 300; + font-size: 18px; +} + +.post p { + line-height: 2.25; + text-indent: 3em; +} diff --git a/app/templates/index.html b/app/templates/index.html index 6a3ce30..f9fb491 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -1,31 +1,31 @@ - - -
- - - 0x01fe.net -
- -
-

0x01fe.net

-

{{ status|safe }}

-
-
- - - - - -
- {% for post in posts %} -
{{ post|safe }}
- {% endfor %} -
-
- - + + +
+ + + 0x01fe.net +
+ +
+

0x01fe.net

+ {{ status|safe }} +
+
+ + + + + +
+ {% for post in posts %} +
{{ post|safe }}
+ {% endfor %} +
+
+ + diff --git a/requirements.txt b/requirements.txt index 1308c6c..bb91e2f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Markdown==3.5.2 -Flask==2.2.3 -waitress==2.1.2 +Markdown==3.5.2 +Flask==2.2.3 +waitress==2.1.2 Werkzeug==2.2.3 \ No newline at end of file