diff --git a/content/mp-tracks.json b/content/mp-tracks.json index 3242421..4c71b65 100644 --- a/content/mp-tracks.json +++ b/content/mp-tracks.json @@ -3,36 +3,36 @@ "id": 1, "title": "Good old times", "artist": "Agahnim", - "src": "/static/music/times.mp3" + "src": "/static/assets/music/times.mp3" }, { "id": 2, "title": "Identification", "artist": "Infinity Frequencies", - "src": "/static/music/infinity.mp3" + "src": "/static/assets/music/infinity.mp3" }, { "id": 3, "title": "Flip the Switch", "artist": "Stevia Sphere", - "src": "/static/music/switch.mp3" + "src": "/static/assets/music/switch.mp3" }, { "id": 4, "title": "Machines Vs Water", "artist": "Stevia Sphere", - "src": "/static/music/machines.mp3" + "src": "/static/assets/music/machines.mp3" }, { "id": 5, "title": "Elevator 1", "artist": "Stevia Sphere", - "src": "/static/music/elevator.mp3" + "src": "/static/assets/music/elevator.mp3" }, { "id": 6, "title": "Somewhere Dark", "artist": "Monodrone", - "src": "/static/music/dark.mp3" + "src": "/static/assets/music/dark.mp3" } ] \ No newline at end of file diff --git a/content/p-tracks.json b/content/p-tracks.json index f9d8f46..215e1d8 100644 --- a/content/p-tracks.json +++ b/content/p-tracks.json @@ -3,70 +3,70 @@ "id": 1, "title": "I'm getting tired of farewells", "artist": "Agahnim", - "src": "/static/music/farewells.mp3", + "src": "/static/assets/music/farewells.mp3", "album": "LIFE" }, { "id": 2, "title": "DAWN", "artist": "Agahnim", - "src": "/static/music/DAWN.mp3", + "src": "/static/assets/music/DAWN.mp3", "album": "DAWN" }, { "id": 3, "title": "Move on", "artist": "Agahnim", - "src": "/static/music/move_on.mp3", + "src": "/static/assets/music/move_on.mp3", "album": "DAWN" }, { "id": 4, "title": "Carcer", "artist": "Agahnim", - "src": "/static/music/carcer.mp3", + "src": "/static/assets/music/carcer.mp3", "album": "LIFE" }, { "id": 5, "title": "Under listening", "artist": "Agahnim", - "src": "/static/music/listening.mp3", + "src": "/static/assets/music/listening.mp3", "album": "Justice" }, { "id": 6, "title": "Fading away", "artist": "Agahnim", - "src": "/static/music/fading.mp3", + "src": "/static/assets/music/fading.mp3", "album": "LIFE" }, { "id": 7, "title": "Hindsight", "artist": "Agahnim", - "src": "/static/music/hindsight.mp3", + "src": "/static/assets/music/hindsight.mp3", "album": "The End" }, { "id": 8, "title": "With or without", "artist": "Agahnim", - "src": "/static/music/without.mp3", + "src": "/static/assets/music/without.mp3", "album": "Extinction" }, { "id": 9, "title": "Perfect Light", "artist": "Agahnim", - "src": "/static/music/perfect_light.mp3", + "src": "/static/assets/music/perfect_light.mp3", "album": "Rebirth" }, { "id": 10, "title": "Good old times", "artist": "Agahnim", - "src": "/static/music/times.mp3", + "src": "/static/assets/music/times.mp3", "album": "Extinction" } ] \ No newline at end of file diff --git a/src/domain.rs b/src/domain.rs index f9ff12d..6c4184f 100644 --- a/src/domain.rs +++ b/src/domain.rs @@ -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, } diff --git a/src/main.rs b/src/main.rs index 5ac7672..eb9b862 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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) diff --git a/src/templates/mod.rs b/src/templates/mod.rs index b2b9394..8b35472 100644 --- a/src/templates/mod.rs +++ b/src/templates/mod.rs @@ -1,3 +1,4 @@ pub mod index; pub mod miniplayer; +pub mod music; pub mod notfound; diff --git a/src/templates/music.rs b/src/templates/music.rs new file mode 100644 index 0000000..9337657 --- /dev/null +++ b/src/templates/music.rs @@ -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()) + } +} diff --git a/templates/base.html b/templates/base.html index ecd5171..21f0279 100644 --- a/templates/base.html +++ b/templates/base.html @@ -12,11 +12,30 @@ {% include "partials/header.html" %} - +
+ +

Chargement...

+
+
+
{% block content %}{% endblock %}
+ \ No newline at end of file diff --git a/templates/music.html b/templates/music.html new file mode 100644 index 0000000..dceed8d --- /dev/null +++ b/templates/music.html @@ -0,0 +1,5 @@ +{% extends "base.html" %} + +{% block content %} +{% include "partials/music.html" %} +{% endblock %} diff --git a/templates/partials/miniplayer.html b/templates/partials/miniplayer.html index 76a38f7..873eda3 100644 --- a/templates/partials/miniplayer.html +++ b/templates/partials/miniplayer.html @@ -1,3 +1,13 @@ -

Je suis un miniplayer

-
\ No newline at end of file +

Miniplayer

+ {% if tracks.is_empty() %} +

Aucune track

+ {% else %} + {% for track in tracks %} +
+

{{ track.title }} - {{ track.artist }}

+ +
+ {% endfor %} + {% endif %} + diff --git a/templates/partials/music.html b/templates/partials/music.html new file mode 100644 index 0000000..e2b4616 --- /dev/null +++ b/templates/partials/music.html @@ -0,0 +1 @@ +

y'a pas de miniplayer ici

\ No newline at end of file