diff --git a/.env.example b/.env.example index bad4385..48bf608 100644 --- a/.env.example +++ b/.env.example @@ -7,4 +7,5 @@ GITHUB_ID='' GITHUB_SECRET='' SERVER_NAME='' DATABASE_PATH='' -PORT=5000 \ No newline at end of file +PORT=5000 +CORS_REGEX=''' \ No newline at end of file diff --git a/src/about.py b/src/about.py index 13e7751..c916ed6 100644 --- a/src/about.py +++ b/src/about.py @@ -1,6 +1,6 @@ import os -version = "0.7.1" +version = "0.7.2" if os.path.exists(".git/HEAD"): with open(".git/HEAD") as fp: diff --git a/src/app/app.py b/src/app/app.py index ae6aadc..5f0638d 100644 --- a/src/app/app.py +++ b/src/app/app.py @@ -1,6 +1,7 @@ from __future__ import annotations import re +from os import environ from quart import Quart from quart_auth import QuartAuth @@ -22,7 +23,10 @@ def create_app(import_name: str) -> Quart: if app.config["DEBUG"]: app.logger.info("Loading Development configuration...") else: - app = cors(app, allow_origin=re.compile("https://*.yip.cat*")) + app = cors( + app, + allow_origin=re.compile(environ.get("CORS_REGEX", "https://*.yip.cat*")), + ) auth_manager = QuartAuth(app) auth_manager.user_class = User diff --git a/src/auth/permissions.py b/src/auth/permissions.py index d668090..9320c66 100644 --- a/src/auth/permissions.py +++ b/src/auth/permissions.py @@ -7,6 +7,14 @@ class Permissions: @staticmethod def sort() -> list: + """Sorts a list of all available permissions by their value, making for + easier indexing without knowing the name. + + Returns: + list: Sorted list of all Permission integer values + """ + # tl;dr: shitty list comprehension that returns only uppercase, non_private variables + # DO NOT DO THIS! THIS IS BAD!!!!! probably. idk im just a fox dont listen to me _current = [ value for name, value in vars(Permissions).items() diff --git a/src/blueprints/foxterm_backend/__init__.py b/src/blueprints/foxterm_backend/__init__.py new file mode 100644 index 0000000..7ef19fe --- /dev/null +++ b/src/blueprints/foxterm_backend/__init__.py @@ -0,0 +1,2 @@ +__all__ = ["blueprint"] +from src.blueprints.foxterm_backend.blueprint import blueprint diff --git a/src/blueprints/term/blueprint.py b/src/blueprints/foxterm_backend/blueprint.py similarity index 97% rename from src/blueprints/term/blueprint.py rename to src/blueprints/foxterm_backend/blueprint.py index eb74282..49ddbc9 100644 --- a/src/blueprints/term/blueprint.py +++ b/src/blueprints/foxterm_backend/blueprint.py @@ -14,7 +14,7 @@ links = {"readme.md": "README.md"} blueprint = Blueprint( - "term", + "foxterm_backend", __name__, template_folder="templates", static_folder="static", @@ -108,7 +108,11 @@ async def cd(): @blueprint.route("/login-text", methods=["GET"]) async def login_text(): commit_hash = "" - path = anyio.Path(".git/refs/heads/dev") + if is_dev: + path = anyio.Path(".git/refs/heads/dev") + else: + path = anyio.Path(".git/refs/heads/main") + if await path.exists(): async with await anyio.open_file(path) as fp: commit_hash = (await fp.readline()).strip("\n") diff --git a/src/blueprints/term/__init__.py b/src/blueprints/term/__init__.py deleted file mode 100644 index 72146de..0000000 --- a/src/blueprints/term/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -__all__ = ["blueprint"] -from src.blueprints.term.blueprint import blueprint