AkurAI Build
Menu

Public repository / d63e826eb482cb963477774b04fe8a84f23f0e45

AkurAI-Drive / backend/src/pages.rs

Latest change ddc31462ceddd45c4426bf90e65a21aedab2df32 - refactor(drive): share theme presentation shell by AkurAI Agent

use axum::{
    http::{HeaderMap, StatusCode, header},
    response::{Html, IntoResponse, Response},
};

use crate::session;

/// `GET /app` — the authenticated dashboard. Redirects to `/auth/login` without a
/// valid session, otherwise serves the dashboard HTML.
///
/// NOTE: `static/app.html` is the real dashboard, provided by a separate frontend
/// agent. A minimal placeholder is committed so the crate compiles standalone; the
/// real file replaces it without any code change here.
pub async fn app(headers: HeaderMap) -> Response {
    match session::lookup_session(&headers) {
        Some(_) => Html(include_str!("../static/app.html")).into_response(),
        None => (StatusCode::FOUND, [(header::LOCATION, "/auth/login")]).into_response(),
    }
}

/// `GET /js/monitor-client.js` — browser-side Monitor shipper.
pub async fn monitor_client() -> Response {
    (
        [(header::CONTENT_TYPE, "text/javascript; charset=utf-8")],
        include_str!("../static/js/monitor-client.js"),
    )
        .into_response()
}

/// Public dashboard dependencies. These are deliberately allowlisted instead
/// of exposing the whole static tree or filesystem.
pub async fn theme_js() -> Response {
    (
        [(header::CONTENT_TYPE, "text/javascript; charset=utf-8")],
        include_str!("../../site/frontend/theme.js"),
    )
        .into_response()
}

pub async fn themes_css() -> Response {
    (
        [(header::CONTENT_TYPE, "text/css; charset=utf-8")],
        include_str!("../static/themes.css"),
    )
        .into_response()
}

pub async fn shared_shell_css() -> Response {
    (
        [(header::CONTENT_TYPE, "text/css; charset=utf-8")],
        include_str!("../../site/frontend/shared-shell.css"),
    )
        .into_response()
}

pub async fn themes_json() -> Response {
    (
        [(header::CONTENT_TYPE, "application/json; charset=utf-8")],
        include_str!("../static/themes.json"),
    )
        .into_response()
}

pub async fn favicon() -> Response {
    (
        [(header::CONTENT_TYPE, "image/svg+xml")],
        include_str!("../../site/frontend/favicon.svg"),
    )
        .into_response()
}

pub async fn apple_touch_icon() -> Response {
    (
        [(header::CONTENT_TYPE, "image/png")],
        include_bytes!("../../site/frontend/apple-touch-icon.png").as_slice(),
    )
        .into_response()
}