added all my images and stuff

This commit is contained in:
0x01FE 2024-09-17 09:45:25 -05:00
parent 637e7bd9ab
commit ad2175e6cb
31 changed files with 304 additions and 295 deletions

View File

@ -48,7 +48,7 @@ statuses = {}
def get_posts(category_filter : str | None = None) -> list[tuple[dict, list]]: def get_posts(category_filter : str | None = None) -> list[tuple[dict, list]]:
post_files = glob.glob(f'{POSTS_FOLDER}/*') post_files = glob.glob(f'{POSTS_FOLDER}/*')
try: try:
post_files.remove(f'{POSTS_FOLDER}/POST_TEMPLATE.md') post_files.remove(f'{POSTS_FOLDER}\\POST_TEMPLATE.md')
except ValueError as e: except ValueError as e:
print(e) print(e)
print(f'Couldn\'t remove the template file probably; {post_files}') print(f'Couldn\'t remove the template file probably; {post_files}')

View File

@ -1,61 +1,64 @@
import json import json
import os import os
import flask import flask
import flask_wtf.csrf import flask_wtf.csrf
import wtforms import wtforms
COMMENTS_PATH = "./data/comments.json" COMMENTS_PATH = "./data/comments.json"
comments = flask.Blueprint('comment', __name__, template_folder='./templates')
if not os.path.exists('./data/'):
class CommentForm(flask_wtf.FlaskForm): os.mkdir('./data/')
textbox = wtforms.TextAreaField('Input')
if not os.path.exists(COMMENTS_PATH):
@comments.route('/comment/<string:post_title>', methods=['POST']) with open(COMMENTS_PATH, 'w+') as file:
def comment(post_title: str): file.write('{}')
form = CommentForm(csrf_enabled=True)
comments = flask.Blueprint('comment', __name__, template_folder='./templates')
save_comment(form.textbox.data, post_title)
class CommentForm(flask_wtf.FlaskForm):
return flask.redirect('/') textbox = wtforms.TextAreaField('Input')
def save_comment(content: str, post_title: str): @comments.route('/comment/<string:post_title>', methods=['POST'])
with open(COMMENTS_PATH, 'r') as file: def comment(post_title: str):
comment_data = json.loads(file.read()) form = CommentForm(csrf_enabled=True)
# See if user is logged in, otherwise setup as anon save_comment(form.textbox.data, post_title)
if 'username' in flask.session:
username = flask.session['username'] return flask.redirect('/')
else:
username = 'Anon' def save_comment(content: str, post_title: str):
with open(COMMENTS_PATH, 'r') as file:
comment = { comment_data = json.loads(file.read())
"username" : username,
"content" : content # See if user is logged in, otherwise setup as anon
} if 'username' in flask.session:
username = flask.session['username']
# Add comment to JSON data else:
if post_title in comment_data: username = 'Anon'
comment_data[post_title].append(comment)
else: comment = {
comment_data[post_title] = [comment] "username" : username,
"content" : content
# Save JSON data }
with open(COMMENTS_PATH, 'w') as file:
file.write(json.dumps(comment_data)) # Add comment to JSON data
if post_title in comment_data:
def get_comments(post_title : int) -> list[dict]: comment_data[post_title].append(comment)
else:
with open(COMMENTS_PATH, 'r') as file: comment_data[post_title] = [comment]
comment_data = json.loads(file.read())
# Save JSON data
if post_title in comment_data: with open(COMMENTS_PATH, 'w') as file:
return comment_data[post_title] file.write(json.dumps(comment_data))
else:
return [] def get_comments(post_title : int) -> list[dict]:
# Check Comments file exists with open(COMMENTS_PATH, 'r') as file:
if not os.path.exists(COMMENTS_PATH): comment_data = json.loads(file.read())
with open(COMMENTS_PATH, 'w+') as file:
file.write('{}') if post_title in comment_data:
return comment_data[post_title]
else:
return []

View File

@ -1,19 +1,19 @@
.albums { .albums {
height: 100%; height: 100%;
line-height: 0; line-height: 0;
font-size: 0; font-size: 0;
} }
.albums img { .albums img {
padding: 0 0; padding: 0 0;
margin: 0 0; margin: 0 0;
border: 0 0; border: 0 0;
} }
.body { .body {
height: 100%; height: 100%;
padding: 0 0; padding: 0 0;
margin: 0 0; margin: 0 0;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 609 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 832 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 828 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 728 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

View File

@ -1,12 +1,12 @@
EOF Mark, EOF Mark,
Glassit-VSC, Glassit-VSC,
JSON formatter, JSON formatter,
Pylance, Pylance,
Remote - SSH, Remote - SSH,
Synthwave '84 Blues, Synthwave '84 Blues,
Trailing Spaces, Trailing Spaces,
Helm Intellisense, Helm Intellisense,
background, background,
Helium Icon Theme, Helium Icon Theme,
SQLite Viewer, SQLite Viewer,
Docker Docker

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

BIN
app/static/render.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
app/static/render.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

BIN
app/static/roland_think.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

View File

@ -12,8 +12,9 @@ h1, h2, h3, h4, h5 {
} }
html { html {
--text: hsl(224, 83%, 91%); --text: black;
--background: hsl(224, 31%, 23%); --background: #c0c0b0;
/* --background: #2b2d31; */
--primary: hsl(229, 81%, 73%); --primary: hsl(229, 81%, 73%);
--primary10: hsla(209, 61%, 71%, 10%); --primary10: hsla(209, 61%, 71%, 10%);
--primary20: hsla(209, 61%, 71%, 20%); --primary20: hsla(209, 61%, 71%, 20%);
@ -70,15 +71,19 @@ li {
/* Other */ /* Other */
.header { .header {
background-image: url("render.jpg");
background-size: cover;
text-align: center; text-align: center;
margin: 0 30%; margin: 2em 25%;
padding: 2em; padding: 3em;
border-style: var(--borders-style); border-style: var(--borders-style);
border-color: #1E2022; border-color: #1E2022;
background-color: var(--background); background-color: var(--background);
border-radius: var(--border-radius); border-radius: var(--border-radius);
color: white;
} }
.header a { .header a {
@ -91,7 +96,7 @@ li {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
margin: 0px 5%; margin: 0px 20%;
border-style: var(--borders-style); border-style: var(--borders-style);
border-color: #1E2022; border-color: #1E2022;
@ -223,6 +228,7 @@ li {
} }
.post p { .post p {
font-family: Verdana, Geneva, sans-serif;
line-height: 2.25; line-height: 2.25;
text-indent: 3em; text-indent: 3em;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
app/static/yosemite.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 MiB

View File

@ -1,20 +1,20 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<header> <header>
<link rel="shortcut icon" href="index_favicon.ico"> <link rel="shortcut icon" href="index_favicon.ico">
<link rel="stylesheet" href="{{ url_for('static', filename='albumsquare.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='albumsquare.css') }}">
<title>Album Square</title> <title>Album Square</title>
</header> </header>
<body> <body>
<div class="albums"> <div class="albums">
{% for album in top_albums %} {% for album in top_albums %}
<a title="{{ album.album_name}} by {{ album.artist_name }} - {{ album.listen_time }} Hours"> <a title="{{ album.album_name}} by {{ album.artist_name }} - {{ album.listen_time }} Hours">
<img src="{{ album.album_cover }}" style="width: {{ res }}px; height: {{ res }}px;"> <img src="{{ album.album_cover }}" style="width: {{ res }}px; height: {{ res }}px;">
</a> </a>
{% if loop.index % limit == 0 %} {% if loop.index % limit == 0 %}
<br> <br>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,40 +1,40 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<header> <header>
<link rel="shortcut icon" href="index_favicon.ico"> <link rel="shortcut icon" href="index_favicon.ico">
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<title>0x01fe.net - Login</title> <title>0x01fe.net - Login</title>
</header> </header>
<body> <body>
<div class="header"> <div class="header">
<h1>0x01fe.net</h1> <h1>0x01fe.net</h1>
{{ status|safe }} {{ status|safe }}
</div> </div>
<div class="container"> <div class="container">
<!-- Sidebar --> <!-- Sidebar -->
<div class="sidebar"> <div class="sidebar">
<a href="/"><u>Home</u></a><br> <a href="/"><u>Home</u></a><br>
<a href="/games/">Games</a><br> <a href="/games/">Games</a><br>
<a href="/music/">Music</a><br> <a href="/music/">Music</a><br>
<a href="/motion-pictures/">Motion Picture</a><br> <a href="/motion-pictures/">Motion Picture</a><br>
<a href="/programming/">Programming</a><br> <a href="/programming/">Programming</a><br>
<a href="/about/">About</a><br> <a href="/about/">About</a><br>
<a href="/login/">Login</a> <a href="/login/">Login</a>
</div> </div>
<div class="dlog"> <div class="dlog">
<h1>Login</h1> <h1>Login</h1>
<form method="post" action="/user/login/"> <form method="post" action="/user/login/">
{{ form.hidden_tag() }} {{ form.hidden_tag() }}
Username: {{ form.username }} <br> Username: {{ form.username }} <br>
Password: {{ form.password }} <br> Password: {{ form.password }} <br>
<input type="submit" value="Login"> <input type="submit" value="Login">
</form> </form>
<br> <br>
<h1>Need to Register?</h1> <h1>Need to Register?</h1>
<a href="/user/register/">Register</a> <a href="/user/register/">Register</a>
</div> </div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,36 +1,36 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<header> <header>
<link rel="shortcut icon" href="index_favicon.ico"> <link rel="shortcut icon" href="index_favicon.ico">
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<title>0x01fe.net - Register</title> <title>0x01fe.net - Register</title>
</header> </header>
<body> <body>
<div class="header"> <div class="header">
<h1>0x01fe.net</h1> <h1>0x01fe.net</h1>
{{ status|safe }} {{ status|safe }}
</div> </div>
<div class="container"> <div class="container">
<!-- Sidebar --> <!-- Sidebar -->
<div class="sidebar"> <div class="sidebar">
<a href="/"><u>Home</u></a><br> <a href="/"><u>Home</u></a><br>
<a href="/games/">Games</a><br> <a href="/games/">Games</a><br>
<a href="/music/">Music</a><br> <a href="/music/">Music</a><br>
<a href="/motion-pictures/">Motion Picture</a><br> <a href="/motion-pictures/">Motion Picture</a><br>
<a href="/programming/">Programming</a><br> <a href="/programming/">Programming</a><br>
<a href="/about/">About</a><br> <a href="/about/">About</a><br>
<a href="/login/">Login</a> <a href="/login/">Login</a>
</div> </div>
<div class="dlog"> <div class="dlog">
<h1>Register</h1> <h1>Register</h1>
<form method="post" action="/user/add/"> <form method="post" action="/user/add/">
{{ form.hidden_tag() }} {{ form.hidden_tag() }}
Username: {{ form.username }} <br> Username: {{ form.username }} <br>
Password: {{ form.password }} <br> Password: {{ form.password }} <br>
<input type="submit" value="Register"> <input type="submit" value="Register">
</form> </form>
</div> </div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,102 +1,102 @@
import base64 import base64
import json import json
import os import os
import flask import flask
import flask_wtf.csrf import flask_wtf.csrf
import wtforms import wtforms
user = flask.Blueprint('user', __name__, template_folder='./templates/user') user = flask.Blueprint('user', __name__, template_folder='./templates/user')
USERS_PATH = "./data/users.json" USERS_PATH = "./data/users.json"
class RegisterUserForm(flask_wtf.FlaskForm): class RegisterUserForm(flask_wtf.FlaskForm):
username = wtforms.StringField("Username", [ username = wtforms.StringField("Username", [
wtforms.validators.Length(min=4, max=32), wtforms.validators.Length(min=4, max=32),
wtforms.validators.DataRequired() wtforms.validators.DataRequired()
]) ])
password = wtforms.PasswordField("Password", [ password = wtforms.PasswordField("Password", [
wtforms.validators.Length(min=8, max=64), wtforms.validators.Length(min=8, max=64),
wtforms.validators.DataRequired() wtforms.validators.DataRequired()
]) ])
class LoginUserForm(flask_wtf.FlaskForm): class LoginUserForm(flask_wtf.FlaskForm):
username = wtforms.StringField("Username", [ username = wtforms.StringField("Username", [
wtforms.validators.DataRequired() wtforms.validators.DataRequired()
]) ])
password = wtforms.PasswordField("Password", [ password = wtforms.PasswordField("Password", [
wtforms.validators.DataRequired() wtforms.validators.DataRequired()
]) ])
@user.route('/user/add/', methods=["POST"]) @user.route('/user/add/', methods=["POST"])
def add_user(): def add_user():
# Get form data # Get form data
form = RegisterUserForm(csrf_enabled=True) form = RegisterUserForm(csrf_enabled=True)
username = form.username.data username = form.username.data
password = form.password.data password = form.password.data
# Read existing user data # Read existing user data
with open(USERS_PATH, 'r') as file: with open(USERS_PATH, 'r') as file:
user_data = json.loads(file.read()) user_data = json.loads(file.read())
# check if user exists # check if user exists
if username in user_data: if username in user_data:
return 'ERROR PROCESSING REQUEST - That user already exists' return 'ERROR PROCESSING REQUEST - That user already exists'
# Store password / server side cookie # Store password / server side cookie
user_data[username] = base64.b64encode(password.encode()).decode() user_data[username] = base64.b64encode(password.encode()).decode()
flask.session['username'] = username flask.session['username'] = username
# Write user data # Write user data
with open(USERS_PATH, 'w') as file: with open(USERS_PATH, 'w') as file:
file.write(json.dumps(user_data)) file.write(json.dumps(user_data))
return flask.redirect('/') return flask.redirect('/')
@user.route('/user/register/') @user.route('/user/register/')
def register_page(): def register_page():
form = RegisterUserForm() form = RegisterUserForm()
return flask.render_template('register.html', form=form) return flask.render_template('register.html', form=form)
@user.route('/user/login/', methods=["POST"]) @user.route('/user/login/', methods=["POST"])
def login_user(): def login_user():
form = LoginUserForm(csrf_enabled=True) form = LoginUserForm(csrf_enabled=True)
username = form.username.data username = form.username.data
password = base64.b64encode(form.password.data.encode()).decode() password = base64.b64encode(form.password.data.encode()).decode()
# Read existing user data # Read existing user data
with open(USERS_PATH, 'r') as file: with open(USERS_PATH, 'r') as file:
user_data = json.loads(file.read()) user_data = json.loads(file.read())
# check if user exists # check if user exists
if username not in user_data: if username not in user_data:
return 'ERROR PROCESSING REQUEST - Bad username OR password' return 'ERROR PROCESSING REQUEST - Bad username OR password'
# Does password match? # Does password match?
if user_data[username] != password: if user_data[username] != password:
return 'ERROR PROCESSING REQUEST - Bad username OR password' return 'ERROR PROCESSING REQUEST - Bad username OR password'
flask.session['username'] = username flask.session['username'] = username
return flask.redirect('/') return flask.redirect('/')
@user.route('/login/') @user.route('/login/')
def login_page(): def login_page():
form = LoginUserForm() form = LoginUserForm()
return flask.render_template('login.html', form=form) return flask.render_template('login.html', form=form)
@user.route('/logout/') @user.route('/logout/')
def logout_user(): def logout_user():
if 'username' in flask.session: if 'username' in flask.session:
flask.session.pop('username') flask.session.pop('username')
return flask.redirect('/') return flask.redirect('/')
# Check User file exists # Check User file exists
if not os.path.exists(USERS_PATH): if not os.path.exists(USERS_PATH):
with open(USERS_PATH, 'w+') as file: with open(USERS_PATH, 'w+') as file:
file.write('{}') file.write('{}')