aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/src/internal.rs2
-rw-r--r--ebml_derive/src/lib.rs2
-rw-r--r--kv/src/rocksdb.rs2
-rw-r--r--server/src/request_info.rs8
-rw-r--r--server/src/responders/cache.rs2
-rw-r--r--server/src/responders/cors.rs2
-rw-r--r--server/src/ui/assets.rs29
-rw-r--r--server/src/ui/mod.rs2
-rw-r--r--tool/src/bin/generate_completions.rs2
-rw-r--r--ui/client-scripts/src/pagination.ts32
-rw-r--r--ui/src/components/mod.rs4
11 files changed, 34 insertions, 53 deletions
diff --git a/common/src/internal.rs b/common/src/internal.rs
index 844468d..3f2c622 100644
--- a/common/src/internal.rs
+++ b/common/src/internal.rs
@@ -40,4 +40,4 @@ impl Display for LogLevel {
LogLevel::Error => "error",
})
}
-} \ No newline at end of file
+}
diff --git a/ebml_derive/src/lib.rs b/ebml_derive/src/lib.rs
index c020005..8c1e147 100644
--- a/ebml_derive/src/lib.rs
+++ b/ebml_derive/src/lib.rs
@@ -3,7 +3,7 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2026 metamuffin <metamuffin.org>
*/
-use proc_macro::{token_stream, Delimiter, Span, TokenStream, TokenTree};
+use proc_macro::{Delimiter, Span, TokenStream, TokenTree, token_stream};
use quote::quote;
use syn::{Fields, FieldsUnnamed, Ident, Variant};
diff --git a/kv/src/rocksdb.rs b/kv/src/rocksdb.rs
index c78dd96..683e399 100644
--- a/kv/src/rocksdb.rs
+++ b/kv/src/rocksdb.rs
@@ -29,7 +29,7 @@ impl Store for OptimisticTransactionDB {
}
impl Transaction for rocksdb::Transaction<'_, OptimisticTransactionDB> {
- fn set(&mut self, key: &[u8], value: &[u8]) -> Result<()> {
+ fn set(&mut self, key: &[u8], value: &[u8]) -> Result<()> {
Ok(self.put(key, value)?)
}
diff --git a/server/src/request_info.rs b/server/src/request_info.rs
index 0adfe96..55dde0d 100644
--- a/server/src/request_info.rs
+++ b/server/src/request_info.rs
@@ -26,6 +26,7 @@ pub struct RequestInfo<'a> {
pub debug: &'a str,
pub user: Option<Box<User>>,
pub state: Arc<State>,
+ pub no_scaffold: bool,
pub flash: Option<FlashMessage<'a>>,
}
@@ -48,6 +49,7 @@ impl<'a> RequestInfo<'a> {
accept: Accept::from_request_ut(request),
user: user_from_request(state, request)?,
state: state.clone(),
+ no_scaffold: request.query_value::<bool>("no_scaff").is_some(),
debug: request
.query_value::<&str>("debug")
.transpose()
@@ -78,7 +80,11 @@ impl<'a> RequestInfo<'a> {
}
}
pub fn respond_ui(&self, page: &dyn Page) -> RawHtml<String> {
- RawHtml(Scaffold { page }.to_string())
+ if self.no_scaffold {
+ RawHtml(page.render().to_string())
+ } else {
+ RawHtml(Scaffold { page }.to_string())
+ }
}
}
diff --git a/server/src/responders/cache.rs b/server/src/responders/cache.rs
index a943de8..078de20 100644
--- a/server/src/responders/cache.rs
+++ b/server/src/responders/cache.rs
@@ -6,9 +6,9 @@
use log::debug;
use rocket::{
+ Request, Response,
http::{Header, Status},
response::{self, Responder},
- Request, Response,
};
use std::{
hash::{DefaultHasher, Hash, Hasher},
diff --git a/server/src/responders/cors.rs b/server/src/responders/cors.rs
index 875b1e5..46a5987 100644
--- a/server/src/responders/cors.rs
+++ b/server/src/responders/cors.rs
@@ -5,9 +5,9 @@
*/
use rocket::{
+ Request,
http::Header,
response::{self, Responder},
- Request,
};
pub struct Cors<T>(pub T);
diff --git a/server/src/ui/assets.rs b/server/src/ui/assets.rs
index 5903b83..089f293 100644
--- a/server/src/ui/assets.rs
+++ b/server/src/ui/assets.rs
@@ -51,32 +51,3 @@ pub async fn r_image_fallback_person(
})?;
Ok(Redirect::found(u_image(&path, size.unwrap_or(2048))))
}
-
-// #[get("/n/<id>/image/<slot>?<size>")]
-// pub async fn r_item_poster(
-// session: A<Session>,
-// id: A<NodeID>,
-// slot: &str,
-// size: Option<usize>,
-// ) -> MyResult<Redirect> {
-// let slot = PictureSlot::from_str(slot).map_err(|_| anyhow!("slot invalid"))?;
-// let node = get_node(&session.0, id.0, false, false, NodeFilterSort::default())?;
-// let picture = node
-// .node
-// .pictures
-// .get(&slot)
-// .cloned()
-// .ok_or(anyhow!("no pic todo"))?;
-// Ok(Redirect::permanent(rocket::uri!(r_image(picture, size))))
-// }
-
-// #[get("/n/<id>/thumbnail?<t>&<size>")]
-// pub async fn r_node_thumbnail(
-// session: A<Session>,
-// id: A<NodeID>,
-// t: f64,
-// size: Option<usize>,
-// ) -> MyResult<Redirect> {
-// let picture = get_node_thumbnail(&session.0, id.0, t).await?;
-// Ok(Redirect::permanent(rocket::uri!(r_image(picture, size))))
-// }
diff --git a/server/src/ui/mod.rs b/server/src/ui/mod.rs
index 6cb3cd2..2dab076 100644
--- a/server/src/ui/mod.rs
+++ b/server/src/ui/mod.rs
@@ -15,10 +15,10 @@ pub mod admin;
pub mod assets;
pub mod error;
pub mod home;
+pub mod items;
pub mod node;
pub mod player;
pub mod style;
-pub mod items;
#[get("/")]
pub async fn r_index(ri: RequestInfo<'_>) -> MyResult<Redirect> {
diff --git a/tool/src/bin/generate_completions.rs b/tool/src/bin/generate_completions.rs
index 556d613..dfa8378 100644
--- a/tool/src/bin/generate_completions.rs
+++ b/tool/src/bin/generate_completions.rs
@@ -4,7 +4,7 @@
Copyright (C) 2026 metamuffin <metamuffin.org>
*/
use clap::{CommandFactory, Parser, ValueEnum};
-use clap_complete::{generate_to, Shell};
+use clap_complete::{Shell, generate_to};
use jellytool::cli;
use std::{fs::create_dir_all, path::PathBuf};
diff --git a/ui/client-scripts/src/pagination.ts b/ui/client-scripts/src/pagination.ts
index 380b20e..62362c1 100644
--- a/ui/client-scripts/src/pagination.ts
+++ b/ui/client-scripts/src/pagination.ts
@@ -1,18 +1,22 @@
-globalThis.addEventListener("DOMContentLoaded", () => {
- const el = document.querySelector(".next_page") as HTMLElement
+function init_paging() {
+ const el = document.querySelector(".next_page") as HTMLAnchorElement
if (!el) return
- const cont = document.body.parentElement!
- console.log(cont);
-
- cont.addEventListener("scroll", () => {
- const end = cont.scrollTop + cont.clientHeight
- console.log(end, cont.scrollHeight);
-
- if (end + 1000 > el.scrollHeight) {
- el.textContent = "Loading more..."
- el.click()
+ document.body.onscroll = () => {
+ const end = document.body.clientHeight - document.body.parentElement!.scrollTop - document.body.parentElement!.clientHeight
+ if (end < 200) {
+ document.body.onscroll = () => { }
+ load_next(el)
}
+ }
+}
- })
-})
+async function load_next(el: HTMLAnchorElement) {
+ const res = await fetch(el.href + "&no_scaff")
+ if (!res.ok) throw "aaa"
+ const ext = await res.text()
+ el.remove()
+ document.getElementById("main")!.innerHTML += ext
+ init_paging()
+}
+globalThis.addEventListener("DOMContentLoaded", init_paging)
diff --git a/ui/src/components/mod.rs b/ui/src/components/mod.rs
index 6c4cc9d..3dd43a4 100644
--- a/ui/src/components/mod.rs
+++ b/ui/src/components/mod.rs
@@ -6,6 +6,8 @@
pub mod admin;
pub mod admin_log;
+pub mod home;
+pub mod items;
pub mod login;
pub mod message;
pub mod node_card;
@@ -13,5 +15,3 @@ pub mod node_page;
pub mod props;
pub mod stats;
pub mod user;
-pub mod items;
-pub mod home;