diff options
Diffstat (limited to 'server/src/routes/ui/node.rs')
-rw-r--r-- | server/src/routes/ui/node.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs index 9162982..855da45 100644 --- a/server/src/routes/ui/node.rs +++ b/server/src/routes/ui/node.rs @@ -7,7 +7,7 @@ use crate::{ }; use anyhow::{anyhow, Context}; use log::info; -use rocket::{get, uri, State}; +use rocket::{get, http::ContentType, uri, State}; use std::{ops::Deref, path::PathBuf, sync::Arc}; use tokio::fs::File; @@ -54,8 +54,11 @@ markup::define! { } ItemCard(item: Arc<Item>) { div.card.item { - a[href=&uri!(r_library_node(&item.lib_path)).to_string()] { - img[src=uri!(r_item_assets(&item.lib_path)).to_string()]; + div.banner { + a[href=&uri!(r_library_node(&item.lib_path)).to_string()] { + img[src=uri!(r_item_assets(&item.lib_path)).to_string()]; + } + div.hover { a[href=&player_uri(&item.lib_path)] { "▶" } } } a[href=&uri!(r_library_node(&item.lib_path)).to_string()] { p.title { @item.info.title } @@ -63,17 +66,15 @@ markup::define! { } } ItemPage(item: Arc<Item>) { + // TODO different image here + img.backdrop[src=uri!(r_item_assets(&item.lib_path)).to_string()]; div.page.item { - div.backdrop { - // TODO different image here - img[src=uri!(r_item_assets(&item.lib_path)).to_string()]; - } div.banner { img[src=uri!(r_item_assets(&item.lib_path)).to_string()]; } div.title { h1 { @item.info.title } - a[href=&player_uri(&item.lib_path)] { "Watch now" } + a.play[href=&player_uri(&item.lib_path)] { "Watch now" } } div.details { h3 { "Lorem Ipsum!" } @@ -84,7 +85,10 @@ markup::define! { } #[get("/item_assets/<path..>")] -pub async fn r_item_assets(path: PathBuf, state: &State<AppState>) -> Result<File, MyError> { +pub async fn r_item_assets( + path: PathBuf, + state: &State<AppState>, +) -> Result<(ContentType, File), MyError> { let node = state .library .nested_path(&path) @@ -98,5 +102,5 @@ pub async fn r_item_assets(path: PathBuf, state: &State<AppState>) -> Result<Fil .ok_or(anyhow!("no banner available"))?, ); info!("loading asset from {path:?}"); - Ok(File::open(path).await?) + Ok((ContentType::WEBP, File::open(path).await?)) } |