From 4b6ced439da2847f8f4a7a87809adf046c515ec2 Mon Sep 17 00:00:00 2001 From: shockrah Date: Fri, 8 Oct 2021 13:21:09 -0700 Subject: [PATCH] ! Bulk commit of progression A lot off issues with the current design make 100% more sense by cutting hugo out of the picture entirely This means we're switching fully to rocket however we're not going to leave behind the work done with hugo, we're just going to migrate it over first --- .gitignore | 1 + api/src/main.rs | 2 +- api/src/video.rs | 30 +++++++++- frontend/content/collection.md | 6 ++ .../clippable/layouts/collection/baseof.html | 15 +++++ .../clippable/layouts/collection/single.html | 4 ++ .../themes/clippable/static/css/style.css | 4 ++ frontend/ts/collection.ts | 59 +++++++++++++++++++ frontend/ts/index.ts | 32 +++++++--- 9 files changed, 143 insertions(+), 10 deletions(-) create mode 100644 frontend/content/collection.md create mode 100644 frontend/themes/clippable/layouts/collection/baseof.html create mode 100644 frontend/themes/clippable/layouts/collection/single.html create mode 100644 frontend/ts/collection.ts diff --git a/.gitignore b/.gitignore index 6d6452e..78bbb51 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ api/vids/ frontend/themes/clippable/static/js/index.js frontend/public/ frontend/themes/clippable/static/js/category.js +frontend/themes/clippable/static/js/collection.js diff --git a/api/src/main.rs b/api/src/main.rs index 67a190f..ddcc9d6 100644 --- a/api/src/main.rs +++ b/api/src/main.rs @@ -12,6 +12,6 @@ fn main() { * CLIP_DIR */ let _ = rocket::ignite() - .mount("/api", routes![video::list_categories]) + .mount("/api", routes![video::list_categories, video::list_videos]) .launch(); } diff --git a/api/src/video.rs b/api/src/video.rs index 5b5df7d..71f0a17 100644 --- a/api/src/video.rs +++ b/api/src/video.rs @@ -13,6 +13,13 @@ struct Category { thumbnail: Option } +#[derive(Serialize)] +struct Video { + name: String, + category: String, + thumbnail: Option +} + fn get_nail(dirpath: &Path) -> std::io::Result> { let mut t_path = dirpath.to_path_buf(); t_path.push(".thumbnail.jpg"); @@ -29,7 +36,7 @@ fn get_nail(dirpath: &Path) -> std::io::Result> { pub fn list_categories() -> JsonValue { let dir = match env::var("CLIPS_DIR") { Ok(val) => val, - Err(e) => "/media/clips/".to_string() + Err(_) => "/media/clips/".to_string() }; // Fucking hell this is going to be dumb @@ -48,3 +55,24 @@ pub fn list_categories() -> JsonValue { json!({"categories": cats}) } + +#[get("/category/")] +pub fn list_videos(cat: String) -> JsonValue { + let dir = match env::var("CLIPS_DIR") { + Ok(val) => val, + Err(_) => "/media/clips".to_string() + }; + + let mut vids: Vec