aboutsummaryrefslogtreecommitdiff
path: root/ui/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-03-12 04:31:30 +0100
committermetamuffin <metamuffin@disroot.org>2026-03-12 04:31:30 +0100
commit854504fac9444463495aaaf589c0c27823779ce9 (patch)
treecb1c345fa2ec9197c333cb4796525c80b1bbe705 /ui/src
parent8d9b20d56d90d61de5b13cf2c3fc39f4c508611e (diff)
downloadjellything-854504fac9444463495aaaf589c0c27823779ce9.tar
jellything-854504fac9444463495aaaf589c0c27823779ce9.tar.bz2
jellything-854504fac9444463495aaaf589c0c27823779ce9.tar.zst
chapters and their thumbnails
Diffstat (limited to 'ui/src')
-rw-r--r--ui/src/components/node_page.rs55
1 files changed, 34 insertions, 21 deletions
diff --git a/ui/src/components/node_page.rs b/ui/src/components/node_page.rs
index 53dd904..06d8b55 100644
--- a/ui/src/components/node_page.rs
+++ b/ui/src/components/node_page.rs
@@ -10,11 +10,12 @@ use crate::{
node_card::{NodeCard, NodeCardWide},
props::Props,
},
+ format::format_duration,
page,
};
use jellycommon::{
jellyobject::{EMPTY, Object, Tag, TypedTag},
- routes::{u_image, u_node_slug_player},
+ routes::{u_image, u_node_slug_player, u_node_slug_player_time, u_node_slug_thumbnail},
*,
};
use jellyui_locale::tr;
@@ -92,21 +93,6 @@ markup::define! {
@if let Some(description) = &node.get(NO_DESCRIPTION) {
p { @for line in description.lines() { @line br; } }
}
- // @if !media.chapters.is_empty() {
- // h2 { @trs(lang, "node.chapters") }
- // ul.children.hlist { @for chap in &media.chapters {
- // @let (inl, sub) = format_chapter(chap);
- // li { .card."aspect-thumb" {
- // .poster {
- // a[href=u_node_slug_player_time(&node.slug, chap.time_start.unwrap_or(0.))] {
- // img[src=u_node_slug_thumbnail(&node.slug, chapter_key_time(chap, media.duration), 1024), loading="lazy"];
- // }
- // .cardhover { .props { p { @inl } } }
- // }
- // .title { span { @sub } }
- // }}
- // }}
- // }
@if node.has(NO_TRACK.0) {
details {
summary { @tr(ri.lang, "tag.trak") }
@@ -157,6 +143,21 @@ markup::define! {
}
}
}
+ @if node.has(NO_CHAPTER.0) {
+ h2 { @tr(ri.lang, "tag.chpt") }
+ ul.nl.inline { @for chap in node.iter(NO_CHAPTER) {
+ @let (inl, sub) = format_chapter(chap);
+ li { .card."aspect-thumb" {
+ .poster {
+ a[href=u_node_slug_player_time(&slug, chap.get(CH_START).unwrap_or(0.))] {
+ img[src=u_node_slug_thumbnail(&slug, chapter_key_time(chap, node.get(NO_DURATION).unwrap_or(1.)), 512), loading="lazy"];
+ }
+ .overlay { .props { p { @inl } } }
+ }
+ .title { span { @sub } }
+ }}
+ }}
+ }
}
@for (cat, items) in *credits {
@@ -191,11 +192,23 @@ markup::define! {
}
}
-// fn chapter_key_time(c: Object, dur: f64) -> f64 {
-// let start = c.get(CH_START).unwrap_or(0.);
-// let end = c.get(CH_END).unwrap_or(dur);
-// start * 0.8 + end * 0.2
-// }
+fn chapter_key_time(c: &Object, dur: f64) -> f64 {
+ let start = c.get(CH_START).unwrap_or(0.);
+ let end = c.get(CH_END).unwrap_or(dur);
+ start * 0.8 + end * 0.2
+}
+fn format_chapter(c: &Object) -> (String, String) {
+ (
+ format!(
+ "{} - {}",
+ format_duration(c.get(CH_START).unwrap_or(0.)),
+ c.get(CH_END)
+ .map(|x| format_duration(x))
+ .unwrap_or_default(),
+ ),
+ c.get(CH_NAME).map(|s| s.to_string()).unwrap_or_default(),
+ )
+}
pub fn aspect_class(node: &Object) -> &'static str {
let kind = node.get(NO_KIND).unwrap_or(KIND_COLLECTION);