diff options
Diffstat (limited to 'server/src/routes')
-rw-r--r-- | server/src/routes/mod.rs | 4 | ||||
-rw-r--r-- | server/src/routes/stream.rs | 59 | ||||
-rw-r--r-- | server/src/routes/ui/admin/mod.rs | 5 | ||||
-rw-r--r-- | server/src/routes/ui/home.rs | 2 | ||||
-rw-r--r-- | server/src/routes/ui/node.rs | 22 | ||||
-rw-r--r-- | server/src/routes/ui/player.rs | 2 | ||||
-rw-r--r-- | server/src/routes/ui/sort.rs | 16 |
7 files changed, 56 insertions, 54 deletions
diff --git a/server/src/routes/mod.rs b/server/src/routes/mod.rs index e95d714..4c7838d 100644 --- a/server/src/routes/mod.rs +++ b/server/src/routes/mod.rs @@ -3,10 +3,10 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2023 metamuffin <metamuffin.org> */ -use crate::{database::Database, federation::Federation, routes::ui::error::MyResult}; +use crate::{database::Database, routes::ui::error::MyResult}; use api::{r_api_account_login, r_api_node_raw, r_api_root, r_api_version}; use base64::Engine; -use jellybase::CONF; +use jellybase::{CONF, federation::Federation}; use log::warn; use progress::{r_player_progress, r_player_watched}; use rand::random; diff --git a/server/src/routes/stream.rs b/server/src/routes/stream.rs index e7b3d54..14db462 100644 --- a/server/src/routes/stream.rs +++ b/server/src/routes/stream.rs @@ -4,14 +4,14 @@ Copyright (C) 2023 metamuffin <metamuffin.org> */ use super::ui::{account::session::Session, error::MyError}; -use crate::{database::Database, federation::Federation}; +use crate::database::Database; use anyhow::{anyhow, Result}; use jellybase::{ + federation::Federation, permission::{NodePermissionExt, PermissionSetExt}, CONF, }; -use jellyclient::LoginDetails; -use jellycommon::{stream::StreamSpec, user::UserPermission, MediaSource}; +use jellycommon::{stream::StreamSpec, user::UserPermission, TrackSource}; use log::{info, warn}; use rocket::{ get, head, @@ -58,35 +58,36 @@ pub async fn r_stream( .as_ref() .ok_or(anyhow!("item does not contain media"))?; - if let MediaSource::Remote { host, remote_id } = source { - session - .user - .permissions - .assert(&UserPermission::FederatedContent)?; + // TODO federated streams + // if let MediaSource::Remote { host, remote_id } = source { + // session + // .user + // .permissions + // .assert(&UserPermission::FederatedContent)?; - let (username, password, _) = CONF - .remote_credentials - .get(host) - .ok_or(anyhow!("no credentials on the server-side"))?; + // let (username, password, _) = CONF + // .remote_credentials + // .get(host) + // .ok_or(anyhow!("no credentials on the server-side"))?; - info!("creating session on {host}"); - let instance = federation.get_instance(&host)?.to_owned(); - let session = instance - .login(LoginDetails { - username: username.to_owned(), - password: password.to_owned(), - expire: Some(60), - drop_permissions: Some(HashSet::from_iter([ - UserPermission::ManageSelf, - UserPermission::Admin, // in case somebody federated the admin :))) - ])), - }) - .await?; + // info!("creating session on {host}"); + // let instance = federation.get_instance(&host)?.to_owned(); + // let session = instance + // .login(LoginDetails { + // username: username.to_owned(), + // password: password.to_owned(), + // expire: Some(60), + // drop_permissions: Some(HashSet::from_iter([ + // UserPermission::ManageSelf, + // UserPermission::Admin, // in case somebody federated the admin :))) + // ])), + // }) + // .await?; - let uri = session.stream(&remote_id, &spec); - info!("federation redirect"); - return Ok(Either::Right(RedirectResponse(uri))); - } + // let uri = session.stream(&remote_id, &spec); + // info!("federation redirect"); + // return Ok(Either::Right(RedirectResponse(uri))); + // } info!( "stream request (range={})", diff --git a/server/src/routes/ui/admin/mod.rs b/server/src/routes/ui/admin/mod.rs index 0d1ee0a..b976192 100644 --- a/server/src/routes/ui/admin/mod.rs +++ b/server/src/routes/ui/admin/mod.rs @@ -9,8 +9,6 @@ pub mod user; use super::account::session::AdminSession; use crate::{ database::Database, - federation::Federation, - import::import, routes::ui::{ admin::log::rocket_uri_macro_r_admin_log, error::MyResult, @@ -19,7 +17,8 @@ use crate::{ uri, }; use anyhow::anyhow; -use jellybase::CONF; +use jellybase::{federation::Federation, CONF}; +use jellyimport::import; use rand::Rng; use rocket::{form::Form, get, post, FromForm, State}; use std::time::Instant; diff --git a/server/src/routes/ui/home.rs b/server/src/routes/ui/home.rs index bcbc847..74e9b02 100644 --- a/server/src/routes/ui/home.rs +++ b/server/src/routes/ui/home.rs @@ -77,7 +77,7 @@ pub fn r_home(sess: Session, db: &State<Database>) -> MyResult<DynLayoutPage> { Ok(LayoutPage { title: "Home".to_string(), content: markup::new! { - p { "Welcome back " @sess.user.display_name } + p { "Welcome back, " @sess.user.display_name } h2 { "Explore " @CONF.brand } .homelist { ul {@for (id, node, udata) in &toplevel { li { @NodeCard { id, node, udata } } diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs index 6e2f532..bcb7362 100644 --- a/server/src/routes/ui/node.rs +++ b/server/src/routes/ui/node.rs @@ -72,7 +72,7 @@ pub async fn r_library_node_filter<'a>( filter_and_sort_nodes(&filter, &mut children); Ok(Either::Left(LayoutPage { - title: node.title.to_string(), + title: node.title.clone().unwrap_or_default(), content: markup::new! { @NodePage { node: &node, id: &id, udata: &udata, children: &children, filter: &filter } }, @@ -82,14 +82,14 @@ pub async fn r_library_node_filter<'a>( markup::define! { NodeCard<'a>(id: &'a str, node: &'a NodePublic, udata: &'a NodeUserData) { - @let cls = format!("node card poster {}", match node.kind {NodeKind::Channel => "aspect-square", NodeKind::Video => "aspect-thumb", NodeKind::Collection => "aspect-land", _ => "aspect-port"}); + @let cls = format!("node card poster {}", match node.kind.unwrap_or_default() {NodeKind::Channel => "aspect-square", NodeKind::Video => "aspect-thumb", NodeKind::Collection => "aspect-land", _ => "aspect-port"}); div[class=cls] { .poster { a[href=uri!(r_library_node(id))] { img[src=uri!(r_item_assets(id, AssetRole::Poster, Some(1024)))]; } .cardhover.item { - @if !(matches!(node.kind, NodeKind::Collection | NodeKind::Channel)) { + @if !(matches!(node.kind.unwrap_or_default(), NodeKind::Collection | NodeKind::Channel)) { a.play.icon[href=&uri!(r_player(id, PlayerConfig::default()))] { "play_arrow" } } @Props { node, udata } @@ -103,17 +103,17 @@ markup::define! { } } NodePage<'a>(id: &'a str, node: &'a NodePublic, udata: &'a NodeUserData, children: &'a Vec<(String, NodePublic, NodeUserData)>, filter: &'a NodeFilterSort) { - @if !matches!(node.kind, NodeKind::Collection) { + @if !matches!(node.kind.unwrap_or_default(), NodeKind::Collection) { img.backdrop[src=uri!(r_item_assets(id, AssetRole::Backdrop, Some(2048)))]; } .page.node { - @if !matches!(node.kind, NodeKind::Collection) { + @if !matches!(node.kind.unwrap_or_default(), NodeKind::Collection) { div.bigposter { img[src=uri!(r_item_assets(id, AssetRole::Poster, Some(2048)))]; } } .title { h1 { @node.title } @if node.media.is_some() { a.play[href=&uri!(r_player(id, PlayerConfig::default()))] { "Watch now" }} - @if !matches!(node.kind, NodeKind::Collection | NodeKind::Channel) { + @if !matches!(node.kind.unwrap_or_default(), NodeKind::Collection | NodeKind::Channel) { @match udata.watched { WatchedState::None | WatchedState::Progress(_) => { @@ -152,15 +152,15 @@ markup::define! { } } } - @if matches!(node.kind, NodeKind::Collection | NodeKind::Channel) { - @if matches!(node.kind, NodeKind::Collection) { + @if matches!(node.kind.unwrap_or_default(), NodeKind::Collection | NodeKind::Channel) { + @if matches!(node.kind.unwrap_or_default(), NodeKind::Collection) { @if let Some(parent) = &node.path.last().cloned() { a.dirup[href=uri!(r_library_node(parent))] { "Go up" } } } @NodeFilterSortForm { f: filter } } - @match node.kind { + @match node.kind.unwrap_or_default() { NodeKind::Collection | NodeKind::Channel => { ul.children {@for (id, node, udata) in children.iter() { li { @NodeCard { id, node, udata } } @@ -261,7 +261,9 @@ impl MediaInfoExt for MediaInfo { let mut maxdim = 0; for t in &self.tracks { match &t.kind { - SourceTrackKind::Video { width, height, .. } => maxdim = maxdim.max(*width.max(height)), + SourceTrackKind::Video { width, height, .. } => { + maxdim = maxdim.max(*width.max(height)) + } _ => (), } } diff --git a/server/src/routes/ui/player.rs b/server/src/routes/ui/player.rs index 177a5f6..8b8adf6 100644 --- a/server/src/routes/ui/player.rs +++ b/server/src/routes/ui/player.rs @@ -59,7 +59,7 @@ pub fn r_player<'a>( let conf = player_conf(item.clone(), playing)?; Ok(LayoutPage { - title: item.public.title.to_owned(), + title: item.public.title.to_owned().unwrap_or_default(), class: Some("player"), content: markup::new! { @if playing { diff --git a/server/src/routes/ui/sort.rs b/server/src/routes/ui/sort.rs index c7fbfc2..143a101 100644 --- a/server/src/routes/ui/sort.rs +++ b/server/src/routes/ui/sort.rs @@ -139,14 +139,14 @@ 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 == NodeKind::Movie, - FilterProperty::KindVideo => node.kind == NodeKind::Video, - 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::KindMovie => node.kind == Some(NodeKind::Movie), + FilterProperty::KindVideo => node.kind == Some(NodeKind::Video), + 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::Watched => udata.watched == WatchedState::Watched, FilterProperty::Unwatched => udata.watched == WatchedState::None, FilterProperty::WatchProgress => { |