From 66c1c10d39e6ecb212ec4709888493693339c07d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Pej=C5=A1a?= Date: Sun, 24 Mar 2019 10:25:48 +0100 Subject: Implement file upload. --- src/listing.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/listing.rs') diff --git a/src/listing.rs b/src/listing.rs index c4daf88..0173176 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -265,6 +265,7 @@ pub fn directory_listing( page_parent, sort_method, sort_order, + &base.to_string_lossy(), ) .into_string(), )) -- cgit v1.2.3 From d14e17d94964291fda976423c1fe1a772d5af60b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Pej=C5=A1a?= Date: Wed, 27 Mar 2019 09:44:29 +0100 Subject: Add CLI arguments for file uploading. --- src/listing.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/listing.rs') diff --git a/src/listing.rs b/src/listing.rs index 0173176..5fde879 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -130,6 +130,7 @@ pub fn directory_listing( dir: &fs::Directory, req: &HttpRequest, skip_symlinks: bool, + file_upload: bool, random_route: Option, ) -> Result { let title = format!("Index of {}", req.path()); @@ -265,6 +266,7 @@ pub fn directory_listing( page_parent, sort_method, sort_order, + file_upload, &base.to_string_lossy(), ) .into_string(), -- cgit v1.2.3 From 84b5852aad17961dfa2cb6ea3351b9fa3244fe6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Pej=C5=A1a?= Date: Thu, 28 Mar 2019 11:29:56 +0100 Subject: Fix file upload when used with random route. --- src/listing.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/listing.rs') diff --git a/src/listing.rs b/src/listing.rs index 5fde879..4a0927b 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -132,12 +132,17 @@ pub fn directory_listing( skip_symlinks: bool, file_upload: bool, random_route: Option, + upload_route: String, ) -> Result { let title = format!("Index of {}", req.path()); let base = Path::new(req.path()); let random_route = format!("/{}", random_route.unwrap_or_default()); let is_root = base.parent().is_none() || req.path() == random_route; let page_parent = base.parent().map(|p| p.display().to_string()); + let current_dir = match base.strip_prefix(random_route) { + Ok(c_d) => Path::new("/").join(c_d), + Err(_) => base.to_path_buf(), + }; let (sort_method, sort_order, download) = if let Ok(query) = Query::::extract(req) { @@ -267,7 +272,8 @@ pub fn directory_listing( sort_method, sort_order, file_upload, - &base.to_string_lossy(), + &upload_route, + ¤t_dir.display().to_string(), ) .into_string(), )) -- cgit v1.2.3