1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/*
This file is part of jellything (https://codeberg.org/metamuffin/jellything)
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2026 metamuffin <metamuffin.org>
*/
use crate::{
RenderInfo,
components::{node_page::aspect_class, props::Props},
};
use jellycommon::{
jellyobject::{EMPTY, Object},
routes::{u_image, u_image_fallback_person, u_node_slug, u_node_slug_player},
*,
};
markup::define! {
NodeCard<'a>(ri: &'a RenderInfo<'a>, nku: &'a Nku<'a>) {
@let node = &nku.node;
@let slug = node.get(NO_SLUG).unwrap_or_default();
div[class=&format!("card {}", aspect_class(&node))] {
.poster {
a[href=u_node_slug(&slug)] {
img[src=cover_image(&node, 512), loading="lazy"];
}
.overlay {
@if node.has(NO_TRACK.0) {
a.play.icon[href=u_node_slug_player(&slug)] { "play_arrow" }
}
@Props { ri, nku, full: false }
}
}
div.title {
a[href=u_node_slug(&slug)] {
@node.get(NO_TITLE)
}
}
div.subtitle {
span {
@nku.role.as_deref().or(node.get(NO_SUBTITLE))
}
}
}
}
NodeCardWide<'a>(ri: &'a RenderInfo<'a>, nku: Nku<'a>) {
@let node = &nku.node;
@let slug = node.get(NO_SLUG).unwrap_or_default();
div[class="card wide"] {
div[class=&format!("poster {}", aspect_class(node))] {
a[href=u_node_slug(&slug)] {
img[src=cover_image(&node, 512), loading="lazy"];
}
.overlay {
@if node.has(NO_TRACK.0) {
a.play.icon[href=u_node_slug_player(&slug)] { "play_arrow" }
}
}
}
div.details {
a.title[href=u_node_slug(&slug)] { @node.get(NO_TITLE) }
@Props { ri, nku ,full: false }
span.overview { @node.get(NO_DESCRIPTION) }
}
}
}
NodeCardHightlight<'a>(ri: &'a RenderInfo<'a>, nku: &'a Nku<'a>) {
@let node = &nku.node;
@let slug = node.get(NO_SLUG).unwrap_or_default();
@let backdrop = u_image(node.get(NO_PICTURES).unwrap_or(EMPTY).get(PICT_BACKDROP).unwrap_or_default(), 2048);
div[class="card highlight", style=format!("background-image: url(\"{backdrop}\")")] {
.inner {
div.overview {
h2 { a[href=u_node_slug(slug)] { @node.get(NO_TITLE) } }
@Props { ri, nku: *nku, full: false }
p { b { @node.get(NO_TAGLINE) } " " @node.get(NO_DESCRIPTION) }
}
div[class=&format!("poster {}", aspect_class(node))] {
a[href=u_node_slug(&slug)] {
img[src=cover_image(&node, 512), loading="lazy"];
}
.overlay {
@if node.has(NO_TRACK.0) {
a.play.icon[href=u_node_slug_player(&slug)] { "play_arrow" }
}
}
}
}
}
}
}
fn cover_image(node: &Object, size: usize) -> String {
if let Some(cover) = node.get(NO_PICTURES).unwrap_or(EMPTY).get(PICT_COVER) {
return u_image(cover, size);
}
if let Some(title) = node.get(NO_TITLE)
&& node.get(NO_KIND) == Some(KIND_PERSON)
{
return u_image_fallback_person(title, 512);
}
return String::new();
}
|