S006a: website under /dezio/, minimal landing page

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
astar76 2026-12-01 22:02:35 -06:00
commit c7b02db71b
16 changed files with 153 additions and 51 deletions

View file

@ -21,7 +21,7 @@ Tracker: https://claude.ai/artifact/PRAT4HSkqn44d6QFDJeovp
## 03a Website path
- [ ] [S006a — Website under /dezio/, landing page at the root](03a%20Website%20path/S006a-dezio-path.md) 🧑
- [x] [S006a — Website under /dezio/, landing page at the root](03a%20Website%20path/S006a-dezio-path.md) 🧑
## 04 Security

19
deploy/landing/index.html Normal file
View file

@ -0,0 +1,19 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Astar Hub</title>
<style>
body { font-family: system-ui, sans-serif; background: #15171a; color: #e8e8e8; margin: 0; min-height: 100vh; display: grid; place-items: center; text-align: center; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
a { color: #8bd450; font-size: 1.1rem; margin: 0 .8rem; }
</style>
</head>
<body>
<main>
<h1>Astar Hub</h1>
<p><a href="/dezio/">Dezio</a> <a href="/git/">Source</a></p>
</main>
</body>
</html>

View file

@ -15,3 +15,4 @@
- D-011 — 2026-12-01 — Covers come from a chain (`src/commands/lastfm/covers.rs`): the release ID in the player's own tags (Cover Art Archive) → ListenBrainz's match → the release group → Deezer → iTunes; Deezer/iTunes results count only when artist and title match. Artist photos: Deezer → MusicBrainz/Wikimedia. Play counts match by MusicBrainz ID before names. — MusicBrainz art alone left many covers blank; owner asked for the most reliable sources with fallbacks. — fm commands.
- D-012 — 2026-12-01 — All fm logic must get its data from ListenBrainz and MusicBrainz (plus the D-011 cover/photo fallbacks); leftover Last.fm API logic and Last.fm-only fields are replaced or removed. Song links to the Last.fm website stay. — Owner request after the Last.fm API change. — S006, S010.
- D-013 — 2026-12-01 — All of Dezio's website (site, dashboard, API, OAuth, Game Boy Activity, hosted `/f/` files) moves to https://archlinux.tail7c4f5e.ts.net/dezio/. The root `/` serves a minimal static landing page (links to `/dezio/` and `/git/`), which the owner will improve in a later session; old root links to Dezio are not redirected. `/git` stays Forgejo. — Owner request. — S006a, S007, S011.
- D-013 addition — 2026-12-01 — Base path = path part of `DASHBOARD_URL` (`/dezio`, none → root). The router serves every route both under the base and un-prefixed, so it works whether `tailscale serve --set-path` strips the prefix or not. HTML pages carry `__BASE__` (server replaces it); dashboard JS reads `<html data-base>`; site pages use relative paths; the Activity derives its base from `location.pathname` (so it also works at `/` inside Discord). Cookie `Path` = base. — Avoids guessing tailscale's behaviour. — S006a, S011.

View file

@ -43,3 +43,8 @@ One entry per session, newest last, ≤ 15 lines: done, verified how, not done,
- Done: audit of every fm feature; code was already fully on ListenBrainz/MusicBrainz, no Last.fm API leftovers in src. Only fix: `docs/topgg.md` wording. Test list in `docs/tests/S006-fm.md`.
- Dropped from cards: listeners, global plays, bio, tags (none were shown). Profile realname/country are skipped when empty.
- Verified: grep and `cargo check` only. Not tested in Discord 🧑. No new unit test (no new logic; api.rs already has sample-JSON tests).
## 2026-12-01 — S006a website under /dezio/
- Done: `Cfg.base` from `DASHBOARD_URL` path (`base_path`, unit test); routes nested under base and also un-prefixed; cookie Path, redirects, login link carry base; pages use `__BASE__`/relative paths; `deploy/landing/index.html` (minimal). topgg + module comments updated.
- Not done: nothing deployed. Static copy of web/dashboard/index.html now has `__BASE__` placeholders (only the bot serves it).
- Verified: `cargo check`, `cargo test base_path`. No browser check. Server commands + 🧑 portal list in `docs/tests/S006a-dezio-path.md`.

View file

@ -0,0 +1,33 @@
# S006a — website under /dezio/ (tests)
## Local checks
Run: `DASHBOARD_URL=http://127.0.0.1:8099/dezio DISCORD_BOT_TOKEN=dev-placeholder target/debug/dezio --web-dev`, cookie `dezio_session=devtoken`.
1. `/dezio/` shows the site with fonts and images; `/dezio/terms`, `/dezio/privacy` load and their Home link goes to `/dezio/`.
2. `/dezio/assets/site.css`, `/dezio/images/dezio.png` return 200.
3. Site: the Dashboard button appears (fetch of `/dezio/api/me` works).
4. `/dezio/dashboard` loads styled; its scripts load from `/dezio/dashboard/static/`; settings load and save (`/dezio/api/user`).
5. Dashboard URL bar after navigating stays `/dezio/dashboard#...`; Sign out returns to `/dezio/dashboard`.
6. Signed out (no cookie): "Sign in with Discord" links to `/dezio/login`; `/dezio/login` redirects to Discord with `redirect_uri=http://127.0.0.1:8099/dezio/callback`.
7. Set-Cookie headers from login have `Path=/dezio`.
8. `/dezio/activity` redirects to `/dezio/activity/`; the page loads, `/dezio/activity/api/config` works, the 401 from web-session has `login` = `/dezio/login?next=/activity/`.
9. A hosted link from `hosted::store` is `http://127.0.0.1:8099/dezio/f/<token>/<name>` and downloads.
10. Without a path (`DASHBOARD_URL=http://127.0.0.1:8099`) everything still works at `/`.
11. `cargo test base_path` passes.
## Deploy commands for S011 (do not run before)
- Back up: `ssh [email protected] cp /root/Dezio/.env /root/Dezio/.env.bak-<date>`.
- Landing: `scp deploy/landing/index.html [email protected]:/srv/landing/index.html` (mkdir `/srv/landing` first).
- `tailscale serve --bg --set-path / /srv/landing`
- `tailscale serve --bg --set-path /dezio http://127.0.0.1:8080` (keep Funnel on; keep the `/git` mapping).
- In `/root/Dezio/.env`: `DASHBOARD_URL=https://archlinux.tail7c4f5e.ts.net/dezio`, then restart `dezio-bot`.
- Check `https://archlinux.tail7c4f5e.ts.net/`, `/dezio/`, `/git/`. The router accepts the prefix stripped or not.
## Owner checklist 🧑
- Developer Portal → OAuth2 → Redirects: add `https://archlinux.tail7c4f5e.ts.net/dezio/callback`.
- Activities → URL Mappings: `/` → `archlinux.tail7c4f5e.ts.net/dezio/activity`.
- top.gg website field: `https://archlinux.tail7c4f5e.ts.net/dezio/`.
## Doubts
- Whether tailscale strips `/dezio` (both handled, not verified).
- `web/dashboard/index.html` has `__BASE__` placeholders, so opening it as a plain file shows broken links.
- Root-absolute paths left in web/: none outside `__BASE__` placeholders (grep `(href|src|action)="/[a-z]` in web/site finds none).

View file

@ -8,7 +8,7 @@ Copy each block into the matching field on the bot's Top.gg edit page.
|---|---|
| Invite URL | https://discord.com/oauth2/authorize?client_id=1387839600017412106&scope=bot%20applications.commands&permissions=8 |
| Support server | https://discord.gg/UnSga5DmR7 |
| Website | https://archlinux.tail7c4f5e.ts.net |
| Website | https://archlinux.tail7c4f5e.ts.net/dezio/ |
| GitHub / source | https://archlinux.tail7c4f5e.ts.net/git/astar76/Dezio |
| Prefix | `D!` (every command is also a slash command) |
| Library | Rust (twilight + songbird) |
@ -55,7 +55,7 @@ Chess, Connect 4, tic-tac-toe, Wordle, hangman, minesweeper, 2048, Akinator, Coo
AI chat with a personality you can change per server, anime GIF actions, confessions, a phone-call system between servers, quotes you can style, emoji tools, weather, translation, wikipedia / web / image search, a calculator and a **Game Boy you can play inside Discord** (Activity).
## Links
- **Website & dashboard:** https://archlinux.tail7c4f5e.ts.net
- **Website & dashboard:** https://archlinux.tail7c4f5e.ts.net/dezio/
- **Support server:** https://discord.gg/UnSga5DmR7
- **Source code:** https://archlinux.tail7c4f5e.ts.net/git/astar76/Dezio
- Privacy policy and terms are on the website.

View file

@ -8,7 +8,7 @@
//!
//! Owner setup, once, in the Developer Portal (app → Activities):
//! 1. Settings → enable Activities.
//! 2. URL Mappings → prefix `/` → target `<DASHBOARD_URL host>/activity`.
//! 2. URL Mappings → prefix `/` → target `<DASHBOARD_URL host + path>/activity` (…ts.net/dezio/activity).
use crate::cmd::{Command, Ctx, Origin};
use crate::state::State;
use crate::ui::{button, Card};

View file

@ -1,4 +1,4 @@
//! The Game Boy Discord Activity's web side, served by the dashboard's web server under /activity.
//! The Game Boy Discord Activity's web side, served by the dashboard's web server under /activity (below the DASHBOARD_URL path, /dezio).
//!
//! The emulator itself (binjgb, WebAssembly) runs in each player's Discord client, so the bot only hands out the page,
//! the ROMs (once — the client keeps them in IndexedDB) and the saves.
@ -16,7 +16,7 @@
//! GET /activity/api/art/<id> the game's cover (public): an image next to the ROM wins, else SteamGridDB
//! (STEAMGRIDDB_API_KEY), cached in data/gameboy/art
//!
//! Developer Portal setup (once): Activities → Settings → enable; Activities → URL Mappings → `/` → `<DASHBOARD_URL host>/activity`
//! Developer Portal setup (once): Activities → Settings → enable; Activities → URL Mappings → `/` → `<DASHBOARD_URL host + path>/activity` (e.g. archlinux.tail7c4f5e.ts.net/dezio/activity)
//! (no https://); OAuth2 → Redirects needs at least one entry (the dashboard's /callback is there already).
//! DEZIO_ACTIVITY_DEV=1 adds POST /activity/api/dev-session, a test sign-in for requests from 127.0.0.1.
//! Everything else under /api needs the session from /api/token (`Authorization: Bearer …`).
@ -340,8 +340,8 @@ async fn page() -> Response {
([(header::CONTENT_TYPE, "text/html; charset=utf-8"), (header::CACHE_CONTROL, "no-cache")], page_html()).into_response()
}
async fn slash_redirect(uri: axum::http::Uri) -> Redirect {
Redirect::to(&format!("/activity/{}", uri.query().map(|q| format!("?{q}")).unwrap_or_default()))
async fn slash_redirect(AxState(w): AxState<Shared>, uri: axum::http::Uri) -> Redirect {
Redirect::to(&format!("{}/activity/{}", w.cfg.base, uri.query().map(|q| format!("?{q}")).unwrap_or_default()))
}
fn dev_mode(addr: &SocketAddr) -> bool {
@ -366,7 +366,7 @@ async fn web_session(AxState(w): AxState<Shared>, headers: HeaderMap) -> Respons
if origin != w.cfg.origin && origin != format!("{}://{host}", if w.cfg.secure { "https" } else { "http" }) {
return ApiError::new(403, "Cross-site request refused").into_response();
}
let Some(s) = w.session(&headers) else { return (StatusCode::UNAUTHORIZED, Json(json!({"error": "Sign in with Discord first", "login": "/login?next=/activity/"}))).into_response() };
let Some(s) = w.session(&headers) else { return (StatusCode::UNAUTHORIZED, Json(json!({"error": "Sign in with Discord first", "login": format!("{}/login?next=/activity/", w.cfg.base)}))).into_response() };
Json(json!({"session": w.activity.new_session(s.user_id, &s.name), "user": {"id": s.user_id.to_string(), "name": s.name}})).into_response()
}

View file

@ -1,5 +1,7 @@
//! The web dashboard: Dezio's website plus per-user and per-server settings, served by the bot itself.
//!
//! Everything below lives under the path of DASHBOARD_URL (https://archlinux.tail7c4f5e.ts.net/dezio → /dezio; D-013).
//! Un-prefixed paths work too. HTML pages get that path in place of `__BASE__`.
//! / the website (web/site/: index, terms, privacy, assets/, images/)
//! /dashboard the settings app (web/dashboard/), which talks to /api/…
//! /login → Discord → /callback sign in with Discord (OAuth2, "identify" only)
@ -8,7 +10,7 @@
//! Settings in .env:
//! DASHBOARD_CLIENT_SECRET the app's OAuth2 client secret (Developer Portal → OAuth2) — sign-in is off without it
//! DASHBOARD_URL the address people open, default http://192.168.1.71:8080;
//! add DASHBOARD_URL + "/callback" under OAuth2 → Redirects in the Developer Portal
//! add DASHBOARD_URL + "/callback" (…/dezio/callback) under OAuth2 → Redirects in the Developer Portal
//! DASHBOARD_HOST / _PORT where to listen (default 0.0.0.0 and the port from DASHBOARD_URL)
//!
//! Security: sessions are random server-side tokens in an HttpOnly, SameSite=Lax cookie; every change needs the
@ -45,6 +47,8 @@ const ACTIVITY_CSP: &str = "default-src 'self'; script-src 'self' 'wasm-unsafe-e
pub struct Cfg {
pub url: String,
/// Path part of `url` without a trailing slash (`/dezio`), empty when the site lives at the root.
pub base: String,
pub origin: String,
pub secure: bool,
pub host: String,
@ -52,6 +56,12 @@ pub struct Cfg {
pub client_secret: String,
}
/// The path part of the public address, without a trailing slash: `https://x.ts.net/dezio/` → `/dezio`, no path → ``.
pub fn base_path(url: &str) -> String {
let path = reqwest::Url::parse(url).map(|u| u.path().trim_end_matches('/').to_string()).unwrap_or_default();
if path.is_empty() { String::new() } else { path }
}
impl Cfg {
pub fn from_env() -> Self {
let url = std::env::var("DASHBOARD_URL").ok().filter(|u| !u.is_empty()).unwrap_or_else(|| "http://192.168.1.71:8080".into()).trim_end_matches('/').to_string();
@ -60,6 +70,7 @@ impl Cfg {
let origin = parsed.as_ref().map(|u| format!("{}://{}", u.scheme(), u.host_str().unwrap_or("localhost").to_string() + &u.port().map(|p| format!(":{p}")).unwrap_or_default())).unwrap_or_else(|| url.clone());
let default_port = parsed.as_ref().and_then(|u| u.port_or_known_default()).unwrap_or(8080);
Self {
base: base_path(&url),
origin,
secure,
host: std::env::var("DASHBOARD_HOST").ok().filter(|h| !h.is_empty()).unwrap_or_else(|| "0.0.0.0".into()),
@ -137,7 +148,7 @@ impl Web {
}
fn set_cookie(&self, resp: &mut Response, name: &str, value: &str, max_age: u64) {
let c = format!("{name}={value}; Max-Age={max_age}; Path=/; HttpOnly; SameSite=Lax{}", if self.cfg.secure { "; Secure" } else { "" });
let c = format!("{name}={value}; Max-Age={max_age}; Path={}; HttpOnly; SameSite=Lax{}", if self.cfg.base.is_empty() { "/" } else { &self.cfg.base }, if self.cfg.secure { "; Secure" } else { "" });
if let Ok(v) = HeaderValue::from_str(&c) {
resp.headers_mut().append(header::SET_COOKIE, v);
}
@ -197,7 +208,7 @@ impl Web {
async fn login(AxState(w): AxState<Shared>, axum::extract::Query(q): axum::extract::Query<std::collections::HashMap<String, String>>) -> Response {
if !w.sign_in_ready() {
return Redirect::to("/dashboard?error=setup").into_response();
return Redirect::to(&format!("{}/dashboard?error=setup", w.cfg.base)).into_response();
}
let state = random_token(24);
let params = [("client_id", w.state.app_id().to_string()), ("redirect_uri", format!("{}/callback", w.cfg.url)), ("response_type", "code".into()), ("scope", "identify".into()), ("state", state.clone()), ("prompt", "none".into())];
@ -211,7 +222,7 @@ async fn login(AxState(w): AxState<Shared>, axum::extract::Query(q): axum::extra
}
async fn callback(AxState(w): AxState<Shared>, headers: HeaderMap, axum::extract::Query(q): axum::extract::Query<std::collections::HashMap<String, String>>) -> Response {
let fail = |why: &str| Redirect::to(&format!("/dashboard?error={why}")).into_response();
let fail = |why: &str| Redirect::to(&format!("{}/dashboard?error={why}", w.cfg.base)).into_response();
let (state, code) = (q.get("state").cloned().unwrap_or_default(), q.get("code").cloned().unwrap_or_default());
let expected = cookie_value(&headers, STATE_COOKIE).unwrap_or_default();
if code.is_empty() || expected.is_empty() || state != expected {
@ -238,7 +249,7 @@ async fn callback(AxState(w): AxState<Shared>, headers: HeaderMap, axum::extract
}));
tracing::info!("Dashboard sign-in: {} ({})", me["username"], me["id"]);
let after = cookie_value(&headers, NEXT_COOKIE).filter(|a| AFTER_LOGIN.contains(&a.as_str())).unwrap_or_else(|| "/dashboard".into());
let mut resp = Redirect::to(&after).into_response();
let mut resp = Redirect::to(&format!("{}{after}", w.cfg.base)).into_response();
w.set_cookie(&mut resp, SESSION_COOKIE, &raw, SESSION_DAYS * 86400);
w.set_cookie(&mut resp, STATE_COOKIE, "", 0);
w.set_cookie(&mut resp, NEXT_COOKIE, "", 0);
@ -258,8 +269,10 @@ async fn logout(AxState(w): AxState<Shared>, headers: HeaderMap) -> ApiResult {
// ---- headers + pages --------------------------------------------------------------------------------------------
async fn headers_mw(request: Request, next: Next) -> Response {
let path = request.uri().path().to_string();
async fn headers_mw(AxState(base): AxState<String>, request: Request, next: Next) -> Response {
let full = request.uri().path().to_string();
// Rules below match the path without the base, so they hold under /dezio/ and without it.
let path = if base.is_empty() { full } else { full.strip_prefix(base.as_str()).unwrap_or(&full).to_string() };
let mut resp = next.run(request).await;
let h = resp.headers_mut();
h.insert("x-content-type-options", HeaderValue::from_static("nosniff"));
@ -286,27 +299,43 @@ async fn headers_mw(request: Request, next: Next) -> Response {
pub fn router(w: Shared) -> Router {
let site = paths::web(&["site"]);
let app = paths::web(&["dashboard"]);
let page = |dir: &std::path::Path, name: &str| ServeFile::new(dir.join(name));
Router::new()
let base = w.cfg.base.clone();
// HTML pages carry `__BASE__` where a root-absolute path would go; it becomes the base path here.
let page = |dir: &std::path::Path, name: &str| {
let file = dir.join(name);
let base = base.clone();
get(move || {
let (file, base) = (file.clone(), base.clone());
async move {
let html = tokio::fs::read_to_string(&file).await.unwrap_or_default().replace("__BASE__", &base);
([(header::CONTENT_TYPE, "text/html; charset=utf-8")], html).into_response()
}
})
};
let inner: Router<Shared> = Router::new()
.route("/login", get(login))
.route("/callback", get(callback))
.route("/logout", post(logout))
.merge(api::routes())
.merge(activity::routes())
.route_service("/dashboard", page(&app, "index.html"))
.route_service("/dashboard/", page(&app, "index.html"))
.route_service("/", page(&site, "index.html"))
.route_service("/index.html", page(&site, "index.html"))
.route_service("/terms", page(&site, "terms.html"))
.route_service("/terms.html", page(&site, "terms.html"))
.route_service("/privacy", page(&site, "privacy.html"))
.route_service("/privacy.html", page(&site, "privacy.html"))
.route("/dashboard", page(&app, "index.html"))
.route("/dashboard/", page(&app, "index.html"))
.route("/", page(&site, "index.html"))
.route("/index.html", page(&site, "index.html"))
.route("/terms", page(&site, "terms.html"))
.route("/terms.html", page(&site, "terms.html"))
.route("/privacy", page(&site, "privacy.html"))
.route("/privacy.html", page(&site, "privacy.html"))
.nest_service("/dashboard/static", ServeDir::new(app.join("static")))
.nest_service("/assets", ServeDir::new(site.join("assets")))
.nest_service("/images", ServeDir::new(site.join("images")))
// files too big for Discord, kept for a few hours (see hosted.rs)
.nest_service("/f", ServeDir::new(crate::hosted::dir()))
.layer(middleware::from_fn(headers_mw))
.nest_service("/f", ServeDir::new(crate::hosted::dir()));
// Under a base path (/dezio) the routes live there. The un-prefixed paths stay too, so it works whether the
// reverse proxy (tailscale serve --set-path) strips the prefix or not.
let routes = if base.is_empty() { inner } else { Router::new().nest(&base, inner.clone()).merge(inner) };
routes
.layer(middleware::from_fn_with_state(base, headers_mw))
.layer(axum::extract::DefaultBodyLimit::max(64 * 1024))
.with_state(w)
}
@ -314,7 +343,8 @@ pub fn router(w: Shared) -> Router {
/// For `--web-dev`: serve on 127.0.0.1:8099 with a signed-in test session (cookie `dezio_session=devtoken`).
pub fn start_dev(state: Arc<State>) {
let url = "http://127.0.0.1:8099".to_string();
let cfg = Cfg { origin: url.clone(), url, secure: false, host: "127.0.0.1".into(), port: 8099, client_secret: "dev".into() };
let base = base_path(&url);
let cfg = Cfg { origin: url.clone(), base, url, secure: false, host: "127.0.0.1".into(), port: 8099, client_secret: "dev".into() };
let sessions = JsonStore::open(std::env::temp_dir().join("dezio-dev-sessions.json"));
sessions.set(sha("devtoken"), json!({"user_id": 4242u64, "name": "Dev Tester", "username": "devtester", "avatar": null, "csrf": "devcsrf", "created": now(), "expires": now() + 86400}));
let web = Arc::new(Web { state, cfg, sessions, activity: Arc::new(activity::Activity::new()), preview: tokio::sync::Semaphore::new(2) });
@ -357,13 +387,23 @@ mod tests {
use axum::http::{Method, Request as HttpRequest};
use tower::ServiceExt;
#[test]
fn base_path_from_dashboard_url() {
assert_eq!(base_path("https://archlinux.tail7c4f5e.ts.net/dezio"), "/dezio");
assert_eq!(base_path("https://archlinux.tail7c4f5e.ts.net/dezio/"), "/dezio");
assert_eq!(base_path("http://127.0.0.1:8099/a/b"), "/a/b");
assert_eq!(base_path("http://192.168.1.71:8080"), "");
assert_eq!(base_path("http://192.168.1.71:8080/"), "");
assert_eq!(base_path("not a url"), "");
}
fn web() -> Shared {
let _ = rustls::crypto::ring::default_provider().install_default();
let http = Arc::new(twilight_http::Client::new("x".into()));
let state = Arc::new(State::new(http, crate::cmd::Registry::new(vec![]), "x".into()));
state.set_app_id(twilight_model::id::Id::new(1));
state.set_bot_id(twilight_model::id::Id::new(2));
let cfg = Cfg { url: "http://dashboard.test".into(), origin: "http://dashboard.test".into(), secure: false, host: "127.0.0.1".into(), port: 0, client_secret: "secret".into() };
let cfg = Cfg { url: "http://dashboard.test".into(), base: String::new(), origin: "http://dashboard.test".into(), secure: false, host: "127.0.0.1".into(), port: 0, client_secret: "secret".into() };
Arc::new(Web { state, cfg, sessions: JsonStore::open(std::env::temp_dir().join(format!("dezio-ws-{}.json", rand::random::<u32>()))), activity: Arc::new(activity::Activity::new()), preview: tokio::sync::Semaphore::new(2) })
}

View file

@ -7,7 +7,8 @@
*/
'use strict';
const BASE = location.pathname.startsWith('/activity') ? '/activity' : '';
// Where this page is served from: /dezio/activity in a browser, / inside Discord (its URL mapping hides the prefix).
const BASE = location.pathname.replace(/\/(index\.html)?$/, '');
const $ = (s) => document.querySelector(s);
const CPU_HZ = 4194304;
const AUDIO_FRAMES = 4096;

View file

@ -1,14 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" data-base="__BASE__">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dezio dashboard</title>
<meta name="theme-color" content="#0f0f10">
<link rel="icon" href="/images/dezio.png">
<link rel="preload" href="/assets/fonts/rubik.woff" as="font" type="font/woff" crossorigin>
<link rel="stylesheet" href="/assets/tokens.css">
<link rel="stylesheet" href="/dashboard/static/app.css">
<link rel="icon" href="__BASE__/images/dezio.png">
<link rel="preload" href="__BASE__/assets/fonts/rubik.woff" as="font" type="font/woff" crossorigin>
<link rel="stylesheet" href="__BASE__/assets/tokens.css">
<link rel="stylesheet" href="__BASE__/dashboard/static/app.css">
</head>
<body>
<svg width="0" height="0" class="hidden" aria-hidden="true">
@ -22,7 +22,7 @@
<div class="layout hidden" id="app">
<aside class="side">
<a class="brand" href="/"><svg class="mark" width="24" height="24" aria-hidden="true"><use href="#mark"/></svg> Dezio</a>
<a class="brand" href="__BASE__/"><svg class="mark" width="24" height="24" aria-hidden="true"><use href="#mark"/></svg> Dezio</a>
<nav class="side-nav" id="side" aria-label="Pages"></nav>
<div class="who" id="who">
<img id="who-avatar" alt="">
@ -44,12 +44,12 @@
<h1>Dezio dashboard</h1>
<p id="gate-text">Sign in with Discord to change your settings and the settings of servers you manage</p>
<p class="error hidden" id="gate-error"></p>
<a class="btn primary" href="/login" id="gate-login">Sign in with Discord</a>
<a class="btn primary" href="__BASE__/login" id="gate-login">Sign in with Discord</a>
</div>
</main>
<div class="toast" id="toast" role="status" aria-live="polite"></div>
<script src="/dashboard/static/controls.js" defer></script>
<script src="/dashboard/static/app.js" defer></script>
<script src="__BASE__/dashboard/static/controls.js" defer></script>
<script src="__BASE__/dashboard/static/app.js" defer></script>
</body>
</html>

View file

@ -13,6 +13,9 @@ function toast(text, bad) {
toast.timer = setTimeout(() => el.classList.remove("show"), 3500);
}
// The site may live under a path such as /dezio; the server puts it on <html data-base>.
const BASE = document.documentElement.dataset.base || "";
async function api(method, path, body) {
const options = { method, credentials: "same-origin", headers: {} };
if (body !== undefined) {
@ -20,7 +23,7 @@ async function api(method, path, body) {
options.headers["X-CSRF-Token"] = state.me ? state.me.csrf : "";
options.body = JSON.stringify(body);
}
const response = await fetch(path, options);
const response = await fetch(BASE + path, options);
let data = {};
try { data = await response.json(); } catch (e) { /* empty answer */ }
if (!response.ok) throw new Error(data.error || `Something went wrong (${response.status})`);
@ -131,7 +134,7 @@ function quoteSection(id, title, hint, q, path) {
drawing.textContent = "Drawing";
drawing.classList.remove("err");
try {
const response = await fetch("/api/quote/preview", { method: "POST", credentials: "same-origin",
const response = await fetch(BASE + "/api/quote/preview", { method: "POST", credentials: "same-origin",
headers: { "Content-Type": "application/json", "X-CSRF-Token": state.me.csrf }, body: JSON.stringify({ style: st }) });
if (!response.ok) throw new Error((await response.json()).error || "Couldn't draw that");
const url = URL.createObjectURL(await response.blob());
@ -562,7 +565,7 @@ async function go(page, keepScroll) {
state.page = page;
state.sections = [];
refreshSaveBar();
history.replaceState(null, "", page === "me" ? "/dashboard" : `/dashboard#${page}`);
history.replaceState(null, "", page === "me" ? `${BASE}/dashboard` : `${BASE}/dashboard#${page}`);
renderSide();
const slow = setTimeout(() => { if (turn === state.turn) $("main").replaceChildren(skeleton()); }, 160);
try {
@ -603,7 +606,7 @@ async function start() {
$("app").classList.remove("hidden");
$("logout").addEventListener("click", async () => {
try { await api("POST", "/logout", {}); } catch (e) { /* signed out anyway */ }
location.href = "/dashboard";
location.href = `${BASE}/dashboard`;
});
$("save-go").addEventListener("click", saveAll);
$("save-undo").addEventListener("click", () => { state.sections = []; go(state.page, true); });

View file

@ -2,7 +2,7 @@
document.querySelectorAll("[data-year]").forEach((el) => { el.textContent = new Date().getFullYear(); });
// The dashboard only exists when the bot itself serves this site (not on the static copy).
fetch("/api/me", { credentials: "same-origin" })
fetch("api/me", { credentials: "same-origin" })
.then((r) => (r.ok ? r.json() : null))
.then((me) => {
if (!me) return;

View file

@ -41,11 +41,11 @@
<header class="top">
<div class="wrap">
<a class="brand" href="/"><img class="mark" src="images/mark.svg" alt="" width="24" height="24"> Dezio</a>
<a class="brand" href="./"><img class="mark" src="images/mark.svg" alt="" width="24" height="24"> Dezio</a>
<nav>
<a class="optional" href="#features">Features</a>
<a class="optional" href="https://discord.gg/UnSga5DmR7">Support</a>
<a class="btn hidden" href="/dashboard" data-dashboard>Dashboard</a>
<a class="btn hidden" href="dashboard" data-dashboard>Dashboard</a>
</nav>
</div>
</header>

View file

@ -11,7 +11,7 @@
<body>
<header class="top">
<div class="wrap">
<a class="brand" href="/"><img class="mark" src="images/mark.svg" alt="" width="24" height="24"> Dezio</a>
<a class="brand" href="./"><img class="mark" src="images/mark.svg" alt="" width="24" height="24"> Dezio</a>
<nav><a href="terms.html">Terms of Service</a></nav>
</div>
</header>
@ -42,7 +42,7 @@
<footer>
<div class="wrap">
<span>© <span data-year>2026</span> Dezio</span>
<nav><a href="/">Home</a><a href="terms.html">Terms of Service</a></nav>
<nav><a href="./">Home</a><a href="terms.html">Terms of Service</a></nav>
</div>
</footer>
<script src="assets/site.js" defer></script>

View file

@ -11,7 +11,7 @@
<body>
<header class="top">
<div class="wrap">
<a class="brand" href="/"><img class="mark" src="images/mark.svg" alt="" width="24" height="24"> Dezio</a>
<a class="brand" href="./"><img class="mark" src="images/mark.svg" alt="" width="24" height="24"> Dezio</a>
<nav><a href="privacy.html">Privacy Policy</a></nav>
</div>
</header>
@ -48,7 +48,7 @@
<footer>
<div class="wrap">
<span>© <span data-year>2026</span> Dezio</span>
<nav><a href="/">Home</a><a href="privacy.html">Privacy Policy</a></nav>
<nav><a href="./">Home</a><a href="privacy.html">Privacy Policy</a></nav>
</div>
</footer>
<script src="assets/site.js" defer></script>