aboutsummaryrefslogtreecommitdiff
path: root/server/src/routes
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-02-02 00:25:45 +0100
committermetamuffin <metamuffin@disroot.org>2025-02-02 00:25:45 +0100
commit1534bb6d8f88d83c1ce9c89d007af04dcc3291f1 (patch)
tree4df67a6ad396a97094afd7dd9e57775320075655 /server/src/routes
parent4993f189870a96a328bdda5838d1d184c1bbdb67 (diff)
downloadjellything-1534bb6d8f88d83c1ce9c89d007af04dcc3291f1.tar
jellything-1534bb6d8f88d83c1ce9c89d007af04dcc3291f1.tar.bz2
jellything-1534bb6d8f88d83c1ce9c89d007af04dcc3291f1.tar.zst
node visibility
Diffstat (limited to 'server/src/routes')
-rw-r--r--server/src/routes/ui/assets.rs4
-rw-r--r--server/src/routes/ui/browser.rs3
-rw-r--r--server/src/routes/ui/home.rs6
-rw-r--r--server/src/routes/ui/node.rs27
-rw-r--r--server/src/routes/ui/sort.rs22
5 files changed, 35 insertions, 27 deletions
diff --git a/server/src/routes/ui/assets.rs b/server/src/routes/ui/assets.rs
index ac808b1..a01c8bc 100644
--- a/server/src/routes/ui/assets.rs
+++ b/server/src/routes/ui/assets.rs
@@ -80,7 +80,7 @@ pub async fn r_item_poster(
}
};
let asset = asset.unwrap_or_else(|| {
- AssetInner::Assets(format!("fallback-{:?}.avif", node.kind.unwrap_or_default()).into())
+ AssetInner::Assets(format!("fallback-{:?}.avif", node.kind).into())
.ser()
});
Ok(Redirect::temporary(rocket::uri!(r_asset(asset.0, width))))
@@ -105,7 +105,7 @@ pub async fn r_item_backdrop(
}
};
let asset = asset.unwrap_or_else(|| {
- AssetInner::Assets(format!("fallback-{:?}.avif", node.kind.unwrap_or_default()).into())
+ AssetInner::Assets(format!("fallback-{:?}.avif", node.kind).into())
.ser()
});
Ok(Redirect::temporary(rocket::uri!(r_asset(asset.0, width))))
diff --git a/server/src/routes/ui/browser.rs b/server/src/routes/ui/browser.rs
index a15dc27..7affbac 100644
--- a/server/src/routes/ui/browser.rs
+++ b/server/src/routes/ui/browser.rs
@@ -11,6 +11,7 @@ use super::{
sort::{filter_and_sort_nodes, NodeFilterSort, NodeFilterSortForm, SortOrder, SortProperty},
};
use crate::{database::Database, uri};
+use jellycommon::Visibility;
use rocket::{get, State};
/// This function is a stub and only useful for use in the uri! macro.
@@ -26,6 +27,8 @@ pub fn r_all_items_filter(
) -> Result<DynLayoutPage<'_>, MyError> {
let mut items = db.list_nodes_with_udata(sess.user.name.as_str())?;
+ items.retain(|(n, _)| matches!(n.visibility, Visibility::Visible));
+
filter_and_sort_nodes(
&filter,
(SortProperty::Title, SortOrder::Ascending),
diff --git a/server/src/routes/ui/home.rs b/server/src/routes/ui/home.rs
index 321d184..1a4f20a 100644
--- a/server/src/routes/ui/home.rs
+++ b/server/src/routes/ui/home.rs
@@ -15,7 +15,7 @@ use crate::{
use anyhow::Context;
use chrono::{Datelike, Utc};
use jellybase::CONF;
-use jellycommon::{user::WatchedState, NodeID, NodeKind, Rating};
+use jellycommon::{user::WatchedState, NodeID, NodeKind, Rating, Visibility};
use rocket::{get, State};
use tokio::fs::read_to_string;
@@ -45,8 +45,8 @@ pub fn r_home(sess: Session, db: &State<Database>) -> MyResult<DynLayoutPage> {
items.retain(|(n, _)| {
matches!(
n.kind,
- Some(NodeKind::Video | NodeKind::Movie | NodeKind::Episode | NodeKind::Music)
- )
+ NodeKind::Video | NodeKind::Movie | NodeKind::Episode | NodeKind::Music
+ ) && matches!(n.visibility, Visibility::Visible)
});
let random = (0..16)
diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs
index 2df78b4..9882e9f 100644
--- a/server/src/routes/ui/node.rs
+++ b/server/src/routes/ui/node.rs
@@ -32,7 +32,7 @@ use anyhow::{anyhow, Result};
use chrono::DateTime;
use jellycommon::{
user::{NodeUserData, WatchedState},
- Chapter, MediaInfo, Node, NodeID, NodeKind, PeopleGroup, Rating, SourceTrackKind,
+ Chapter, MediaInfo, Node, NodeID, NodeKind, PeopleGroup, Rating, SourceTrackKind, Visibility,
};
use rocket::{get, serde::json::Json, Either, State};
use std::sync::Arc;
@@ -72,7 +72,7 @@ pub async fn r_library_node_filter<'a>(
filter_and_sort_nodes(
&filter,
- match node.kind.unwrap_or(NodeKind::Collection) {
+ match node.kind {
NodeKind::Channel => (SortProperty::ReleaseDate, SortOrder::Descending),
_ => (SortProperty::Title, SortOrder::Ascending),
},
@@ -91,7 +91,7 @@ pub async fn r_library_node_filter<'a>(
markup::define! {
NodeCard<'a>(node: &'a Node, udata: &'a NodeUserData) {
- @let cls = format!("node card poster {}", aspect_class(node.kind.unwrap_or_default()));
+ @let cls = format!("node card poster {}", aspect_class(node.kind));
div[class=cls] {
.poster {
a[href=uri!(r_library_node(&node.slug))] {
@@ -117,12 +117,12 @@ markup::define! {
}
}
NodePage<'a>(id: &'a str, node: &'a Node, udata: &'a NodeUserData, children: &'a [(Arc<Node>, NodeUserData)], parents: &'a [Arc<Node>], filter: &'a NodeFilterSort) {
- @if !matches!(node.kind.unwrap_or_default(), NodeKind::Collection) {
+ @if !matches!(node.kind, NodeKind::Collection) {
img.backdrop[src=uri!(r_item_backdrop(id, Some(2048))), loading="lazy"];
}
.page.node {
- @if !matches!(node.kind.unwrap_or_default(), NodeKind::Collection) {
- @let cls = format!("bigposter {}", aspect_class(node.kind.unwrap_or_default()));
+ @if !matches!(node.kind, NodeKind::Collection) {
+ @let cls = format!("bigposter {}", aspect_class(node.kind));
div[class=cls] { img[src=uri!(r_item_poster(id, Some(2048))), loading="lazy"]; }
}
.title {
@@ -131,7 +131,7 @@ markup::define! {
a.component[href=uri!(r_library_node(&node.slug))] { @node.title }
}}}
@if node.media.is_some() { a.play[href=&uri!(r_player(id, PlayerConfig::default()))] { "Watch now" }}
- @if !matches!(node.kind.unwrap_or_default(), NodeKind::Collection | NodeKind::Channel) {
+ @if !matches!(node.kind, NodeKind::Collection | NodeKind::Channel) {
@if matches!(udata.watched, WatchedState::None | WatchedState::Pending | WatchedState::Progress(_)) {
form.mark_watched[method="POST", action=uri!(r_node_userdata_watched(id, UrlWatchedState::Watched))] {
input[type="submit", value="Mark Watched"];
@@ -214,10 +214,10 @@ markup::define! {
}
}
}
- @if matches!(node.kind.unwrap_or_default(), NodeKind::Collection | NodeKind::Channel) {
+ @if matches!(node.kind, NodeKind::Collection | NodeKind::Channel) {
@NodeFilterSortForm { f: filter }
}
- @match node.kind.unwrap_or_default() {
+ @match node.kind {
NodeKind::Show | NodeKind::Series | NodeKind::Season => {
ol { @for (c, _) in children.iter() {
li { a[href=uri!(r_library_node(&c.slug))] { @c.title } }
@@ -225,7 +225,9 @@ markup::define! {
}
NodeKind::Collection | NodeKind::Channel | _ => {
ul.children {@for (node, udata) in children.iter() {
- li { @NodeCard { node, udata } }
+ @if node.visibility != Visibility::Hidden {
+ li { @NodeCard { node, udata } }
+ }
}}
}
}
@@ -245,6 +247,11 @@ markup::define! {
@DateTime::from_timestamp_millis(*d).unwrap().date_naive().to_string()
}}
}
+ @match node.visibility {
+ Visibility::Visible => {}
+ Visibility::Reduced => {p{"Reduced visibility"}}
+ Visibility::Hidden => {p{"Hidden"}}
+ }
// TODO
// @if !node.children.is_empty() {
// p { @format!("{} items", node.children.len()) }
diff --git a/server/src/routes/ui/sort.rs b/server/src/routes/ui/sort.rs
index 6f1eade..3831431 100644
--- a/server/src/routes/ui/sort.rs
+++ b/server/src/routes/ui/sort.rs
@@ -150,18 +150,16 @@ pub fn filter_and_sort_nodes(
o &= !match p {
FilterProperty::FederationLocal => node.federated.is_none(),
FilterProperty::FederationRemote => node.federated.is_some(),
- FilterProperty::KindMovie => node.kind == Some(NodeKind::Movie),
- FilterProperty::KindVideo => node.kind == Some(NodeKind::Video),
- FilterProperty::KindShortFormVideo => {
- node.kind == Some(NodeKind::ShortFormVideo)
- }
- FilterProperty::KindMusic => node.kind == Some(NodeKind::Music),
- FilterProperty::KindCollection => node.kind == Some(NodeKind::Collection),
- FilterProperty::KindChannel => node.kind == Some(NodeKind::Channel),
- FilterProperty::KindShow => node.kind == Some(NodeKind::Show),
- FilterProperty::KindSeries => node.kind == Some(NodeKind::Series),
- FilterProperty::KindSeason => node.kind == Some(NodeKind::Season),
- FilterProperty::KindEpisode => node.kind == Some(NodeKind::Episode),
+ FilterProperty::KindMovie => node.kind == NodeKind::Movie,
+ FilterProperty::KindVideo => node.kind == NodeKind::Video,
+ FilterProperty::KindShortFormVideo => node.kind == NodeKind::ShortFormVideo,
+ FilterProperty::KindMusic => node.kind == NodeKind::Music,
+ FilterProperty::KindCollection => node.kind == NodeKind::Collection,
+ FilterProperty::KindChannel => node.kind == NodeKind::Channel,
+ FilterProperty::KindShow => node.kind == NodeKind::Show,
+ FilterProperty::KindSeries => node.kind == NodeKind::Series,
+ FilterProperty::KindSeason => node.kind == NodeKind::Season,
+ FilterProperty::KindEpisode => node.kind == NodeKind::Episode,
FilterProperty::Watched => udata.watched == WatchedState::Watched,
FilterProperty::Unwatched => udata.watched == WatchedState::None,
FilterProperty::WatchProgress => {