mini-player: implemented

This commit is contained in:
Agahnim 2026-03-20 11:28:11 +01:00
parent a741d256be
commit 979ac108a7
10 changed files with 81 additions and 23 deletions

View file

@ -24,7 +24,7 @@ impl AppState {
#[derive(Deserialize, Clone)]
pub struct Track {
title: String,
artist: String,
src: String,
pub title: String,
pub artist: String,
pub src: String,
}

View file

@ -2,7 +2,7 @@ use std::sync::Arc;
use agahnim_web_v2::{
domain::AppState,
templates::{index::home, miniplayer::miniplayer, notfound::notfound},
templates::{index::home, miniplayer::miniplayer, music::music, notfound::notfound},
};
use axum::{Router, routing::get};
use tower_http::services::ServeDir;
@ -15,6 +15,7 @@ async fn main() {
let app = Router::new()
.route("/", get(home))
.route("/music", get(music))
.route("/miniplayer", get(miniplayer))
.nest_service("/static", ServeDir::new("static"))
.fallback(notfound)

View file

@ -1,3 +1,4 @@
pub mod index;
pub mod miniplayer;
pub mod music;
pub mod notfound;

21
src/templates/music.rs Normal file
View file

@ -0,0 +1,21 @@
use askama::Template;
use axum::{
http::HeaderMap,
response::{Html, IntoResponse},
};
#[derive(Template)]
#[template(path = "music.html")]
struct MusicTemplate;
#[derive(Template)]
#[template(path = "partials/music.html")]
struct MusicPartialTemplate;
pub async fn music(headers: HeaderMap) -> impl IntoResponse {
if headers.contains_key("hx-request") {
Html(MusicPartialTemplate.render().unwrap())
} else {
Html(MusicTemplate.render().unwrap())
}
}