diff --git a/app/app.py b/app/app.py index f4c519d..ebef179 100644 --- a/app/app.py +++ b/app/app.py @@ -48,7 +48,7 @@ statuses = {} def get_posts(category_filter : str | None = None) -> list[tuple[dict, list]]: post_files = glob.glob(f'{POSTS_FOLDER}/*') try: - post_files.remove(f'{POSTS_FOLDER}/POST_TEMPLATE.md') + 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}') diff --git a/app/comment.py b/app/comment.py index 1aa046d..f00c013 100644 --- a/app/comment.py +++ b/app/comment.py @@ -1,61 +1,64 @@ -import json -import os - -import flask -import flask_wtf.csrf -import wtforms - -COMMENTS_PATH = "./data/comments.json" -comments = flask.Blueprint('comment', __name__, template_folder='./templates') - -class CommentForm(flask_wtf.FlaskForm): - textbox = wtforms.TextAreaField('Input') - -@comments.route('/comment/', methods=['POST']) -def comment(post_title: str): - form = CommentForm(csrf_enabled=True) - - save_comment(form.textbox.data, post_title) - - return flask.redirect('/') - -def save_comment(content: str, post_title: str): - with open(COMMENTS_PATH, 'r') as file: - comment_data = json.loads(file.read()) - - # See if user is logged in, otherwise setup as anon - if 'username' in flask.session: - username = flask.session['username'] - else: - username = 'Anon' - - comment = { - "username" : username, - "content" : content - } - - # Add comment to JSON data - if post_title in comment_data: - comment_data[post_title].append(comment) - else: - comment_data[post_title] = [comment] - - # Save JSON data - with open(COMMENTS_PATH, 'w') as file: - file.write(json.dumps(comment_data)) - -def get_comments(post_title : int) -> list[dict]: - - with open(COMMENTS_PATH, 'r') as file: - comment_data = json.loads(file.read()) - - if post_title in comment_data: - return comment_data[post_title] - else: - return [] - -# Check Comments file exists -if not os.path.exists(COMMENTS_PATH): - with open(COMMENTS_PATH, 'w+') as file: - file.write('{}') - +import json +import os + +import flask +import flask_wtf.csrf +import wtforms + +COMMENTS_PATH = "./data/comments.json" + +if not os.path.exists('./data/'): + os.mkdir('./data/') + +if not os.path.exists(COMMENTS_PATH): + with open(COMMENTS_PATH, 'w+') as file: + file.write('{}') + +comments = flask.Blueprint('comment', __name__, template_folder='./templates') + +class CommentForm(flask_wtf.FlaskForm): + textbox = wtforms.TextAreaField('Input') + +@comments.route('/comment/', methods=['POST']) +def comment(post_title: str): + form = CommentForm(csrf_enabled=True) + + save_comment(form.textbox.data, post_title) + + return flask.redirect('/') + +def save_comment(content: str, post_title: str): + with open(COMMENTS_PATH, 'r') as file: + comment_data = json.loads(file.read()) + + # See if user is logged in, otherwise setup as anon + if 'username' in flask.session: + username = flask.session['username'] + else: + username = 'Anon' + + comment = { + "username" : username, + "content" : content + } + + # Add comment to JSON data + if post_title in comment_data: + comment_data[post_title].append(comment) + else: + comment_data[post_title] = [comment] + + # Save JSON data + with open(COMMENTS_PATH, 'w') as file: + file.write(json.dumps(comment_data)) + +def get_comments(post_title : int) -> list[dict]: + + with open(COMMENTS_PATH, 'r') as file: + comment_data = json.loads(file.read()) + + if post_title in comment_data: + return comment_data[post_title] + else: + return [] + diff --git a/app/static/albumsquare.css b/app/static/albumsquare.css index 1044b3d..3e19492 100644 --- a/app/static/albumsquare.css +++ b/app/static/albumsquare.css @@ -1,19 +1,19 @@ -.albums { - height: 100%; - - line-height: 0; - font-size: 0; -} - -.albums img { - padding: 0 0; - margin: 0 0; - border: 0 0; -} - - -.body { - height: 100%; - padding: 0 0; - margin: 0 0; -} +.albums { + height: 100%; + + line-height: 0; + font-size: 0; +} + +.albums img { + padding: 0 0; + margin: 0 0; + border: 0 0; +} + + +.body { + height: 100%; + padding: 0 0; + margin: 0 0; +} diff --git a/app/static/canal-banner1.jpg b/app/static/canal-banner1.jpg new file mode 100644 index 0000000..19b65f5 Binary files /dev/null and b/app/static/canal-banner1.jpg differ diff --git a/app/static/deadwell-banner.png b/app/static/deadwell-banner.png new file mode 100644 index 0000000..181aa52 Binary files /dev/null and b/app/static/deadwell-banner.png differ diff --git a/app/static/game_screenshots/darkthroat_bottom.jpg b/app/static/game_screenshots/darkthroat_bottom.jpg new file mode 100644 index 0000000..64f6a37 Binary files /dev/null and b/app/static/game_screenshots/darkthroat_bottom.jpg differ diff --git a/app/static/game_screenshots/darkthroat_whirlpool.jpg b/app/static/game_screenshots/darkthroat_whirlpool.jpg new file mode 100644 index 0000000..c818263 Binary files /dev/null and b/app/static/game_screenshots/darkthroat_whirlpool.jpg differ diff --git a/app/static/game_screenshots/deadwell_bridge.jpg b/app/static/game_screenshots/deadwell_bridge.jpg new file mode 100644 index 0000000..10b218e Binary files /dev/null and b/app/static/game_screenshots/deadwell_bridge.jpg differ diff --git a/app/static/game_screenshots/fallcrush.jpg b/app/static/game_screenshots/fallcrush.jpg new file mode 100644 index 0000000..8a36763 Binary files /dev/null and b/app/static/game_screenshots/fallcrush.jpg differ diff --git a/app/static/game_screenshots/greensilt_overlook.jpg b/app/static/game_screenshots/greensilt_overlook.jpg new file mode 100644 index 0000000..f692789 Binary files /dev/null and b/app/static/game_screenshots/greensilt_overlook.jpg differ diff --git a/app/static/game_screenshots/greensilt_tower.jpg b/app/static/game_screenshots/greensilt_tower.jpg new file mode 100644 index 0000000..cb68698 Binary files /dev/null and b/app/static/game_screenshots/greensilt_tower.jpg differ diff --git a/app/static/game_screenshots/nokkpond.jpg b/app/static/game_screenshots/nokkpond.jpg new file mode 100644 index 0000000..afe6238 Binary files /dev/null and b/app/static/game_screenshots/nokkpond.jpg differ diff --git a/app/static/game_screenshots/nokkpond_mountians.jpg b/app/static/game_screenshots/nokkpond_mountians.jpg new file mode 100644 index 0000000..6018657 Binary files /dev/null and b/app/static/game_screenshots/nokkpond_mountians.jpg differ diff --git a/app/static/game_screenshots/sourwood_bridge_1.jpg b/app/static/game_screenshots/sourwood_bridge_1.jpg new file mode 100644 index 0000000..852980a Binary files /dev/null and b/app/static/game_screenshots/sourwood_bridge_1.jpg differ diff --git a/app/static/game_screenshots/sourwood_bridge_2.jpg b/app/static/game_screenshots/sourwood_bridge_2.jpg new file mode 100644 index 0000000..85692d8 Binary files /dev/null and b/app/static/game_screenshots/sourwood_bridge_2.jpg differ diff --git a/app/static/greensilt-banner-2.png b/app/static/greensilt-banner-2.png new file mode 100644 index 0000000..1d56df5 Binary files /dev/null and b/app/static/greensilt-banner-2.png differ diff --git a/app/static/greensilt-banner-3.png b/app/static/greensilt-banner-3.png new file mode 100644 index 0000000..653fc38 Binary files /dev/null and b/app/static/greensilt-banner-3.png differ diff --git a/app/static/greensilt-banner-scaled.png b/app/static/greensilt-banner-scaled.png new file mode 100644 index 0000000..3582576 Binary files /dev/null and b/app/static/greensilt-banner-scaled.png differ diff --git a/app/static/greensilt-banner.png b/app/static/greensilt-banner.png new file mode 100644 index 0000000..4fa44ed Binary files /dev/null and b/app/static/greensilt-banner.png differ diff --git a/app/static/programming/vscode_extensions.txt b/app/static/programming/vscode_extensions.txt index a0edf1d..776d9f8 100644 --- a/app/static/programming/vscode_extensions.txt +++ b/app/static/programming/vscode_extensions.txt @@ -1,12 +1,12 @@ -EOF Mark, -Glassit-VSC, -JSON formatter, -Pylance, -Remote - SSH, -Synthwave '84 Blues, -Trailing Spaces, -Helm Intellisense, -background, -Helium Icon Theme, -SQLite Viewer, +EOF Mark, +Glassit-VSC, +JSON formatter, +Pylance, +Remote - SSH, +Synthwave '84 Blues, +Trailing Spaces, +Helm Intellisense, +background, +Helium Icon Theme, +SQLite Viewer, Docker \ No newline at end of file diff --git a/app/static/real-greensilt-banner.png b/app/static/real-greensilt-banner.png new file mode 100644 index 0000000..40dc64d Binary files /dev/null and b/app/static/real-greensilt-banner.png differ diff --git a/app/static/render.jpg b/app/static/render.jpg new file mode 100644 index 0000000..20fa233 Binary files /dev/null and b/app/static/render.jpg differ diff --git a/app/static/render.png b/app/static/render.png new file mode 100644 index 0000000..8eb2971 Binary files /dev/null and b/app/static/render.png differ diff --git a/app/static/roland_think.png b/app/static/roland_think.png new file mode 100644 index 0000000..7b9564f Binary files /dev/null and b/app/static/roland_think.png differ diff --git a/app/static/style.css b/app/static/style.css index 9bdca92..524e8e1 100644 --- a/app/static/style.css +++ b/app/static/style.css @@ -12,8 +12,9 @@ h1, h2, h3, h4, h5 { } html { - --text: hsl(224, 83%, 91%); - --background: hsl(224, 31%, 23%); + --text: black; + --background: #c0c0b0; + /* --background: #2b2d31; */ --primary: hsl(229, 81%, 73%); --primary10: hsla(209, 61%, 71%, 10%); --primary20: hsla(209, 61%, 71%, 20%); @@ -70,15 +71,19 @@ li { /* Other */ .header { + background-image: url("render.jpg"); + background-size: cover; text-align: center; - margin: 0 30%; - padding: 2em; + margin: 2em 25%; + padding: 3em; border-style: var(--borders-style); border-color: #1E2022; background-color: var(--background); border-radius: var(--border-radius); + + color: white; } .header a { @@ -91,7 +96,7 @@ li { display: flex; flex-direction: row; - margin: 0px 5%; + margin: 0px 20%; border-style: var(--borders-style); border-color: #1E2022; @@ -223,6 +228,7 @@ li { } .post p { + font-family: Verdana, Geneva, sans-serif; line-height: 2.25; text-indent: 3em; } diff --git a/app/static/yosemite-banner.png b/app/static/yosemite-banner.png new file mode 100644 index 0000000..f40f3f5 Binary files /dev/null and b/app/static/yosemite-banner.png differ diff --git a/app/static/yosemite.png b/app/static/yosemite.png new file mode 100644 index 0000000..f348d54 Binary files /dev/null and b/app/static/yosemite.png differ diff --git a/app/templates/album_square.html b/app/templates/album_square.html index ca6d024..ec65fba 100644 --- a/app/templates/album_square.html +++ b/app/templates/album_square.html @@ -1,20 +1,20 @@ - - -
- - - Album Square -
- -
- {% for album in top_albums %} - - - - {% if loop.index % limit == 0 %} -
- {% endif %} - {% endfor %} -
- - + + +
+ + + Album Square +
+ +
+ {% for album in top_albums %} + + + + {% if loop.index % limit == 0 %} +
+ {% endif %} + {% endfor %} +
+ + diff --git a/app/templates/user/login.html b/app/templates/user/login.html index 9659b9c..6d045ad 100644 --- a/app/templates/user/login.html +++ b/app/templates/user/login.html @@ -1,40 +1,40 @@ - - -
- - - 0x01fe.net - Login -
- -
-

0x01fe.net

- {{ status|safe }} -
-
- - - -
-

Login

-
- {{ form.hidden_tag() }} - Username: {{ form.username }}
- Password: {{ form.password }}
- -
-
- -

Need to Register?

- Register -
-
- - + + +
+ + + 0x01fe.net - Login +
+ +
+

0x01fe.net

+ {{ status|safe }} +
+
+ + + +
+

Login

+
+ {{ form.hidden_tag() }} + Username: {{ form.username }}
+ Password: {{ form.password }}
+ +
+
+ +

Need to Register?

+ Register +
+
+ + diff --git a/app/templates/user/register.html b/app/templates/user/register.html index b5cc4da..ee8ac99 100644 --- a/app/templates/user/register.html +++ b/app/templates/user/register.html @@ -1,36 +1,36 @@ - - -
- - - 0x01fe.net - Register -
- -
-

0x01fe.net

- {{ status|safe }} -
-
- - - -
-

Register

-
- {{ form.hidden_tag() }} - Username: {{ form.username }}
- Password: {{ form.password }}
- -
-
-
- - + + +
+ + + 0x01fe.net - Register +
+ +
+

0x01fe.net

+ {{ status|safe }} +
+
+ + + +
+

Register

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