Reorganise images in static folder

Run black
This commit is contained in:
Michał Gdula 2023-06-12 20:15:17 +01:00
parent da142b2bc4
commit 76e7ec2058
15 changed files with 35 additions and 15 deletions

View file

@ -50,6 +50,7 @@ def load_user(user_id):
def error_page(err):
if not isinstance(err, HTTPException):
abort(500)
return (
render_template(
"error.html", error=err.code, msg=err.description, image=str(randint(1, 3))

View file

@ -7,7 +7,14 @@ from werkzeug.security import check_password_hash
from server.models import Scores, Sessions, Users
from server.extensions import db
from server.config import GAME_VERSION, GAME_VERSIONS, GAME_DIFFICULTIES, USER_MAX_TOKENS, MAX_SEARCH_RESULTS, USER_REGEX
from server.config import (
GAME_VERSION,
GAME_VERSIONS,
GAME_DIFFICULTIES,
USER_MAX_TOKENS,
MAX_SEARCH_RESULTS,
USER_REGEX,
)
blueprint = Blueprint("api", __name__, url_prefix="/api")
@ -85,7 +92,11 @@ def search():
if not search_arg:
return "No search query provided!", 400
users = Users.query.filter(Users.username.icontains(search_arg)).limit(MAX_SEARCH_RESULTS).all()
users = (
Users.query.filter(Users.username.icontains(search_arg))
.limit(MAX_SEARCH_RESULTS)
.all()
)
return jsonify([user.username for user in users])
@ -109,7 +120,7 @@ def login():
user_id=user.id,
auth_key=str(shortuuid.ShortUUID().random(length=32)),
ip_address=request.remote_addr,
device_type=device
device_type=device,
)
db.session.add(session)
db.session.commit()
@ -128,4 +139,4 @@ def authenticate():
user_data = Users.query.filter_by(id=session.user_id).first()
return jsonify({'username':user_data.username})
return jsonify({"username": user_data.username})

View file

@ -30,4 +30,4 @@ INSTANCE_DIR = "/data/storage/instance"
# SQLite
SECRET_KEY = "dev"
SQLALCHEMY_DATABASE_URI = "sqlite:///tfr.db"
"""
"""

View file

@ -14,6 +14,7 @@ class Scores(db.Model):
then the username must be provided. Otherwise, it's grabbed from the user
table
"""
id = db.Column(db.Integer, primary_key=True)
score = db.Column(db.Float, nullable=False)
@ -37,6 +38,7 @@ class Sessions(db.Model):
"""
Sessions table
"""
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey("users.id", use_alter=True))
auth_key = db.Column(db.String, nullable=False, unique=True)
@ -58,6 +60,7 @@ class Users(db.Model, UserMixin):
"""
User table
"""
id = db.Column(db.Integer, primary_key=True)
alt_id = db.Column(db.String, nullable=False, unique=True)
@ -69,9 +72,8 @@ class Users(db.Model, UserMixin):
server_default=db.func.now(),
)
scores = db.relationship("Scores", backref=db.backref('users', lazy=True))
tokens = db.relationship("Sessions", backref=db.backref('users', lazy=True))
scores = db.relationship("Scores", backref=db.backref("users", lazy=True))
tokens = db.relationship("Sessions", backref=db.backref("users", lazy=True))
def get_id(self):
return str(self.alt_id)

View file

Before

Width:  |  Height:  |  Size: 570 KiB

After

Width:  |  Height:  |  Size: 570 KiB

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View file

Before

Width:  |  Height:  |  Size: 400 KiB

After

Width:  |  Height:  |  Size: 400 KiB

View file

Before

Width:  |  Height:  |  Size: 165 KiB

After

Width:  |  Height:  |  Size: 165 KiB

View file

Before

Width:  |  Height:  |  Size: 708 KiB

After

Width:  |  Height:  |  Size: 708 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

View file

Before

Width:  |  Height:  |  Size: 152 KiB

After

Width:  |  Height:  |  Size: 152 KiB

View file

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View file

@ -1,10 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Front Rooms Highscores</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Front Rooms Highscores</title>
<meta name=description content="The Front Rooms official website">
<meta name=author content="Project Redacted">
<meta name="favicon" content="{{ url_for('static', filename='images/icon.png') }}">
<script src="https://unpkg.com/@phosphor-icons/web"></script>
{% assets "scripts" %}<script src="{{ ASSET_URL }}"></script>{% endassets %}
@ -16,8 +20,8 @@
</div>
<picture class="background">
<source srcset="{{ url_for('static', filename='background.webp') }}">
<img src="{{ url_for('static', filename='background.png') }}" alt="The Front Rooms Level select render">
<source srcset="{{ url_for('static', filename='images/background.webp') }}">
<img src="{{ url_for('static', filename='images/background.png') }}" alt="The Front Rooms Level select render">
</picture>
<div class="app">
@ -34,8 +38,8 @@
<header>
<picture class="title">
<source srcset="{{ url_for('static', filename='title.webp') }}">
<img src="{{ url_for('static', filename='title.png') }}" alt="The Front Rooms logo">
<source srcset="{{ url_for('static', filename='images/title.webp') }}">
<img src="{{ url_for('static', filename='images/title.png') }}" alt="The Front Rooms logo">
</picture>
<nav>

View file

@ -3,6 +3,6 @@
<div class="center-text">
<h2>{{ error }}</h2>
<p>{{ msg }}</p>
<image src="{{ url_for('static', filename='error-images/' + image + '.jpg') }}" alt="Error">
<image src="{{ url_for('static', filename='images/error/' + image + '.jpg') }}" alt="Error">
</div>
{% endblock %}

View file

@ -25,7 +25,9 @@ def index():
scores = scores.order_by(Scores.score.asc()).limit(MAX_TOP_SCORES).all()
return render_template("scores.html", scores=scores, diff=int(diff_arg), ver=ver_arg, user=user_arg)
return render_template(
"scores.html", scores=scores, diff=int(diff_arg), ver=ver_arg, user=user_arg
)
@blueprint.route("/about")