From c53d9a293e97d8f5cbe7bcedd5ba930d4d41b45c Mon Sep 17 00:00:00 2001 From: shockrah Date: Sat, 16 Oct 2021 18:14:04 -0700 Subject: [PATCH] ! Finalizing video fetch endpoint With this the backend is officially at an MVP stage and now requires polishing Proper data streaming for larger clips is basically required for a really good backend(especially async streaming) and some better css for the video player --- api/Cargo.toml | 1 - api/src/page.rs | 5 ++--- api/src/video.rs | 2 +- api/static/css/style.css | 3 +++ api/templates/video.html.tera | 16 +++++++++------- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/api/Cargo.toml b/api/Cargo.toml index 04bf1c9..7333946 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -9,7 +9,6 @@ edition = "2018" rocket = { version = "0.5.0-rc.1", features = [ "json" ] } tokio = "1.0" serde = { version = "1.0", features = [ "derive" ] } -base64 = "0.13.0" [dependencies.rocket_dyn_templates] diff --git a/api/src/page.rs b/api/src/page.rs index 1fd1047..53a96f8 100644 --- a/api/src/page.rs +++ b/api/src/page.rs @@ -37,9 +37,6 @@ pub async fn category(cat: PathBuf) -> Template { #[get("/clip//")] pub async fn video(cat: PathBuf, file_base: PathBuf) -> Template { - // NOTE: the "file name" does not include the - println!("{:?}, {:?}", cat, file_base); - let mut h: HashMap<&'static str, &str> = HashMap::new(); let cat = cat.to_string_lossy(); @@ -59,6 +56,8 @@ pub async fn video(cat: PathBuf, file_base: PathBuf) -> Template { let thumbnail = format!("/thumbnail/{}/{}", cat, file); h.insert("ogimg", &thumbnail); + let clip_url = format!("/video/{}/{}", &cat, &file); + h.insert("clip_url", &clip_url); return Template::render("video", &h); } diff --git a/api/src/video.rs b/api/src/video.rs index d0a982a..8aec679 100644 --- a/api/src/video.rs +++ b/api/src/video.rs @@ -62,7 +62,7 @@ pub fn list(cat: PathBuf) -> Option>> { } -#[get("/clip//")] +#[get("//")] pub async fn get_video(cat: PathBuf, file: PathBuf) -> Option { let clips_dir = get_clips_dir(); let path = Path::new(&clips_dir).join(cat).join(file); diff --git a/api/static/css/style.css b/api/static/css/style.css index 2243f5e..cbafdcd 100644 --- a/api/static/css/style.css +++ b/api/static/css/style.css @@ -38,6 +38,9 @@ a { background: #191818; border-radius: 1em; } +video { + max-width: 100%; +} .pure-form { text-align: center; diff --git a/api/templates/video.html.tera b/api/templates/video.html.tera index 2808215..a20739c 100644 --- a/api/templates/video.html.tera +++ b/api/templates/video.html.tera @@ -19,12 +19,14 @@ {% endif %} -
-
-

- -
-
+
+
+

{{title}}

+ +
+