Reorganise images in static folder
Run black
|
@ -50,6 +50,7 @@ def load_user(user_id):
|
||||||
def error_page(err):
|
def error_page(err):
|
||||||
if not isinstance(err, HTTPException):
|
if not isinstance(err, HTTPException):
|
||||||
abort(500)
|
abort(500)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
render_template(
|
render_template(
|
||||||
"error.html", error=err.code, msg=err.description, image=str(randint(1, 3))
|
"error.html", error=err.code, msg=err.description, image=str(randint(1, 3))
|
||||||
|
|
|
@ -7,7 +7,14 @@ from werkzeug.security import check_password_hash
|
||||||
|
|
||||||
from server.models import Scores, Sessions, Users
|
from server.models import Scores, Sessions, Users
|
||||||
from server.extensions import db
|
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")
|
blueprint = Blueprint("api", __name__, url_prefix="/api")
|
||||||
|
@ -85,7 +92,11 @@ def search():
|
||||||
if not search_arg:
|
if not search_arg:
|
||||||
return "No search query provided!", 400
|
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])
|
return jsonify([user.username for user in users])
|
||||||
|
|
||||||
|
@ -109,7 +120,7 @@ def login():
|
||||||
user_id=user.id,
|
user_id=user.id,
|
||||||
auth_key=str(shortuuid.ShortUUID().random(length=32)),
|
auth_key=str(shortuuid.ShortUUID().random(length=32)),
|
||||||
ip_address=request.remote_addr,
|
ip_address=request.remote_addr,
|
||||||
device_type=device
|
device_type=device,
|
||||||
)
|
)
|
||||||
db.session.add(session)
|
db.session.add(session)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
@ -128,4 +139,4 @@ def authenticate():
|
||||||
|
|
||||||
user_data = Users.query.filter_by(id=session.user_id).first()
|
user_data = Users.query.filter_by(id=session.user_id).first()
|
||||||
|
|
||||||
return jsonify({'username':user_data.username})
|
return jsonify({"username": user_data.username})
|
||||||
|
|
|
@ -14,6 +14,7 @@ class Scores(db.Model):
|
||||||
then the username must be provided. Otherwise, it's grabbed from the user
|
then the username must be provided. Otherwise, it's grabbed from the user
|
||||||
table
|
table
|
||||||
"""
|
"""
|
||||||
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
|
||||||
score = db.Column(db.Float, nullable=False)
|
score = db.Column(db.Float, nullable=False)
|
||||||
|
@ -37,6 +38,7 @@ class Sessions(db.Model):
|
||||||
"""
|
"""
|
||||||
Sessions table
|
Sessions table
|
||||||
"""
|
"""
|
||||||
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
user_id = db.Column(db.Integer, db.ForeignKey("users.id", use_alter=True))
|
user_id = db.Column(db.Integer, db.ForeignKey("users.id", use_alter=True))
|
||||||
auth_key = db.Column(db.String, nullable=False, unique=True)
|
auth_key = db.Column(db.String, nullable=False, unique=True)
|
||||||
|
@ -58,6 +60,7 @@ class Users(db.Model, UserMixin):
|
||||||
"""
|
"""
|
||||||
User table
|
User table
|
||||||
"""
|
"""
|
||||||
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
alt_id = db.Column(db.String, nullable=False, unique=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(),
|
server_default=db.func.now(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
scores = db.relationship("Scores", 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))
|
||||||
tokens = db.relationship("Sessions", backref=db.backref('users', lazy=True))
|
|
||||||
|
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
return str(self.alt_id)
|
return str(self.alt_id)
|
||||||
|
|
Before Width: | Height: | Size: 570 KiB After Width: | Height: | Size: 570 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 400 KiB After Width: | Height: | Size: 400 KiB |
Before Width: | Height: | Size: 165 KiB After Width: | Height: | Size: 165 KiB |
Before Width: | Height: | Size: 708 KiB After Width: | Height: | Size: 708 KiB |
BIN
TFR/server/static/images/logo.png
Normal file
After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 152 KiB After Width: | Height: | Size: 152 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
@ -1,10 +1,14 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
<title>Front Rooms Highscores</title>
|
||||||
|
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<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>
|
<script src="https://unpkg.com/@phosphor-icons/web"></script>
|
||||||
{% assets "scripts" %}<script src="{{ ASSET_URL }}"></script>{% endassets %}
|
{% assets "scripts" %}<script src="{{ ASSET_URL }}"></script>{% endassets %}
|
||||||
|
@ -16,8 +20,8 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<picture class="background">
|
<picture class="background">
|
||||||
<source srcset="{{ url_for('static', filename='background.webp') }}">
|
<source srcset="{{ url_for('static', filename='images/background.webp') }}">
|
||||||
<img src="{{ url_for('static', filename='background.png') }}" alt="The Front Rooms Level select render">
|
<img src="{{ url_for('static', filename='images/background.png') }}" alt="The Front Rooms Level select render">
|
||||||
</picture>
|
</picture>
|
||||||
|
|
||||||
<div class="app">
|
<div class="app">
|
||||||
|
@ -34,8 +38,8 @@
|
||||||
|
|
||||||
<header>
|
<header>
|
||||||
<picture class="title">
|
<picture class="title">
|
||||||
<source srcset="{{ url_for('static', filename='title.webp') }}">
|
<source srcset="{{ url_for('static', filename='images/title.webp') }}">
|
||||||
<img src="{{ url_for('static', filename='title.png') }}" alt="The Front Rooms logo">
|
<img src="{{ url_for('static', filename='images/title.png') }}" alt="The Front Rooms logo">
|
||||||
</picture>
|
</picture>
|
||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
<div class="center-text">
|
<div class="center-text">
|
||||||
<h2>{{ error }}</h2>
|
<h2>{{ error }}</h2>
|
||||||
<p>{{ msg }}</p>
|
<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>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -25,7 +25,9 @@ def index():
|
||||||
|
|
||||||
scores = scores.order_by(Scores.score.asc()).limit(MAX_TOP_SCORES).all()
|
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")
|
@blueprint.route("/about")
|
||||||
|
|