2022-11-13 17:56:59 +01:00
|
|
|
import mimetypes
|
2019-12-08 22:43:49 +01:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import traceback
|
|
|
|
from typing import Callable, Dict, Any, Optional, List
|
|
|
|
from react.jsx import JSXTransformer # type: ignore
|
2022-10-15 20:56:30 +02:00
|
|
|
from flask import (
|
|
|
|
Flask,
|
|
|
|
flash,
|
|
|
|
request,
|
|
|
|
redirect,
|
|
|
|
Response,
|
|
|
|
url_for,
|
2022-11-13 17:56:59 +01:00
|
|
|
abort,
|
2022-10-15 20:56:30 +02:00
|
|
|
render_template,
|
|
|
|
got_request_exception,
|
|
|
|
jsonify as flask_jsonify,
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
from functools import wraps
|
|
|
|
|
2023-08-13 20:56:43 +02:00
|
|
|
from bemani.common import AESCipher, GameConstants, cache
|
2021-08-20 06:43:59 +02:00
|
|
|
from bemani.data import Config, Data
|
2021-05-20 00:38:00 +02:00
|
|
|
from bemani.frontend.types import g
|
2019-12-08 22:43:49 +01:00
|
|
|
from bemani.frontend.templates import templates_location
|
|
|
|
from bemani.frontend.static import static_location
|
|
|
|
|
|
|
|
app = Flask(
|
|
|
|
__name__,
|
|
|
|
template_folder=templates_location,
|
|
|
|
static_folder=static_location,
|
|
|
|
)
|
2021-08-20 06:43:59 +02:00
|
|
|
config = Config()
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
|
2022-10-09 00:40:28 +02:00
|
|
|
# Allow cache-busting of entire frontend for major changes such as react upgrades.
|
2023-03-19 20:18:00 +01:00
|
|
|
FRONTEND_CACHE_BUST: str = "site.1.3.react.16.14"
|
2022-10-09 00:40:28 +02:00
|
|
|
|
|
|
|
|
2019-12-08 22:43:49 +01:00
|
|
|
@app.before_request
|
|
|
|
def before_request() -> None:
|
|
|
|
global config
|
2023-08-13 20:56:43 +02:00
|
|
|
|
|
|
|
g.cache = cache
|
|
|
|
g.config = config
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
if request.endpoint in ["jsx", "static"]:
|
2019-12-08 22:43:49 +01:00
|
|
|
# This is just serving cached compiled frontends, skip loading from DB
|
|
|
|
return
|
|
|
|
|
|
|
|
g.data = Data(config)
|
|
|
|
g.sessionID = None
|
|
|
|
g.userID = None
|
|
|
|
try:
|
2021-08-20 06:43:59 +02:00
|
|
|
aes = AESCipher(config.secret_key)
|
2022-10-15 20:56:30 +02:00
|
|
|
sessionID = aes.decrypt(request.cookies.get("SessionID"))
|
2019-12-08 22:43:49 +01:00
|
|
|
except Exception:
|
|
|
|
sessionID = None
|
|
|
|
g.sessionID = sessionID
|
|
|
|
if sessionID is not None:
|
|
|
|
g.userID = g.data.local.user.from_session(sessionID)
|
|
|
|
else:
|
|
|
|
g.userID = None
|
|
|
|
|
|
|
|
|
2020-04-28 01:31:59 +02:00
|
|
|
@app.after_request
|
|
|
|
def after_request(response: Response) -> Response:
|
|
|
|
if not response.cache_control.max_age:
|
|
|
|
# Make sure our REST calls don't get cached, so that the
|
|
|
|
# live pages update in real-time.
|
|
|
|
response.cache_control.no_cache = True
|
|
|
|
response.cache_control.must_revalidate = True
|
|
|
|
response.cache_control.private = True
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
2019-12-08 22:43:49 +01:00
|
|
|
@app.teardown_request
|
|
|
|
def teardown_request(exception: Any) -> None:
|
2022-10-15 20:56:30 +02:00
|
|
|
data = getattr(g, "data", None)
|
2019-12-08 22:43:49 +01:00
|
|
|
if data is not None:
|
|
|
|
data.close()
|
|
|
|
|
|
|
|
|
|
|
|
def loginrequired(func: Callable) -> Callable:
|
|
|
|
@wraps(func)
|
|
|
|
def decoratedfunction(*args: Any, **kwargs: Any) -> Response:
|
|
|
|
if g.userID is None:
|
2022-10-15 20:56:30 +02:00
|
|
|
return redirect(url_for("account_pages.viewlogin")) # type: ignore
|
2019-12-08 22:43:49 +01:00
|
|
|
else:
|
|
|
|
return func(*args, **kwargs)
|
2022-10-15 20:56:30 +02:00
|
|
|
|
2019-12-08 22:43:49 +01:00
|
|
|
return decoratedfunction
|
|
|
|
|
|
|
|
|
|
|
|
def adminrequired(func: Callable) -> Callable:
|
|
|
|
@wraps(func)
|
|
|
|
def decoratedfunction(*args: Any, **kwargs: Any) -> Response:
|
|
|
|
if g.userID is None:
|
2022-10-15 20:56:30 +02:00
|
|
|
return redirect(url_for("account_pages.viewlogin")) # type: ignore
|
2019-12-08 22:43:49 +01:00
|
|
|
else:
|
|
|
|
user = g.data.local.user.get_user(g.userID)
|
|
|
|
if not user.admin:
|
2022-10-15 20:56:30 +02:00
|
|
|
return Response(
|
|
|
|
render_template("403.html", **{"title": "403 Forbidden"}), 403
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
else:
|
|
|
|
return func(*args, **kwargs)
|
2022-10-15 20:56:30 +02:00
|
|
|
|
2019-12-08 22:43:49 +01:00
|
|
|
return decoratedfunction
|
|
|
|
|
|
|
|
|
|
|
|
def loginprohibited(func: Callable) -> Callable:
|
|
|
|
@wraps(func)
|
|
|
|
def decoratedfunction(*args: Any, **kwargs: Any) -> Response:
|
|
|
|
if g.userID is not None:
|
2022-10-15 20:56:30 +02:00
|
|
|
return redirect(url_for("home_pages.viewhome")) # type: ignore
|
2019-12-08 22:43:49 +01:00
|
|
|
else:
|
|
|
|
return func(*args, **kwargs)
|
2022-10-15 20:56:30 +02:00
|
|
|
|
2019-12-08 22:43:49 +01:00
|
|
|
return decoratedfunction
|
|
|
|
|
|
|
|
|
|
|
|
def jsonify(func: Callable) -> Callable:
|
|
|
|
@wraps(func)
|
|
|
|
def decoratedfunction(*args: Any, **kwargs: Any) -> Response:
|
|
|
|
try:
|
|
|
|
return flask_jsonify(func(*args, **kwargs))
|
|
|
|
except Exception as e:
|
|
|
|
print(traceback.format_exc())
|
2022-10-15 20:56:30 +02:00
|
|
|
return flask_jsonify(
|
|
|
|
{
|
|
|
|
"error": True,
|
|
|
|
"message": str(e),
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2019-12-08 22:43:49 +01:00
|
|
|
return decoratedfunction
|
|
|
|
|
|
|
|
|
|
|
|
def cacheable(max_age: int) -> Callable:
|
|
|
|
def __cache(func: Callable) -> Callable:
|
|
|
|
@wraps(func)
|
|
|
|
def decoratedfunction(*args: Any, **kwargs: Any) -> Response:
|
|
|
|
response = func(*args, **kwargs)
|
|
|
|
response.cache_control.max_age = max_age
|
|
|
|
return response
|
2022-10-15 20:56:30 +02:00
|
|
|
|
2019-12-08 22:43:49 +01:00
|
|
|
return decoratedfunction
|
2022-10-15 20:56:30 +02:00
|
|
|
|
2019-12-08 22:43:49 +01:00
|
|
|
return __cache
|
|
|
|
|
|
|
|
|
2022-11-13 17:56:59 +01:00
|
|
|
# Note that this should really only be used for debug builds. In production, you should use
|
|
|
|
# the "jsx" utility to bulk convert your JSX files and put them in a directory where your
|
|
|
|
# actual webserver (nginx, apache, etc) can find them and serve them without going through
|
|
|
|
# this endpoint.
|
2022-10-15 20:56:30 +02:00
|
|
|
@app.route("/jsx/<path:filename>")
|
2019-12-08 22:43:49 +01:00
|
|
|
@cacheable(86400)
|
|
|
|
def jsx(filename: str) -> Response:
|
2021-08-31 23:40:54 +02:00
|
|
|
try:
|
|
|
|
# Figure out what our update time is to namespace on
|
|
|
|
jsxfile = os.path.join(static_location, filename)
|
|
|
|
normalized_path = os.path.normpath(jsxfile)
|
|
|
|
# Check for path traversal exploit
|
|
|
|
if not normalized_path.startswith(static_location):
|
|
|
|
raise IOError("Path traversal exploit detected!")
|
|
|
|
mtime = os.path.getmtime(jsxfile)
|
2022-10-15 20:56:30 +02:00
|
|
|
namespace = f"{mtime}.{jsxfile}"
|
2021-08-31 23:40:54 +02:00
|
|
|
jsx = g.cache.get(namespace)
|
|
|
|
if jsx is None:
|
2022-10-15 20:56:30 +02:00
|
|
|
with open(jsxfile, "rb") as f:
|
2021-08-31 23:40:54 +02:00
|
|
|
transformer = JSXTransformer()
|
2022-10-15 20:56:30 +02:00
|
|
|
jsx = transformer.transform_string(
|
|
|
|
polyfill_fragments(f.read().decode("utf-8"))
|
|
|
|
)
|
2021-08-31 23:40:54 +02:00
|
|
|
# Set the cache to one year, since we namespace on this file's update time
|
|
|
|
g.cache.set(namespace, jsx, timeout=86400 * 365)
|
2022-10-15 20:56:30 +02:00
|
|
|
return Response(jsx, mimetype="application/javascript")
|
2021-08-31 23:40:54 +02:00
|
|
|
except Exception as exception:
|
|
|
|
if app.debug:
|
|
|
|
# We should make sure this error shows up on the frontend
|
|
|
|
# much like python or template errors do.
|
2022-10-15 20:56:30 +02:00
|
|
|
stack = "".join(
|
|
|
|
traceback.format_exception(
|
|
|
|
type(exception), exception, exception.__traceback__
|
|
|
|
)
|
|
|
|
)
|
2021-08-31 23:40:54 +02:00
|
|
|
stack = stack.replace('"', '\\"')
|
2022-10-15 20:56:30 +02:00
|
|
|
stack = stack.replace("\r\n", "\\n")
|
|
|
|
stack = stack.replace("\r", "\\n")
|
|
|
|
stack = stack.replace("\n", "\\n")
|
2021-08-31 23:40:54 +02:00
|
|
|
return Response(
|
2022-10-15 20:56:30 +02:00
|
|
|
'$("ul.messages").append("<li class=\\"error\\">JSX transform error in <code>'
|
|
|
|
+ filename
|
|
|
|
+ "</code><br /><br /><pre>"
|
|
|
|
+ stack
|
|
|
|
+ '</li>");',
|
|
|
|
mimetype="application/javascript",
|
2021-08-31 23:40:54 +02:00
|
|
|
)
|
|
|
|
else:
|
|
|
|
# Just pass it forward like normal for production.
|
|
|
|
raise
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
|
2022-11-13 17:56:59 +01:00
|
|
|
# Note that this should really only be used for debug builds. In production, you should use
|
|
|
|
# the "assetparse" utility to bulk convert your game asset files and put them in directories
|
|
|
|
# where your actual webserver (nginx, apache, etc) can find them and serve them without
|
|
|
|
# going through this endpoint.
|
|
|
|
@app.route("/assets/<path:filename>")
|
|
|
|
@cacheable(86400)
|
|
|
|
def assets(filename: str) -> Response:
|
|
|
|
# Map of all assets. We could walk the config using reflection, but meh.
|
|
|
|
assetdirs: Dict[str, str] = {
|
|
|
|
"jubeat/emblems/": config.assets.jubeat.emblems,
|
|
|
|
}
|
|
|
|
|
|
|
|
# Figure out what asset pack this is from.
|
|
|
|
for prefix, directory in assetdirs.items():
|
|
|
|
if filename.startswith(prefix):
|
|
|
|
filename = filename[len(prefix) :]
|
|
|
|
normalized_path = os.path.join(directory, filename)
|
|
|
|
|
|
|
|
# Check for path traversal exploit
|
|
|
|
if not normalized_path.startswith(directory):
|
|
|
|
raise IOError("Path traversal exploit detected!")
|
|
|
|
|
|
|
|
mimetype, _ = mimetypes.guess_type(normalized_path)
|
|
|
|
with open(normalized_path, "rb") as f:
|
|
|
|
return Response(f.read(), mimetype=mimetype)
|
|
|
|
else:
|
|
|
|
# No asset for this.
|
|
|
|
abort(404)
|
|
|
|
|
|
|
|
|
2022-10-08 23:26:48 +02:00
|
|
|
def polyfill_fragments(jsx: str) -> str:
|
|
|
|
jsx = jsx.replace("<>", "<React.Fragment>")
|
|
|
|
jsx = jsx.replace("</>", "</React.Fragment>")
|
|
|
|
return jsx
|
|
|
|
|
|
|
|
|
2019-12-08 22:43:49 +01:00
|
|
|
def render_react(
|
|
|
|
title: str,
|
|
|
|
controller: str,
|
2022-10-15 20:56:30 +02:00
|
|
|
inits: Optional[Dict[str, Any]] = None,
|
|
|
|
links: Optional[Dict[str, Any]] = None,
|
2019-12-08 22:43:49 +01:00
|
|
|
) -> Response:
|
|
|
|
if links is None:
|
|
|
|
links = {}
|
|
|
|
if inits is None:
|
|
|
|
inits = {}
|
2022-10-15 20:56:30 +02:00
|
|
|
links["static"] = url_for("static", filename="-1")
|
|
|
|
|
|
|
|
return Response(
|
|
|
|
render_template(
|
|
|
|
"react.html",
|
|
|
|
**{
|
|
|
|
"title": title,
|
2022-11-01 05:22:58 +01:00
|
|
|
"reactbase": f"controllers/{controller}",
|
2022-10-15 20:56:30 +02:00
|
|
|
"inits": inits,
|
|
|
|
"links": links,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
def exception(sender: Any, exception: Exception, **extra: Any) -> None:
|
2022-10-15 20:56:30 +02:00
|
|
|
stack = "".join(
|
|
|
|
traceback.format_exception(type(exception), exception, exception.__traceback__)
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
try:
|
|
|
|
g.data.local.network.put_event(
|
2022-10-15 20:56:30 +02:00
|
|
|
"exception",
|
2019-12-08 22:43:49 +01:00
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"service": "frontend",
|
|
|
|
"request": request.url,
|
|
|
|
"traceback": stack,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
)
|
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
got_request_exception.connect(exception, app)
|
|
|
|
|
|
|
|
|
|
|
|
@app.errorhandler(403)
|
|
|
|
def forbidden(error: Any) -> Response:
|
2022-10-15 20:56:30 +02:00
|
|
|
return Response(render_template("403.html", **{"title": "403 Forbidden"}), 403)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
@app.errorhandler(404)
|
|
|
|
def page_not_found(error: Any) -> Response:
|
2022-10-15 20:56:30 +02:00
|
|
|
return Response(render_template("404.html", **{"title": "404 Not Found"}), 404)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
@app.errorhandler(500)
|
|
|
|
def server_error(error: Any) -> Response:
|
2022-10-15 20:56:30 +02:00
|
|
|
return Response(
|
|
|
|
render_template("500.html", **{"title": "500 Internal Server Error"}), 500
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
def error(msg: str) -> None:
|
2022-10-15 20:56:30 +02:00
|
|
|
flash(msg, "error")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
def warning(msg: str) -> None:
|
2022-10-15 20:56:30 +02:00
|
|
|
flash(msg, "warning")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
def success(msg: str) -> None:
|
2022-10-15 20:56:30 +02:00
|
|
|
flash(msg, "success")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
def info(msg: str) -> None:
|
2022-10-15 20:56:30 +02:00
|
|
|
flash(msg, "info")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
def valid_email(email: str) -> bool:
|
2022-10-15 20:56:30 +02:00
|
|
|
return (
|
|
|
|
re.match(r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)", email)
|
|
|
|
is not None
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
def valid_username(username: str) -> bool:
|
|
|
|
return re.match(r"^[a-zA-Z0-9_]+$", username) is not None
|
|
|
|
|
|
|
|
|
|
|
|
def valid_pin(pin: str, type: str) -> bool:
|
2022-10-15 20:56:30 +02:00
|
|
|
if type == "card":
|
2021-08-12 20:59:43 +02:00
|
|
|
return re.match(r"^\d\d\d\d$", pin) is not None
|
2022-10-15 20:56:30 +02:00
|
|
|
elif type == "arcade":
|
2021-08-12 20:59:43 +02:00
|
|
|
return re.match(r"^\d\d\d\d\d\d\d\d$", pin) is not None
|
2019-12-08 22:43:49 +01:00
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
2021-08-31 23:40:30 +02:00
|
|
|
# Define useful functions for jnija2
|
|
|
|
def jinja2_any(lval: Optional[List[Any]], pull: str, equals: str) -> bool:
|
|
|
|
if lval is None:
|
|
|
|
return False
|
|
|
|
for entry in lval:
|
|
|
|
if entry[pull] == equals:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
def jinja2_theme(filename: str) -> str:
|
2022-10-15 20:56:30 +02:00
|
|
|
return url_for("static", filename=f"themes/{config.theme}/{filename}")
|
2021-08-31 23:40:30 +02:00
|
|
|
|
|
|
|
|
2019-12-08 22:43:49 +01:00
|
|
|
@app.context_processor
|
|
|
|
def navigation() -> Dict[str, Any]:
|
|
|
|
# Look up JSX components we should provide for every page load
|
2022-11-01 05:22:58 +01:00
|
|
|
# Intentionally always use / to join for the top level since this
|
|
|
|
# is returning a URI.
|
2019-12-08 22:43:49 +01:00
|
|
|
components = [
|
2022-11-01 05:22:58 +01:00
|
|
|
f"components/{f}"
|
2022-10-15 20:56:30 +02:00
|
|
|
for f in os.listdir(os.path.join(static_location, "components"))
|
|
|
|
if re.search(r"\.react\.js$", f)
|
2019-12-08 22:43:49 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
# Look up the logged in user ID.
|
2021-08-20 06:43:59 +02:00
|
|
|
try:
|
|
|
|
if g.userID is not None:
|
|
|
|
user = g.data.local.user.get_user(g.userID)
|
|
|
|
profiles = g.data.local.user.get_games_played(g.userID)
|
|
|
|
else:
|
|
|
|
return {
|
2022-10-15 20:56:30 +02:00
|
|
|
"components": components,
|
|
|
|
"any": jinja2_any,
|
2022-12-03 23:02:37 +01:00
|
|
|
"assets": f"themes/{config.theme}/",
|
2022-10-15 20:56:30 +02:00
|
|
|
"theme_url": jinja2_theme,
|
|
|
|
"cache_bust": f"v={FRONTEND_CACHE_BUST}",
|
2021-08-20 06:43:59 +02:00
|
|
|
}
|
|
|
|
except AttributeError:
|
|
|
|
# If we are trying to render a 500 error and we couldn't even run the
|
|
|
|
# before request, we won't have a userID object on g. So, just give
|
|
|
|
# up and refuse to render any navigation.
|
2019-12-08 22:43:49 +01:00
|
|
|
return {
|
2022-10-15 20:56:30 +02:00
|
|
|
"components": components,
|
|
|
|
"any": jinja2_any,
|
2022-12-03 23:02:37 +01:00
|
|
|
"assets": f"themes/{config.theme}/",
|
2022-10-15 20:56:30 +02:00
|
|
|
"theme_url": jinja2_theme,
|
|
|
|
"cache_bust": f"v={FRONTEND_CACHE_BUST}",
|
2019-12-08 22:43:49 +01:00
|
|
|
}
|
2021-08-20 06:43:59 +02:00
|
|
|
|
2020-11-11 06:14:36 +01:00
|
|
|
pages: List[Dict[str, Any]] = []
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Landing page
|
|
|
|
pages.append(
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Home",
|
|
|
|
"uri": url_for("home_pages.viewhome"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2021-08-20 06:43:59 +02:00
|
|
|
if GameConstants.BISHI_BASHI in g.config.support:
|
2019-12-08 22:43:49 +01:00
|
|
|
# BishiBashi pages
|
|
|
|
bishi_entries = []
|
|
|
|
if len([p for p in profiles if p[0] == GameConstants.BISHI_BASHI]) > 0:
|
2022-10-15 20:56:30 +02:00
|
|
|
bishi_entries.extend(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"label": "Game Options",
|
|
|
|
"uri": url_for("bishi_pages.viewsettings"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Profile",
|
|
|
|
"uri": url_for("bishi_pages.viewplayer", userid=g.userID),
|
|
|
|
},
|
|
|
|
]
|
|
|
|
)
|
|
|
|
bishi_entries.extend(
|
|
|
|
[
|
2019-12-08 22:43:49 +01:00
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "All Players",
|
|
|
|
"uri": url_for("bishi_pages.viewplayers"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
2022-10-15 20:56:30 +02:00
|
|
|
]
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
pages.append(
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "BishiBashi",
|
|
|
|
"entries": bishi_entries,
|
|
|
|
"base_uri": app.blueprints["bishi_pages"].url_prefix,
|
|
|
|
"gamecode": GameConstants.BISHI_BASHI.value,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2021-08-20 06:43:59 +02:00
|
|
|
if GameConstants.DDR in g.config.support:
|
2019-12-08 22:43:49 +01:00
|
|
|
# DDR pages
|
|
|
|
ddr_entries = []
|
|
|
|
if len([p for p in profiles if p[0] == GameConstants.DDR]) > 0:
|
2022-10-15 20:56:30 +02:00
|
|
|
ddr_entries.extend(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"label": "Game Options",
|
|
|
|
"uri": url_for("ddr_pages.viewsettings"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Rivals",
|
|
|
|
"uri": url_for("ddr_pages.viewrivals"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Profile",
|
|
|
|
"uri": url_for("ddr_pages.viewplayer", userid=g.userID),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Scores",
|
|
|
|
"uri": url_for("ddr_pages.viewscores", userid=g.userID),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Records",
|
|
|
|
"uri": url_for("ddr_pages.viewrecords", userid=g.userID),
|
|
|
|
},
|
|
|
|
]
|
|
|
|
)
|
|
|
|
ddr_entries.extend(
|
|
|
|
[
|
2019-12-08 22:43:49 +01:00
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Global Scores",
|
|
|
|
"uri": url_for("ddr_pages.viewnetworkscores"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Global Records",
|
|
|
|
"uri": url_for("ddr_pages.viewnetworkrecords"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "All Players",
|
|
|
|
"uri": url_for("ddr_pages.viewplayers"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
2022-10-15 20:56:30 +02:00
|
|
|
]
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
pages.append(
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "DDR",
|
|
|
|
"entries": ddr_entries,
|
|
|
|
"base_uri": app.blueprints["ddr_pages"].url_prefix,
|
|
|
|
"gamecode": GameConstants.DDR.value,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2021-08-20 06:43:59 +02:00
|
|
|
if GameConstants.IIDX in g.config.support:
|
2019-12-08 22:43:49 +01:00
|
|
|
# IIDX pages
|
|
|
|
iidx_entries = []
|
|
|
|
if len([p for p in profiles if p[0] == GameConstants.IIDX]) > 0:
|
2022-10-15 20:56:30 +02:00
|
|
|
iidx_entries.extend(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"label": "Game Options",
|
|
|
|
"uri": url_for("iidx_pages.viewsettings"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Rivals",
|
|
|
|
"uri": url_for("iidx_pages.viewrivals"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Profile",
|
|
|
|
"uri": url_for("iidx_pages.viewplayer", userid=g.userID),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Scores",
|
|
|
|
"uri": url_for("iidx_pages.viewscores", userid=g.userID),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Records",
|
|
|
|
"uri": url_for("iidx_pages.viewrecords", userid=g.userID),
|
|
|
|
},
|
|
|
|
]
|
|
|
|
)
|
|
|
|
iidx_entries.extend(
|
|
|
|
[
|
2019-12-08 22:43:49 +01:00
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Global Scores",
|
|
|
|
"uri": url_for("iidx_pages.viewnetworkscores"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Global Records",
|
|
|
|
"uri": url_for("iidx_pages.viewnetworkrecords"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "All Players",
|
|
|
|
"uri": url_for("iidx_pages.viewplayers"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
2022-10-15 20:56:30 +02:00
|
|
|
]
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
pages.append(
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "IIDX",
|
|
|
|
"entries": iidx_entries,
|
|
|
|
"base_uri": app.blueprints["iidx_pages"].url_prefix,
|
|
|
|
"gamecode": GameConstants.IIDX.value,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2021-08-20 06:43:59 +02:00
|
|
|
if GameConstants.JUBEAT in g.config.support:
|
2019-12-08 22:43:49 +01:00
|
|
|
# Jubeat pages
|
|
|
|
jubeat_entries = []
|
|
|
|
if len([p for p in profiles if p[0] == GameConstants.JUBEAT]) > 0:
|
2022-10-15 20:56:30 +02:00
|
|
|
jubeat_entries.extend(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"label": "Game Options",
|
|
|
|
"uri": url_for("jubeat_pages.viewsettings"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Rivals",
|
|
|
|
"uri": url_for("jubeat_pages.viewrivals"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Profile",
|
|
|
|
"uri": url_for("jubeat_pages.viewplayer", userid=g.userID),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Scores",
|
|
|
|
"uri": url_for("jubeat_pages.viewscores", userid=g.userID),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Records",
|
|
|
|
"uri": url_for("jubeat_pages.viewrecords", userid=g.userID),
|
|
|
|
},
|
|
|
|
]
|
|
|
|
)
|
|
|
|
jubeat_entries.extend(
|
|
|
|
[
|
2019-12-08 22:43:49 +01:00
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Global Scores",
|
|
|
|
"uri": url_for("jubeat_pages.viewnetworkscores"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Global Records",
|
|
|
|
"uri": url_for("jubeat_pages.viewnetworkrecords"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "All Players",
|
|
|
|
"uri": url_for("jubeat_pages.viewplayers"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
2022-10-15 20:56:30 +02:00
|
|
|
]
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
pages.append(
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Jubeat",
|
|
|
|
"entries": jubeat_entries,
|
|
|
|
"base_uri": app.blueprints["jubeat_pages"].url_prefix,
|
|
|
|
"gamecode": GameConstants.JUBEAT.value,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2021-09-10 17:20:13 +02:00
|
|
|
if GameConstants.MGA in g.config.support:
|
|
|
|
# Metal Gear Arcade pages
|
|
|
|
mga_entries = []
|
|
|
|
if len([p for p in profiles if p[0] == GameConstants.MGA]) > 0:
|
2022-10-15 20:56:30 +02:00
|
|
|
mga_entries.extend(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"label": "Game Options",
|
|
|
|
"uri": url_for("mga_pages.viewsettings"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Profile",
|
|
|
|
"uri": url_for("mga_pages.viewplayer", userid=g.userID),
|
|
|
|
},
|
|
|
|
]
|
|
|
|
)
|
|
|
|
mga_entries.extend(
|
|
|
|
[
|
2021-09-10 17:20:13 +02:00
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "All Players",
|
|
|
|
"uri": url_for("mga_pages.viewplayers"),
|
2021-09-10 17:20:13 +02:00
|
|
|
},
|
2022-10-15 20:56:30 +02:00
|
|
|
]
|
|
|
|
)
|
2021-09-10 17:20:13 +02:00
|
|
|
pages.append(
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Metal Gear Arcade",
|
|
|
|
"entries": mga_entries,
|
|
|
|
"base_uri": app.blueprints["mga_pages"].url_prefix,
|
|
|
|
"gamecode": GameConstants.MGA.value,
|
2021-09-10 17:20:13 +02:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2021-08-20 06:43:59 +02:00
|
|
|
if GameConstants.MUSECA in g.config.support:
|
2019-12-08 22:43:49 +01:00
|
|
|
# Museca pages
|
|
|
|
museca_entries = []
|
|
|
|
if len([p for p in profiles if p[0] == GameConstants.MUSECA]) > 0:
|
2022-10-15 20:56:30 +02:00
|
|
|
museca_entries.extend(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"label": "Game Options",
|
|
|
|
"uri": url_for("museca_pages.viewsettings"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Profile",
|
|
|
|
"uri": url_for("museca_pages.viewplayer", userid=g.userID),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Scores",
|
|
|
|
"uri": url_for("museca_pages.viewscores", userid=g.userID),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Records",
|
|
|
|
"uri": url_for("museca_pages.viewrecords", userid=g.userID),
|
|
|
|
},
|
|
|
|
]
|
|
|
|
)
|
|
|
|
museca_entries.extend(
|
|
|
|
[
|
2019-12-08 22:43:49 +01:00
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Global Scores",
|
|
|
|
"uri": url_for("museca_pages.viewnetworkscores"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Global Records",
|
|
|
|
"uri": url_for("museca_pages.viewnetworkrecords"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "All Players",
|
|
|
|
"uri": url_for("museca_pages.viewplayers"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
2022-10-15 20:56:30 +02:00
|
|
|
]
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
pages.append(
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "MÚSECA",
|
|
|
|
"entries": museca_entries,
|
|
|
|
"base_uri": app.blueprints["museca_pages"].url_prefix,
|
|
|
|
"gamecode": GameConstants.MUSECA.value,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2021-08-20 06:43:59 +02:00
|
|
|
if GameConstants.POPN_MUSIC in g.config.support:
|
2019-12-08 22:43:49 +01:00
|
|
|
# Pop'n Music pages
|
|
|
|
popn_entries = []
|
|
|
|
if len([p for p in profiles if p[0] == GameConstants.POPN_MUSIC]) > 0:
|
2022-10-15 20:56:30 +02:00
|
|
|
popn_entries.extend(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"label": "Game Options",
|
|
|
|
"uri": url_for("popn_pages.viewsettings"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Rivals",
|
|
|
|
"uri": url_for("popn_pages.viewrivals"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Profile",
|
|
|
|
"uri": url_for("popn_pages.viewplayer", userid=g.userID),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Scores",
|
|
|
|
"uri": url_for("popn_pages.viewscores", userid=g.userID),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Records",
|
|
|
|
"uri": url_for("popn_pages.viewrecords", userid=g.userID),
|
|
|
|
},
|
|
|
|
]
|
|
|
|
)
|
|
|
|
popn_entries.extend(
|
|
|
|
[
|
2019-12-08 22:43:49 +01:00
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Global Scores",
|
|
|
|
"uri": url_for("popn_pages.viewnetworkscores"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Global Records",
|
|
|
|
"uri": url_for("popn_pages.viewnetworkrecords"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "All Players",
|
|
|
|
"uri": url_for("popn_pages.viewplayers"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
2022-10-15 20:56:30 +02:00
|
|
|
]
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
pages.append(
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Pop'n Music",
|
|
|
|
"entries": popn_entries,
|
|
|
|
"base_uri": app.blueprints["popn_pages"].url_prefix,
|
|
|
|
"gamecode": GameConstants.POPN_MUSIC.value,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2021-08-20 06:43:59 +02:00
|
|
|
if GameConstants.REFLEC_BEAT in g.config.support:
|
2019-12-08 22:43:49 +01:00
|
|
|
# ReflecBeat pages
|
|
|
|
reflec_entries = []
|
|
|
|
if len([p for p in profiles if p[0] == GameConstants.REFLEC_BEAT]) > 0:
|
2022-10-15 20:56:30 +02:00
|
|
|
reflec_entries.extend(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"label": "Game Options",
|
|
|
|
"uri": url_for("reflec_pages.viewsettings"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Rivals",
|
|
|
|
"uri": url_for("reflec_pages.viewrivals"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Profile",
|
|
|
|
"uri": url_for("reflec_pages.viewplayer", userid=g.userID),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Scores",
|
|
|
|
"uri": url_for("reflec_pages.viewscores", userid=g.userID),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Records",
|
|
|
|
"uri": url_for("reflec_pages.viewrecords", userid=g.userID),
|
|
|
|
},
|
|
|
|
]
|
|
|
|
)
|
|
|
|
reflec_entries.extend(
|
|
|
|
[
|
2019-12-08 22:43:49 +01:00
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Global Scores",
|
|
|
|
"uri": url_for("reflec_pages.viewnetworkscores"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Global Records",
|
|
|
|
"uri": url_for("reflec_pages.viewnetworkrecords"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "All Players",
|
|
|
|
"uri": url_for("reflec_pages.viewplayers"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
2022-10-15 20:56:30 +02:00
|
|
|
]
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
pages.append(
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Reflec Beat",
|
|
|
|
"entries": reflec_entries,
|
|
|
|
"base_uri": app.blueprints["reflec_pages"].url_prefix,
|
|
|
|
"gamecode": GameConstants.REFLEC_BEAT.value,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2021-08-20 06:43:59 +02:00
|
|
|
if GameConstants.SDVX in g.config.support:
|
2019-12-08 22:43:49 +01:00
|
|
|
# SDVX pages
|
|
|
|
sdvx_entries = []
|
|
|
|
if len([p for p in profiles if p[0] == GameConstants.SDVX]) > 0:
|
2022-10-15 20:56:30 +02:00
|
|
|
sdvx_entries.extend(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"label": "Game Options",
|
|
|
|
"uri": url_for("sdvx_pages.viewsettings"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Rivals",
|
|
|
|
"uri": url_for("sdvx_pages.viewrivals"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Profile",
|
|
|
|
"uri": url_for("sdvx_pages.viewplayer", userid=g.userID),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Scores",
|
|
|
|
"uri": url_for("sdvx_pages.viewscores", userid=g.userID),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"label": "Personal Records",
|
|
|
|
"uri": url_for("sdvx_pages.viewrecords", userid=g.userID),
|
|
|
|
},
|
|
|
|
]
|
|
|
|
)
|
|
|
|
sdvx_entries.extend(
|
|
|
|
[
|
2019-12-08 22:43:49 +01:00
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Global Scores",
|
|
|
|
"uri": url_for("sdvx_pages.viewnetworkscores"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Global Records",
|
|
|
|
"uri": url_for("sdvx_pages.viewnetworkrecords"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "All Players",
|
|
|
|
"uri": url_for("sdvx_pages.viewplayers"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
2022-10-15 20:56:30 +02:00
|
|
|
]
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
pages.append(
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "SDVX",
|
|
|
|
"entries": sdvx_entries,
|
|
|
|
"base_uri": app.blueprints["sdvx_pages"].url_prefix,
|
|
|
|
"gamecode": GameConstants.SDVX.value,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
# Admin pages
|
|
|
|
if user.admin:
|
|
|
|
pages.append(
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Admin",
|
|
|
|
"uri": url_for("admin_pages.viewsettings"),
|
|
|
|
"entries": [
|
2019-12-08 22:43:49 +01:00
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Events",
|
|
|
|
"uri": url_for("admin_pages.viewevents"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Data API",
|
|
|
|
"uri": url_for("admin_pages.viewapi"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Arcades",
|
|
|
|
"uri": url_for("admin_pages.viewarcades"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "PCBIDs",
|
|
|
|
"uri": url_for("admin_pages.viewmachines"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
2021-09-10 04:23:20 +02:00
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Game Settings",
|
|
|
|
"uri": url_for("admin_pages.viewgamesettings"),
|
2021-09-10 04:23:20 +02:00
|
|
|
},
|
2019-12-08 22:43:49 +01:00
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Cards",
|
|
|
|
"uri": url_for("admin_pages.viewcards"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Users",
|
|
|
|
"uri": url_for("admin_pages.viewusers"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "News",
|
|
|
|
"uri": url_for("admin_pages.viewnews"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
],
|
2022-10-15 20:56:30 +02:00
|
|
|
"base_uri": app.blueprints["admin_pages"].url_prefix,
|
|
|
|
"right_justify": True,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
# Arcade owner pages
|
|
|
|
arcadeids = g.data.local.machine.from_userid(g.userID)
|
2021-08-28 21:35:44 +02:00
|
|
|
if len(arcadeids) == 1:
|
|
|
|
arcade = g.data.local.machine.get_arcade(arcadeids[0])
|
2022-10-15 20:56:30 +02:00
|
|
|
pages.append(
|
|
|
|
{
|
|
|
|
"label": arcade.name,
|
|
|
|
"uri": url_for("arcade_pages.viewarcade", arcadeid=arcade.id),
|
|
|
|
"right_justify": True,
|
|
|
|
}
|
|
|
|
)
|
2021-08-28 21:35:44 +02:00
|
|
|
elif len(arcadeids) > 1:
|
2019-12-08 22:43:49 +01:00
|
|
|
entries = []
|
|
|
|
for arcadeid in arcadeids:
|
|
|
|
arcade = g.data.local.machine.get_arcade(arcadeid)
|
2022-10-15 20:56:30 +02:00
|
|
|
entries.append(
|
|
|
|
{
|
|
|
|
"label": arcade.name,
|
|
|
|
"uri": url_for("arcade_pages.viewarcade", arcadeid=arcade.id),
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
pages.append(
|
|
|
|
{
|
|
|
|
"label": "Arcades",
|
|
|
|
"entries": entries,
|
|
|
|
"base_uri": app.blueprints["arcade_pages"].url_prefix,
|
|
|
|
"right_justify": True,
|
|
|
|
}
|
|
|
|
)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# User account pages
|
|
|
|
pages.append(
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Account",
|
|
|
|
"uri": url_for("account_pages.viewaccount"),
|
|
|
|
"entries": [
|
2019-12-08 22:43:49 +01:00
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Cards",
|
|
|
|
"uri": url_for("account_pages.viewcards"),
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
],
|
2022-10-15 20:56:30 +02:00
|
|
|
"base_uri": app.blueprints["account_pages"].url_prefix,
|
|
|
|
"right_justify": True,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
# GTFO button
|
|
|
|
pages.append(
|
|
|
|
{
|
2022-10-15 20:56:30 +02:00
|
|
|
"label": "Log Out",
|
|
|
|
"uri": url_for("account_pages.logout"),
|
|
|
|
"right_justify": True,
|
2019-12-08 22:43:49 +01:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
return {
|
2022-10-15 20:56:30 +02:00
|
|
|
"current_path": request.path,
|
|
|
|
"show_navigation": True,
|
|
|
|
"navigation": pages,
|
|
|
|
"components": components,
|
|
|
|
"any": jinja2_any,
|
2022-12-03 23:02:37 +01:00
|
|
|
"assets": f"themes/{config.theme}/",
|
2022-10-15 20:56:30 +02:00
|
|
|
"theme_url": jinja2_theme,
|
|
|
|
"cache_bust": f"v={FRONTEND_CACHE_BUST}",
|
2019-12-08 22:43:49 +01:00
|
|
|
}
|