diff --git a/nephthys/public/binoculars.png b/nephthys/public/binoculars.png new file mode 100644 index 0000000..a7466cf Binary files /dev/null and b/nephthys/public/binoculars.png differ diff --git a/nephthys/public/loading.gif b/nephthys/public/loading.gif new file mode 100644 index 0000000..dd96764 Binary files /dev/null and b/nephthys/public/loading.gif differ diff --git a/nephthys/utils/env.py b/nephthys/utils/env.py index 72c4e7d..cb8e543 100644 --- a/nephthys/utils/env.py +++ b/nephthys/utils/env.py @@ -41,6 +41,7 @@ class Environment: or default_log_level ) self.log_level_otel = os.environ.get("LOG_LEVEL_OTEL", logging.INFO) + self.hostname: str = os.environ.get("HOSTNAME", "https://nephthys.hackclub.com") self.slack_help_channel = os.environ.get("SLACK_HELP_CHANNEL", "unset") self.slack_ticket_channel = os.environ.get("SLACK_TICKET_CHANNEL", "unset") diff --git a/nephthys/utils/starlette.py b/nephthys/utils/starlette.py index 81061ce..ded261a 100644 --- a/nephthys/utils/starlette.py +++ b/nephthys/utils/starlette.py @@ -1,3 +1,5 @@ +from pathlib import Path + from prometheus_client import CONTENT_TYPE_LATEST from prometheus_client import generate_latest from slack_bolt.adapter.starlette.async_handler import AsyncSlackRequestHandler @@ -6,7 +8,9 @@ from starlette.requests import Request from starlette.responses import JSONResponse from starlette.responses import RedirectResponse from starlette.responses import Response +from starlette.routing import Mount from starlette.routing import Route +from starlette.staticfiles import StaticFiles from starlette_exporter import PrometheusMiddleware from nephthys.__main__ import main @@ -53,6 +57,8 @@ async def root(req: Request): return RedirectResponse(url="https://github.com/hackclub/nephthys") +STATIC_DIR = Path(Path.cwd() / "nephthys" / "public") + app = Starlette( debug=True if env.environment != "production" else False, routes=[ @@ -63,6 +69,7 @@ app = Starlette( Route(path="/api/ticket", endpoint=ticket_info, methods=["GET"]), Route(path="/health", endpoint=health, methods=["GET"]), Route(path="/metrics", endpoint=metrics, methods=["GET"]), + Mount("/public", app=StaticFiles(directory=STATIC_DIR), name="static"), ], lifespan=main, ) diff --git a/nephthys/views/home/components/ticket_status_pie.py b/nephthys/views/home/components/ticket_status_pie.py index 3199f16..0a293b0 100644 --- a/nephthys/views/home/components/ticket_status_pie.py +++ b/nephthys/views/home/components/ticket_status_pie.py @@ -89,7 +89,7 @@ async def get_ticket_status_pie_chart( caption = "Ticket stats" if not url: - url = "https://hc-cdn.hel1.your-objectstorage.com/s/v3/888f292372d8450449b41dd18767812c72518449_binoculars.png" + url = f"{env.hostname}/public/binoculars.png" caption = "looks like heidi's scrounging around for tickets in the trash" return { diff --git a/nephthys/views/home/loading.py b/nephthys/views/home/loading.py index b9ca3d4..d1a2980 100644 --- a/nephthys/views/home/loading.py +++ b/nephthys/views/home/loading.py @@ -1,3 +1,4 @@ +from nephthys.utils.env import env from nephthys.views.home.components.header import get_header @@ -15,7 +16,7 @@ def get_loading_view(home_type: str): }, { "type": "image", - "image_url": "https://hc-cdn.hel1.your-objectstorage.com/s/v3/1c1fc5fb03b8bf46c6ab047c97f962ed930616f0_loading-hugs.gif", + "image_url": f"{env.hostname}/public/loading.gif", "alt_text": "Loading...", }, ],