aboutsummaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-07-31 20:48:41 +0200
committermetamuffin <metamuffin@disroot.org>2023-07-31 20:48:41 +0200
commit8e8166c85a3d1f20dfeaf18f29d08d74c554fcbc (patch)
tree278a3151639cceb54a53bea7fcdb8bac5d35a9fa /server/src
parent30306bcf5a312c8749b1b66ef0a426cf7aaee989 (diff)
downloadjellything-8e8166c85a3d1f20dfeaf18f29d08d74c554fcbc.tar
jellything-8e8166c85a3d1f20dfeaf18f29d08d74c554fcbc.tar.bz2
jellything-8e8166c85a3d1f20dfeaf18f29d08d74c554fcbc.tar.zst
other cleanup
Diffstat (limited to 'server/src')
-rw-r--r--server/src/import.rs7
-rw-r--r--server/src/routes/ui/assets.rs16
-rw-r--r--server/src/routes/ui/layout.rs16
-rw-r--r--server/src/routes/ui/node.rs4
4 files changed, 26 insertions, 17 deletions
diff --git a/server/src/import.rs b/server/src/import.rs
index 06d32c3..72fb399 100644
--- a/server/src/import.rs
+++ b/server/src/import.rs
@@ -37,11 +37,13 @@ pub fn import_path(path: PathBuf, db: &Database) -> anyhow::Result<Vec<String>>
.flatten()
.collect();
if mpath.exists() {
- let data: Node =
+ let mut data: Node =
serde_json::from_reader(File::open(mpath).context("metadata missing")?)?;
let identifier = path.file_name().unwrap().to_str().unwrap().to_string();
-
+
+ data.public.children = children;
+ info!("insert {identifier}");
db.node.insert(&identifier, &data)?;
Ok(vec![identifier])
@@ -60,6 +62,7 @@ pub fn import_path(path: PathBuf, db: &Database) -> anyhow::Result<Vec<String>>
.strip_suffix(".jelly")
.unwrap()
.to_string();
+ info!("insert {identifier}");
db.node.insert(&identifier, &data)?;
Ok(vec![identifier])
} else {
diff --git a/server/src/routes/ui/assets.rs b/server/src/routes/ui/assets.rs
index 27d322a..e9c7d24 100644
--- a/server/src/routes/ui/assets.rs
+++ b/server/src/routes/ui/assets.rs
@@ -28,13 +28,15 @@ pub async fn r_item_assets(
db: &State<Database>,
) -> Result<(ContentType, CacheControlFile), MyError> {
let node = db.node.get(&id)?.ok_or(anyhow!("node does not exist"))?;
- let path = CONF.library_path.join(
- match role {
- AssetRole::Backdrop => node.private.backdrop,
- AssetRole::Poster => node.private.poster,
- }
- .unwrap_or_else(|| PathBuf::from_str("fallback.jpeg").unwrap()),
- );
+ let path = match role {
+ AssetRole::Backdrop => node.private.backdrop,
+ AssetRole::Poster => node.private.poster,
+ }
+ .map(|e| CONF.library_path.join(e))
+ .unwrap_or_else(|| {
+ CONF.asset_path
+ .join(PathBuf::from_str("fallback.jpeg").unwrap())
+ });
info!("loading asset from {path:?}");
let ext = path.extension().unwrap().to_str().unwrap();
Ok((
diff --git a/server/src/routes/ui/layout.rs b/server/src/routes/ui/layout.rs
index da795aa..7844e22 100644
--- a/server/src/routes/ui/layout.rs
+++ b/server/src/routes/ui/layout.rs
@@ -4,10 +4,14 @@
Copyright (C) 2023 metamuffin <metamuffin.org>
*/
use crate::{
- routes::ui::account::{
- admin::rocket_uri_macro_r_account_admin_dashboard, rocket_uri_macro_r_account_login,
- rocket_uri_macro_r_account_logout, rocket_uri_macro_r_account_register, session::Session,
- settings::rocket_uri_macro_r_account_settings,
+ routes::ui::{
+ account::{
+ admin::rocket_uri_macro_r_account_admin_dashboard, rocket_uri_macro_r_account_login,
+ rocket_uri_macro_r_account_logout, rocket_uri_macro_r_account_register,
+ session::Session, settings::rocket_uri_macro_r_account_settings,
+ },
+ browser::rocket_uri_macro_r_all_items,
+ node::rocket_uri_macro_r_library_node,
},
uri, CONF,
};
@@ -34,8 +38,8 @@ markup::define! {
@if *show_back { a[onclick="history.back()", href="#"] { "<- Back" } } " "
h1 { a[href="/"] { @CONF.brand } } " "
@if let Some(_) = session {
- a[href="/library"] { "My Library" } " "
- a[href="/items"] { "All Items" } " "
+ a[href=uri!(r_library_node("library"))] { "My Library" } " "
+ a[href=uri!(r_all_items())] { "All Items" } " "
}
div.account {
@if let Some(session) = session {
diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs
index 0ae0d9e..f77b157 100644
--- a/server/src/routes/ui/node.rs
+++ b/server/src/routes/ui/node.rs
@@ -56,7 +56,7 @@ pub async fn r_library_node(
markup::define! {
NodePage<'a>(id: &'a str, node: &'a Node, children: &'a Vec<(String,Node)>) {
@match node.public.kind {
- NodeKind::Collection | NodeKind::Show | NodeKind::Season => { @DirectoryPage { node, id, children } }
+ NodeKind::Collection | NodeKind::Show | NodeKind::Season => { @DirectoryPage { node, _id: id, children } }
NodeKind::Series => { @SeriesPage { node, children, id } }
NodeKind::Movie | NodeKind::Episode => { @ItemPage { node, id } }
}
@@ -69,7 +69,7 @@ markup::define! {
title: &node.public.title
}
}
- DirectoryPage<'a>(id: &'a str, node: &'a Node, children: &'a Vec<(String,Node)>) {
+ DirectoryPage<'a>(_id: &'a str, node: &'a Node, children: &'a Vec<(String,Node)>) {
div.page.dir {
h1 { @node.public.title }
// @if let Some(parent) = node.lib_path.parent() {