aboutsummaryrefslogtreecommitdiff
path: root/server/src/routes/ui
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/routes/ui')
-rw-r--r--server/src/routes/ui/account/settings.rs1
-rw-r--r--server/src/routes/ui/admin/log.rs28
-rw-r--r--server/src/routes/ui/admin/mod.rs12
-rw-r--r--server/src/routes/ui/admin/user.rs4
-rw-r--r--server/src/routes/ui/assets.rs12
-rw-r--r--server/src/routes/ui/error.rs2
-rw-r--r--server/src/routes/ui/home.rs2
-rw-r--r--server/src/routes/ui/layout.rs4
-rw-r--r--server/src/routes/ui/node.rs21
-rw-r--r--server/src/routes/ui/player.rs7
-rw-r--r--server/src/routes/ui/search.rs4
-rw-r--r--server/src/routes/ui/sort.rs2
12 files changed, 42 insertions, 57 deletions
diff --git a/server/src/routes/ui/account/settings.rs b/server/src/routes/ui/account/settings.rs
index 492e8ca..7d54d75 100644
--- a/server/src/routes/ui/account/settings.rs
+++ b/server/src/routes/ui/account/settings.rs
@@ -98,7 +98,6 @@ fn settings_page(session: Session, flash: Option<MyResult<String>>) -> DynLayout
p { "The secret can be found in " code{"$XDG_CONFIG_HOME/jellynative_secret"} " or by clicking " a.button[href="jellynative://show-secret-v1"] { "Show Secret" } "." }
}
},
- ..Default::default()
}
}
diff --git a/server/src/routes/ui/admin/log.rs b/server/src/routes/ui/admin/log.rs
index 5b81a52..884ad7a 100644
--- a/server/src/routes/ui/admin/log.rs
+++ b/server/src/routes/ui/admin/log.rs
@@ -22,7 +22,7 @@ use std::{
const MAX_LOG_LEN: usize = 4096;
-static LOGGER: LazyLock<Log> = LazyLock::new(Log::new);
+static LOGGER: LazyLock<Log> = LazyLock::new(Log::default);
pub fn enable_logging() {
log::set_logger(&*LOGGER).unwrap();
@@ -63,9 +63,8 @@ pub fn r_admin_log<'a>(_session: AdminSession, warnonly: bool) -> MyResult<DynLa
..Default::default()
})
}
-
-impl Log {
- pub fn new() -> Self {
+impl Default for Log {
+ fn default() -> Self {
Self {
inner: env_logger::builder()
.filter_level(log::LevelFilter::Warn)
@@ -74,6 +73,8 @@ impl Log {
log: Default::default(),
}
}
+}
+impl Log {
fn should_log(&self, metadata: &log::Metadata) -> bool {
let level = metadata.level();
level
@@ -152,18 +153,11 @@ fn format_level(level: Level) -> impl markup::Render {
markup::new! { span[style=format!("color:{c}")] {@s} }
}
+#[derive(Default)]
pub struct HtmlOut {
s: String,
color: bool,
}
-impl Default for HtmlOut {
- fn default() -> Self {
- Self {
- color: false,
- s: String::new(),
- }
- }
-}
impl HtmlOut {
pub fn set_color(&mut self, [r, g, b]: [u8; 3]) {
self.reset_color();
@@ -184,16 +178,12 @@ impl vte::Perform for HtmlOut {
x => write!(self.s, "&#{};", x as u32).unwrap(),
}
}
-
fn execute(&mut self, _byte: u8) {}
fn hook(&mut self, _params: &vte::Params, _i: &[u8], _ignore: bool, _a: char) {}
fn put(&mut self, _byte: u8) {}
fn unhook(&mut self) {}
fn osc_dispatch(&mut self, _params: &[&[u8]], _bell_terminated: bool) {}
- fn esc_dispatch(&mut self, _intermediates: &[u8], _ignore: bool, _byte: u8) {
- // self.s += &format!(" {:?} ", (_intermediates, _byte))
- }
-
+ fn esc_dispatch(&mut self, _intermediates: &[u8], _ignore: bool, _byte: u8) {}
fn csi_dispatch(
&mut self,
params: &vte::Params,
@@ -202,9 +192,9 @@ impl vte::Perform for HtmlOut {
action: char,
) {
let mut k = params.iter();
- // self.s += &format!(" {:?} ", (params, action));
+ #[allow(clippy::single_match)]
match action {
- 'm' => match k.next().unwrap_or(&[0]).get(0).unwrap_or(&0) {
+ 'm' => match k.next().unwrap_or(&[0]).first().unwrap_or(&0) {
c @ (30..=37 | 40..=47) => {
let c = if *c >= 40 { *c - 10 } else { *c };
self.set_color(match c {
diff --git a/server/src/routes/ui/admin/mod.rs b/server/src/routes/ui/admin/mod.rs
index 540ac72..25f1f42 100644
--- a/server/src/routes/ui/admin/mod.rs
+++ b/server/src/routes/ui/admin/mod.rs
@@ -134,7 +134,7 @@ pub async fn r_admin_invite(
database: &State<DataAcid>,
) -> MyResult<DynLayoutPage<'static>> {
let i = format!("{}", rand::thread_rng().gen::<u128>());
- T_INVITE.insert(&database, &*i, ())?;
+ T_INVITE.insert(database, &*i, ())?;
admin_dashboard(database, Some(Ok(format!("Invite: {}", i)))).await
}
@@ -152,7 +152,7 @@ pub async fn r_admin_remove_invite(
) -> MyResult<DynLayoutPage<'static>> {
drop(session);
T_INVITE
- .remove(&database, form.invite.as_str())?
+ .remove(database, form.invite.as_str())?
.ok_or(anyhow!("invite did not exist"))?;
admin_dashboard(database, Some(Ok("Invite invalidated".into()))).await
@@ -166,9 +166,9 @@ pub async fn r_admin_import(
) -> MyResult<DynLayoutPage<'static>> {
drop(session);
let t = Instant::now();
- let r = import(&database, &federation).await;
+ let r = import(database, federation).await;
admin_dashboard(
- &database,
+ database,
Some(
r.map_err(|e| e.into())
.map(|_| format!("Import successful; took {:?}", t.elapsed())),
@@ -187,7 +187,7 @@ pub async fn r_admin_delete_cache(
let r = tokio::fs::remove_dir_all(&CONF.cache_path).await;
tokio::fs::create_dir(&CONF.cache_path).await?;
admin_dashboard(
- &database,
+ database,
Some(
r.map_err(|e| e.into())
.map(|_| format!("Cache deleted; took {:?}", t.elapsed())),
@@ -233,7 +233,7 @@ pub async fn r_admin_transcode_posters(
drop(_permit);
admin_dashboard(
- &database,
+ database,
Some(Ok(format!(
"All posters pre-transcoded; took {:?}",
t.elapsed()
diff --git a/server/src/routes/ui/admin/user.rs b/server/src/routes/ui/admin/user.rs
index 4d77191..26c1837 100644
--- a/server/src/routes/ui/admin/user.rs
+++ b/server/src/routes/ui/admin/user.rs
@@ -76,7 +76,7 @@ fn manage_single_user<'a>(
name: String,
) -> MyResult<DynLayoutPage<'a>> {
let user = T_USER
- .get(&database, &*name)?
+ .get(database, &*name)?
.ok_or(anyhow!("user does not exist"))?;
let flash = flash.map(|f| f.map_err(|e| format!("{e:?}")));
@@ -193,7 +193,7 @@ pub fn r_admin_remove_user(
) -> MyResult<DynLayoutPage<'static>> {
drop(session);
T_USER
- .remove(&database, form.name.as_str())?
+ .remove(database, form.name.as_str())?
.ok_or(anyhow!("user did not exist"))?;
user_management(database, Some(Ok("User removed".into())))
}
diff --git a/server/src/routes/ui/assets.rs b/server/src/routes/ui/assets.rs
index c278a31..ad31240 100644
--- a/server/src/routes/ui/assets.rs
+++ b/server/src/routes/ui/assets.rs
@@ -75,7 +75,7 @@ pub async fn r_item_assets(
width: Option<usize>,
) -> MyResult<Redirect> {
let node = T_NODE
- .get(&db, id)?
+ .get(db, id)?
.only_if_permitted(&session.user.permissions)
.ok_or(anyhow!("node does not exist"))?;
@@ -83,10 +83,10 @@ pub async fn r_item_assets(
AssetRole::Backdrop => node.public.backdrop,
AssetRole::Poster => node.public.poster,
};
- if let None = asset {
+ if asset.is_none() {
if let Some(parent) = &node.public.path.last() {
let parent = T_NODE
- .get(&db, parent.as_str())?
+ .get(db, parent.as_str())?
.ok_or(anyhow!("node does not exist"))?;
asset = match role {
AssetRole::Backdrop => parent.public.backdrop,
@@ -113,7 +113,7 @@ pub async fn r_person_asset(
width: Option<usize>,
) -> MyResult<Redirect> {
T_NODE
- .get(&db, id)?
+ .get(db, id)?
.only_if_permitted(&session.user.permissions)
.ok_or(anyhow!("node does not exist"))?;
@@ -129,7 +129,7 @@ pub async fn r_person_asset(
.person
.headshot
.to_owned()
- .unwrap_or(AssetInner::Assets(format!("fallback-Person.avif").into()).ser());
+ .unwrap_or(AssetInner::Assets("fallback-Person.avif".into()).ser());
Ok(Redirect::temporary(rocket::uri!(r_asset(asset.0, width))))
}
@@ -146,7 +146,7 @@ pub async fn r_node_thumbnail(
width: Option<usize>,
) -> MyResult<Redirect> {
let node = T_NODE
- .get(&db, id)?
+ .get(db, id)?
.only_if_permitted(&session.user.permissions)
.ok_or(anyhow!("node does not exist"))?;
diff --git a/server/src/routes/ui/error.rs b/server/src/routes/ui/error.rs
index b8a132d..ba1dc88 100644
--- a/server/src/routes/ui/error.rs
+++ b/server/src/routes/ui/error.rs
@@ -41,7 +41,7 @@ pub fn r_catch<'a>(status: Status, _request: &Request) -> DynLayoutPage<'a> {
}
#[catch(default)]
-pub fn r_api_catch<'a>(status: Status, _request: &Request) -> Value {
+pub fn r_api_catch(status: Status, _request: &Request) -> Value {
json!({ "error": format!("{status}") })
}
diff --git a/server/src/routes/ui/home.rs b/server/src/routes/ui/home.rs
index 2fa9212..0a1089a 100644
--- a/server/src/routes/ui/home.rs
+++ b/server/src/routes/ui/home.rs
@@ -50,7 +50,7 @@ pub fn r_home(sess: Session, db: &State<DataAcid>) -> MyResult<DynLayoutPage> {
.collect::<Vec<_>>();
let toplevel = T_NODE
- .get(&db, "library")?
+ .get(db, "library")?
.context("root node missing")?
.public
.children
diff --git a/server/src/routes/ui/layout.rs b/server/src/routes/ui/layout.rs
index 1696ac4..9f9038c 100644
--- a/server/src/routes/ui/layout.rs
+++ b/server/src/routes/ui/layout.rs
@@ -74,7 +74,7 @@ markup::define! {
@if let Some(flash) = &flash {
@match flash {
Ok(mesg) => { section.message { p.success { @mesg } } }
- Err(err) => { section.message { p.error { @format!("{err}") } } }
+ Err(err) => { section.message { p.error { @err } } }
}
}
}
@@ -110,7 +110,7 @@ impl<'r, Main: Render> Responder<'r, 'static> for LayoutPage<Main> {
title: self.title,
class: &format!(
"{} theme-{:?}",
- self.class.as_deref().unwrap_or(""),
+ self.class.unwrap_or(""),
session
.as_ref()
.map(|s| s.user.theme)
diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs
index bd839fb..d99ddb7 100644
--- a/server/src/routes/ui/node.rs
+++ b/server/src/routes/ui/node.rs
@@ -47,7 +47,7 @@ pub async fn r_library_node_ext<'a>(
db: &'a State<DataAcid>,
) -> MyResult<Json<ExtendedNode>> {
T_NODE
- .get(&db, id)?
+ .get(db, id)?
.only_if_permitted(&session.user.permissions)
.ok_or(anyhow!("node does not exist"))?;
@@ -63,14 +63,14 @@ pub async fn r_library_node_filter<'a>(
filter: NodeFilterSort,
) -> MyResult<Either<DynLayoutPage<'a>, Json<NodePublic>>> {
let node = T_NODE
- .get(&db, id)?
+ .get(db, id)?
.only_if_permitted(&session.user.permissions)
.ok_or(anyhow!("node does not exist"))?
.public;
let node_ext = T_NODE_EXTENDED.get(db, id)?.unwrap_or_default();
let udata = T_USER_NODE
- .get(&db, &(session.user.name.as_str(), id))?
+ .get(db, &(session.user.name.as_str(), id))?
.unwrap_or_default();
if *aj {
@@ -80,7 +80,7 @@ pub async fn r_library_node_filter<'a>(
let mut children = node
.children
.iter()
- .map(|c| Ok(db.get_node_with_userdata(c, &session)?))
+ .map(|c| db.get_node_with_userdata(c, &session))
.collect::<anyhow::Result<Vec<_>>>()?
.into_iter()
.collect();
@@ -113,7 +113,7 @@ pub async fn r_library_node_filter<'a>(
Ok(Either::Left(LayoutPage {
title: node.title.clone().unwrap_or_default(),
content: markup::new! {
- @NodePage { node: &node, id: &id, udata: &udata, children: &children, path: &path, filter: &filter, node_ext: &node_ext }
+ @NodePage { node: &node, id, udata: &udata, children: &children, path: &path, filter: &filter, node_ext: &node_ext }
},
..Default::default()
}))
@@ -220,10 +220,10 @@ markup::define! {
}
.title {
@pe.person.name br;
- @if let Some(c) = pe.characters.get(0) {
+ @if let Some(c) = pe.characters.first() {
.subtitle { @c }
}
- @if let Some(c) = pe.jobs.get(0) {
+ @if let Some(c) = pe.jobs.first() {
.subtitle { @c }
}
}
@@ -359,11 +359,8 @@ impl MediaInfoExt for MediaInfo {
fn resolution_name(&self) -> &'static str {
let mut maxdim = 0;
for t in &self.tracks {
- match &t.kind {
- SourceTrackKind::Video { width, height, .. } => {
- maxdim = maxdim.max(*width.max(height))
- }
- _ => (),
+ if let SourceTrackKind::Video { width, height, .. } = &t.kind {
+ maxdim = maxdim.max(*width.max(height))
}
}
diff --git a/server/src/routes/ui/player.rs b/server/src/routes/ui/player.rs
index 69445ed..55e1303 100644
--- a/server/src/routes/ui/player.rs
+++ b/server/src/routes/ui/player.rs
@@ -108,9 +108,9 @@ pub fn r_player<'a>(
let spec = StreamSpec {
track: None
.into_iter()
- .chain(conf.v.into_iter())
- .chain(conf.a.into_iter())
- .chain(conf.s.into_iter())
+ .chain(conf.v)
+ .chain(conf.a)
+ .chain(conf.s)
.collect::<Vec<_>>(),
format: StreamFormat::Matroska,
webm: Some(true),
@@ -131,7 +131,6 @@ pub fn r_player<'a>(
}
@conf
},
- ..Default::default()
}))
}
diff --git a/server/src/routes/ui/search.rs b/server/src/routes/ui/search.rs
index 4ea5716..5ca4b51 100644
--- a/server/src/routes/ui/search.rs
+++ b/server/src/routes/ui/search.rs
@@ -49,12 +49,12 @@ pub async fn r_search<'a>(
let id = doc.get_first(db.node_index.id).unwrap().as_str().unwrap();
let node = T_NODE
- .get(&db, id)?
+ .get(db, id)?
.only_if_permitted(&session.user.permissions)
.ok_or(anyhow!("node does not exist"))?
.public;
let udata = T_USER_NODE
- .get(&db, &(session.user.name.as_str(), id))?
+ .get(db, &(session.user.name.as_str(), id))?
.unwrap_or_default();
results.push((id.to_owned(), node, udata));
diff --git a/server/src/routes/ui/sort.rs b/server/src/routes/ui/sort.rs
index a779b15..88f262b 100644
--- a/server/src/routes/ui/sort.rs
+++ b/server/src/routes/ui/sort.rs
@@ -220,7 +220,7 @@ markup::define! {
.category {
h3 { @cname }
@for (value, label) in *cat {
- label { input[type="checkbox", name="filter_kind", value=value, checked=f.filter_kind.as_ref().map(|k|k.contains(&value)).unwrap_or(true)]; @label } br;
+ label { input[type="checkbox", name="filter_kind", value=value, checked=f.filter_kind.as_ref().map(|k|k.contains(value)).unwrap_or(true)]; @label } br;
}
}
}