aboutsummaryrefslogtreecommitdiff
path: root/server/src/routes
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/routes')
-rw-r--r--server/src/routes/stream.rs14
-rw-r--r--server/src/routes/ui/account/session.rs3
-rw-r--r--server/src/routes/ui/node.rs5
-rw-r--r--server/src/routes/ui/player.rs6
4 files changed, 12 insertions, 16 deletions
diff --git a/server/src/routes/stream.rs b/server/src/routes/stream.rs
index 469ad07..e7547bd 100644
--- a/server/src/routes/stream.rs
+++ b/server/src/routes/stream.rs
@@ -17,15 +17,15 @@ use rocket::{
};
use std::{
ops::{Deref, Range},
- path::PathBuf,
+ path::{PathBuf, Path},
};
use tokio::io::{duplex, DuplexStream};
use tokio_util::io::SyncIoBridge;
-pub fn stream_uri(path: &PathBuf, tracks: &Vec<u64>, webm: bool) -> String {
+pub fn stream_uri(path: &Path, tracks: &[u64], webm: bool) -> String {
format!(
"/stream/{}?tracks={}&webm={}",
- path.to_str().unwrap().to_string(),
+ path.to_str().unwrap(),
tracks
.iter()
.map(|v| format!("{v}"))
@@ -54,9 +54,8 @@ pub fn r_stream(
.get_item()?;
let remuxer = remuxer.deref().clone();
let tracks = tracks
- .split(",")
+ .split(',')
.map(|e| e.parse().map_err(|_| anyhow!("invalid number")))
- .into_iter()
.collect::<Result<Vec<_>, _>>()?;
let b = SyncIoBridge::new(b);
@@ -119,10 +118,10 @@ impl RequestRange {
Ok(Self(
s.strip_prefix("bytes=")
.ok_or(anyhow!("prefix expected"))?
- .split(",")
+ .split(',')
.map(|s| {
let (l, r) = s
- .split_once("-")
+ .split_once('-')
.ok_or(anyhow!("range delimeter missing"))?;
let km = |s: &str| {
if s.is_empty() {
@@ -133,7 +132,6 @@ impl RequestRange {
};
Ok(km(l)?..km(r)?)
})
- .into_iter()
.collect::<Result<Vec<_>>>()?,
))
}
diff --git a/server/src/routes/ui/account/session.rs b/server/src/routes/ui/account/session.rs
index 3457d41..6059311 100644
--- a/server/src/routes/ui/account/session.rs
+++ b/server/src/routes/ui/account/session.rs
@@ -6,7 +6,6 @@
use crate::{
database::{Database, User},
routes::ui::error::MyError,
- CONF,
};
use anyhow::anyhow;
use rocket::{
@@ -29,7 +28,7 @@ impl Session {
#[cfg(not(feature = "bypass-auth"))]
let username = cookie.value();
#[cfg(feature = "bypass-auth")]
- let username = CONF.admin_username.to_string();
+ let username = crate::CONF.admin_username.to_string();
let db = req.guard::<&State<Database>>().await.unwrap();
let user = db
diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs
index f216df2..dd98a61 100644
--- a/server/src/routes/ui/node.rs
+++ b/server/src/routes/ui/node.rs
@@ -26,10 +26,9 @@ pub async fn r_library_node(
) -> Result<DynLayoutPage<'_>, MyError> {
let node = library
.nested_path(&path)
- .context("retrieving library node")?
- .clone();
+ .context("retrieving library node")?;
Ok(LayoutPage {
- title: format!("{}", node.title()),
+ title: node.title().to_string(),
content: markup::new! {
@NodePage { node: node.clone() }
},
diff --git a/server/src/routes/ui/player.rs b/server/src/routes/ui/player.rs
index 0fc0364..866787a 100644
--- a/server/src/routes/ui/player.rs
+++ b/server/src/routes/ui/player.rs
@@ -13,9 +13,9 @@ use crate::{
};
use jellycommon::SourceTrackKind;
use rocket::{get, FromForm, State};
-use std::{path::PathBuf, sync::Arc};
+use std::{path::{PathBuf, Path}, sync::Arc};
-pub fn player_uri(path: &PathBuf) -> String {
+pub fn player_uri(path: &Path) -> String {
format!("/player/{}", path.to_str().unwrap())
}
@@ -36,7 +36,7 @@ pub fn r_player(
) -> MyResult<DynLayoutPage<'_>> {
let item = library.nested_path(&path)?.get_item()?;
if conf.a.is_none() && conf.v.is_none() && conf.s.is_none() {
- return player_conf(item.clone());
+ return player_conf(item);
}
let tracks = []