1
0

2 کامیت‌ها 29bd72e635 ... 6eab05c42c

نویسنده SHA1 پیام تاریخ
  biblius 6eab05c42c restructure to htmxpress 10 ماه پیش
  biblius 29bd72e635 restructure to htmxpress 10 ماه پیش
3فایلهای تغییر یافته به همراه34 افزوده شده و 5 حذف شده
  1. 1 1
      src/htmx.rs
  2. 3 4
      src/routes.rs
  3. 30 0
      test.html

+ 1 - 1
src/htmx.rs

@@ -299,7 +299,7 @@ pub struct SubFileHtmx {
     #[element("button")]
     #[attrs(class = "download-button")]
     #[hx(
-        "target" = "closest-div",
+        "target" = "closest div",
         "swap" = "innerHtml"
     )]
     #[hx_get("/download?file_id={}&full_path={}", file_id, path)]

+ 3 - 4
src/routes.rs

@@ -28,7 +28,6 @@ pub async fn get_directory(
         state.base_path.clone()
     } else {
         let path = urlencoding::decode(path)?;
-        let path = &path[1..];
         format!("{}/{path}", state.base_path)
     };
 
@@ -45,7 +44,7 @@ pub async fn get_directory(
                     let Some((_, path)) = dir.path.split_once(&state.base_path) else {
                         return acc;
                     };
-                    dir.path = path.to_string();
+                    dir.path = path[1..].to_string();
                     let dir: DirHtmx = dir.into();
                     let _ = write!(acc, "{}", dir.to_htmx());
                 }
@@ -53,7 +52,7 @@ pub async fn get_directory(
                     let Some((_, path)) = file.path.split_once(&state.base_path) else {
                         return acc;
                     };
-                    file.path = path.to_string();
+                    file.path = path[1..].to_string();
                     let file = FileHtmx::new(i, file);
                     let _ = write!(acc, "{}", file.to_htmx());
                 }
@@ -85,7 +84,7 @@ pub async fn search_subtitles(
     state: axum::extract::State<State>,
     query: axum::extract::Query<SubtitleSearch>,
 ) -> Result<String, NtitledError> {
-    let path = format!("{}{}", state.base_path, &query.path);
+    let path = format!("{}/{}", state.base_path, &query.path);
 
     info!("Computing hash for {}", &path);
 

+ 30 - 0
test.html

@@ -0,0 +1,30 @@
+<div class="sub-container">
+    <div class="sub-container-title">
+        <h3>The Venture Bros. - Dia de Los Dangerous! S1E1 🎯</h3>
+    </div>
+    <div class="sub-container-info">
+        <p class="info">Language: en</p>
+        <p class="info">Downloads: 8638</p>
+        <p class="info">Year: 2003</p>
+        <div class="sub-files">
+            <button
+                hx-get="/download?file_id=7873840&full_path=%2Fmedia%2Fbiblius%2FMaxtor%2FFilmovi%20i%20serije%2FThe%20Venture%20Bros%20S01-S06%20%282003-%29%2FThe%20Venture%20Bros%20S01%20%28360p%20re-dvdrip%29%2FThe%20Venture%20Bros%20S01E00%20The%20Terrible%20Secret%20of%20Turtle%20Bay.mp4"
+                class="download-button" hx-target="closest-div" hx-swap="innerHtml">
+                Download
+            </button>
+        </div>
+    </div>
+</div>
+<div class="sub-container">
+    <div class="sub-container-title">
+        <h3>The Venture Bros. - Dia de Los Dangerous! S1E1 🎯</h3>
+    </div>
+    <div class="sub-container-info">
+        <p class="info">Language: es</p>
+        <p class="info">Downloads: 535</p>
+        <p class="info">Year: 2004</p>
+        <div class="sub-files"><button
+                hx-get="/download?file_id=2653995&full_path=%2Fmedia%2Fbiblius%2FMaxtor%2FFilmovi%20i%20serije%2FThe%20Venture%20Bros%20S01-S06%20%282003-%29%2FThe%20Venture%20Bros%20S01%20%28360p%20re-dvdrip%29%2FThe%20Venture%20Bros%20S01E00%20The%20Terrible%20Secret%20of%20Turtle%20Bay.mp4"
+                class="download-button" hx-target="closest div" hx-swap="innerHtml">Download</button></div>
+    </div>
+</div>