aboutsummaryrefslogtreecommitdiff
path: root/server/src/routes
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/routes')
-rw-r--r--server/src/routes/mod.rs3
-rw-r--r--server/src/routes/stream.rs3
-rw-r--r--server/src/routes/ui/account/mod.rs3
-rw-r--r--server/src/routes/ui/account/session/token.rs2
-rw-r--r--server/src/routes/ui/assets.rs7
-rw-r--r--server/src/routes/ui/home.rs2
-rw-r--r--server/src/routes/ui/layout.rs3
-rw-r--r--server/src/routes/ui/mod.rs1
-rw-r--r--server/src/routes/ui/node.rs6
-rw-r--r--server/src/routes/ui/player.rs2
10 files changed, 19 insertions, 13 deletions
diff --git a/server/src/routes/mod.rs b/server/src/routes/mod.rs
index 38d0390..cdb7424 100644
--- a/server/src/routes/mod.rs
+++ b/server/src/routes/mod.rs
@@ -3,9 +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, CONF};
+use crate::{database::Database, federation::Federation, routes::ui::error::MyResult};
use api::{r_api_account_login, r_api_root, r_api_version};
use base64::Engine;
+use jellybase::CONF;
use jellyremuxer::RemuxerContext;
use log::warn;
use rand::random;
diff --git a/server/src/routes/stream.rs b/server/src/routes/stream.rs
index ee7880c..7e26500 100644
--- a/server/src/routes/stream.rs
+++ b/server/src/routes/stream.rs
@@ -4,8 +4,9 @@
Copyright (C) 2023 metamuffin <metamuffin.org>
*/
use super::ui::{account::session::Session, error::MyError};
-use crate::{database::Database, federation::Federation, CONF};
+use crate::{database::Database, federation::Federation};
use anyhow::{anyhow, Result};
+use jellybase::CONF;
use jellycommon::MediaSource;
use jellyremuxer::RemuxerContext;
use log::{debug, info, warn};
diff --git a/server/src/routes/ui/account/mod.rs b/server/src/routes/ui/account/mod.rs
index 6bdf65a..b7ba332 100644
--- a/server/src/routes/ui/account/mod.rs
+++ b/server/src/routes/ui/account/mod.rs
@@ -10,11 +10,12 @@ use super::{error::MyError, layout::LayoutPage};
use crate::{
database::{Database, User},
routes::ui::{error::MyResult, home::rocket_uri_macro_r_home, layout::DynLayoutPage},
- CONF, uri,
+ uri,
};
use anyhow::anyhow;
use argon2::{password_hash::Salt, Argon2, PasswordHasher};
use chrono::Duration;
+use jellybase::CONF;
use rocket::{
form::{Contextual, Form},
get,
diff --git a/server/src/routes/ui/account/session/token.rs b/server/src/routes/ui/account/session/token.rs
index c02eff7..e5e4baf 100644
--- a/server/src/routes/ui/account/session/token.rs
+++ b/server/src/routes/ui/account/session/token.rs
@@ -4,7 +4,6 @@
Copyright (C) 2023 metamuffin <metamuffin.org>
*/
use super::SessionData;
-use crate::CONF;
use aes_gcm_siv::{
aead::{generic_array::GenericArray, Aead},
KeyInit,
@@ -12,6 +11,7 @@ use aes_gcm_siv::{
use anyhow::anyhow;
use base64::Engine;
use chrono::{Duration, Utc};
+use jellybase::CONF;
use log::warn;
use std::sync::LazyLock;
diff --git a/server/src/routes/ui/assets.rs b/server/src/routes/ui/assets.rs
index c00749f..8a14133 100644
--- a/server/src/routes/ui/assets.rs
+++ b/server/src/routes/ui/assets.rs
@@ -6,9 +6,9 @@
use crate::{
database::Database,
routes::ui::{account::session::Session, error::MyError, CacheControlFile},
- CONF,
};
use anyhow::anyhow;
+use jellybase::CONF;
use jellycommon::AssetLocation;
use log::info;
use rocket::{get, http::ContentType, FromFormField, State, UriDisplayQuery};
@@ -23,12 +23,13 @@ pub enum AssetRole {
Backdrop,
}
-#[get("/n/<id>/asset?<role>")]
+#[get("/n/<id>/asset?<role>&<width>")]
pub async fn r_item_assets(
_sess: Session,
+ db: &State<Database>,
id: String,
role: AssetRole,
- db: &State<Database>,
+ width: Option<u32>,
) -> Result<(ContentType, CacheControlFile), MyError> {
let node = db.node.get(&id)?.ok_or(anyhow!("node does not exist"))?;
let mut asset = match role {
diff --git a/server/src/routes/ui/home.rs b/server/src/routes/ui/home.rs
index c4defd0..c544336 100644
--- a/server/src/routes/ui/home.rs
+++ b/server/src/routes/ui/home.rs
@@ -7,8 +7,8 @@ use super::{account::session::Session, layout::LayoutPage};
use crate::{
database::Database,
routes::ui::{error::MyResult, layout::DynLayoutPage},
- CONF,
};
+use jellybase::CONF;
use rocket::{get, State};
use tokio::fs::read_to_string;
diff --git a/server/src/routes/ui/layout.rs b/server/src/routes/ui/layout.rs
index 0e0a429..fdda3e4 100644
--- a/server/src/routes/ui/layout.rs
+++ b/server/src/routes/ui/layout.rs
@@ -14,9 +14,10 @@ use crate::{
browser::rocket_uri_macro_r_all_items,
node::rocket_uri_macro_r_library_node,
},
- uri, CONF,
+ uri,
};
use async_std::task::block_on;
+use jellybase::CONF;
use markup::{DynRender, Render};
use rocket::{
http::ContentType,
diff --git a/server/src/routes/ui/mod.rs b/server/src/routes/ui/mod.rs
index 7acc02a..d561627 100644
--- a/server/src/routes/ui/mod.rs
+++ b/server/src/routes/ui/mod.rs
@@ -82,6 +82,7 @@ impl<'r> Responder<'r, 'static> for CacheControlFile {
Response::build()
.status(Status::NotModified)
.header(Header::new("cache-control", "private"))
+ .header(Header::new("etag", tag))
.ok()
} else {
debug!("file cache: transfer");
diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs
index 7b8548e..4574709 100644
--- a/server/src/routes/ui/node.rs
+++ b/server/src/routes/ui/node.rs
@@ -70,7 +70,7 @@ markup::define! {
div[class=cls] {
div.poster {
a[href=uri!(r_library_node(id))] {
- img[src=uri!(r_item_assets(id, AssetRole::Poster))];
+ img[src=uri!(r_item_assets(id, AssetRole::Poster, Some(1024)))];
}
@if matches!(node.kind, NodeKind::Collection | NodeKind::Channel) {
div.hoverdir { a[href=&uri!(r_library_node(id))] { "Open" } }
@@ -87,11 +87,11 @@ markup::define! {
}
NodePage<'a>(id: &'a str, node: &'a NodePublic, children: &'a Vec<(String, NodePublic)>) {
@if !matches!(node.kind, NodeKind::Collection) {
- img.backdrop[src=uri!(r_item_assets(id, AssetRole::Backdrop))];
+ img.backdrop[src=uri!(r_item_assets(id, AssetRole::Backdrop, Some(2048)))];
}
div.page.node {
@if !matches!(node.kind, NodeKind::Collection) {
- div.bigposter { img[src=uri!(r_item_assets(id, AssetRole::Poster))]; }
+ div.bigposter { img[src=uri!(r_item_assets(id, AssetRole::Poster, Some(2048)))]; }
}
div.title {
h1 { @node.title }
diff --git a/server/src/routes/ui/player.rs b/server/src/routes/ui/player.rs
index 3bfb6a4..0e6962e 100644
--- a/server/src/routes/ui/player.rs
+++ b/server/src/routes/ui/player.rs
@@ -56,7 +56,7 @@ pub fn r_player(
class: Some("player"),
content: markup::new! {
@if tracks.is_empty() {
- img.backdrop[src=uri!(r_item_assets(&id, AssetRole::Backdrop)).to_string()];
+ img.backdrop[src=uri!(r_item_assets(&id, AssetRole::Backdrop, Some(2048))).to_string()];
} else {
video[src=uri!(r_stream(&id, &tracks, Some(true))), controls, preload="auto"]{}
}