mini-player: implemented
This commit is contained in:
parent
55fa3b9196
commit
36208255b2
10 changed files with 81 additions and 23 deletions
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
pub mod index;
|
||||
pub mod miniplayer;
|
||||
pub mod music;
|
||||
pub mod notfound;
|
||||
|
|
|
|||
21
src/templates/music.rs
Normal file
21
src/templates/music.rs
Normal 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())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue