aboutsummaryrefslogtreecommitdiff
path: root/ui/src/node_page.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/node_page.rs')
-rw-r--r--ui/src/node_page.rs31
1 files changed, 16 insertions, 15 deletions
diff --git a/ui/src/node_page.rs b/ui/src/node_page.rs
index fa5c93b..f52ea5b 100644
--- a/ui/src/node_page.rs
+++ b/ui/src/node_page.rs
@@ -4,11 +4,12 @@
Copyright (C) 2026 metamuffin <metamuffin.org>
*/
-use crate::Page;
+use crate::{Page, scaffold::RenderInfo};
use jellycommon::{
- jellyobject::{Object, Tag},
+ jellyobject::{Object, Tag, TypedTag},
*,
};
+use std::marker::PhantomData;
impl Page for NodePage<'_> {
fn title(&self) -> String {
@@ -29,7 +30,7 @@ pub struct NodeUdata<'a> {
markup::define! {
NodePage<'a>(
- ri: RenderInfo<'a>,
+ ri: &'a RenderInfo<'a>,
node: NodeUdata<'a>,
children: &'a [NodeUdata<'a>],
parents: &'a [NodeUdata<'a>],
@@ -184,9 +185,9 @@ markup::define! {
}
}
-fn chapter_key_time(c: &Chapter, dur: f64) -> f64 {
- let start = c.time_start.unwrap_or(0.);
- let end = c.time_end.unwrap_or(dur);
+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
}
@@ -199,17 +200,17 @@ pub fn aspect_class(kind: Tag) -> &'static str {
}
}
-fn external_id_url(key: IdentifierType, value: &str) -> Option<String> {
- Some(match key {
- IdentifierType::YoutubeVideo => format!("https://youtube.com/watch?v={value}"),
- IdentifierType::YoutubeChannel => format!("https://youtube.com/channel/{value}"),
- IdentifierType::YoutubeChannelHandle => format!("https://youtube.com/channel/@{value}"),
- IdentifierType::MusicbrainzRelease => format!("https://musicbrainz.org/release/{value}"),
- IdentifierType::MusicbrainzArtist => format!("https://musicbrainz.org/artist/{value}"),
- IdentifierType::MusicbrainzReleaseGroup => {
+fn external_id_url(key: Tag, value: &str) -> Option<String> {
+ Some(match TypedTag(key, PhantomData) {
+ IDENT_YOUTUBE_VIDEO => format!("https://youtube.com/watch?v={value}"),
+ IDENT_YOUTUBE_CHANNEL => format!("https://youtube.com/channel/{value}"),
+ IDENT_YOUTUBE_CHANNEL_HANDLE => format!("https://youtube.com/channel/@{value}"),
+ IDENT_MUSICBRAINZ_RELEASE => format!("https://musicbrainz.org/release/{value}"),
+ IDENT_MUSICBRAINZ_ARTIST => format!("https://musicbrainz.org/artist/{value}"),
+ IDENT_MUSICBRAINZ_RELEASE_GROUP => {
format!("https://musicbrainz.org/release-group/{value}")
}
- IdentifierType::MusicbrainzRecording => {
+ IDENT_MUSICBRAINZ_RECORDING => {
format!("https://musicbrainz.org/recording/{value}")
}
_ => return None,