diff --git a/Cargo.lock b/Cargo.lock index edbc935..2f36932 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,26 +35,6 @@ dependencies = [ "trust-dns-resolver", ] -[[package]] -name = "actix-files" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc0a9181e93c91dc7eb401a0debaed5c8294e12019c307c72fd7a1731b672fc" -dependencies = [ - "actix-service", - "actix-web", - "bitflags", - "bytes", - "derive_more", - "futures-core", - "futures-util", - "log", - "mime", - "mime_guess", - "percent-encoding", - "v_htmlescape", -] - [[package]] name = "actix-http" version = "2.1.0" @@ -457,15 +437,6 @@ dependencies = [ "libc", ] -[[package]] -name = "buf-min" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6ae7069aad07c7cdefe6a22a671f00650728bd2331a4cc62e1e5d0becdf9ca4" -dependencies = [ - "bytes", -] - [[package]] name = "bumpalo" version = "3.4.0" @@ -1068,7 +1039,6 @@ checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" name = "libreddit" version = "0.1.3" dependencies = [ - "actix-files", "actix-web", "askama", "chrono", @@ -2169,38 +2139,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "v_escape" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "039a44473286eb84e4e74f90165feff67c802dbeced7ee4c5b00d719b0d0475e" -dependencies = [ - "buf-min", - "v_escape_derive", -] - -[[package]] -name = "v_escape_derive" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c860ad1273f4eee7006cee05db20c9e60e5d24cba024a32e1094aa8e574f3668" -dependencies = [ - "nom", - "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.48", -] - -[[package]] -name = "v_htmlescape" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7c2a33ed7cf0dc1b42bcf39e01b6512f9df08f09e1cd8a49d9dc49a6a9482" -dependencies = [ - "cfg-if 1.0.0", - "v_escape", -] - [[package]] name = "vcpkg" version = "0.2.10" diff --git a/Cargo.toml b/Cargo.toml index d8d24bb..79865f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,6 @@ edition = "2018" [dependencies] actix-web = "3.2.0" -actix-files = "0.4.0" askama = "0.8.0" serde = "1.0.117" serde_json = "1.0" diff --git a/src/main.rs b/src/main.rs index 21ade6b..8293113 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ // Import Crates -use actix_files::NamedFile; -use actix_web::{get, App, HttpResponse, HttpServer, Result}; +use actix_web::{get, App, HttpResponse, HttpServer}; +use std::fs; // Reference local files mod popular; @@ -10,9 +10,9 @@ mod user; // Create Services #[get("/style.css")] -async fn style() -> Result { - let file = NamedFile::open("static/style.css"); - Ok(file?) +async fn style() -> HttpResponse { + let file = fs::read_to_string("static/style.css").expect("ERROR: Could not read style.css"); + HttpResponse::Ok().body(file) } #[get("/favicon.ico")] diff --git a/src/popular.rs b/src/popular.rs index a5d1991..5719150 100644 --- a/src/popular.rs +++ b/src/popular.rs @@ -8,7 +8,7 @@ use subreddit::{posts, Post}; #[path = "utils.rs"] mod utils; -use utils::{Params}; +use utils::Params; // STRUCTS #[derive(Template)] diff --git a/src/post.rs b/src/post.rs index 9e2cfd0..f2ab9c4 100644 --- a/src/post.rs +++ b/src/post.rs @@ -6,7 +6,7 @@ use pulldown_cmark::{html, Options, Parser}; #[path = "utils.rs"] mod utils; -use utils::{Params, Comment, Flair, Post, val}; +use utils::{val, Comment, Flair, Params, Post}; // STRUCTS #[derive(Template)] diff --git a/src/subreddit.rs b/src/subreddit.rs index 190c066..71024c2 100644 --- a/src/subreddit.rs +++ b/src/subreddit.rs @@ -5,7 +5,7 @@ use chrono::{TimeZone, Utc}; #[path = "utils.rs"] mod utils; -pub use utils::{Params, Flair, Post, Subreddit, val}; +pub use utils::{val, Flair, Params, Post, Subreddit}; // STRUCTS #[derive(Template)] diff --git a/src/user.rs b/src/user.rs index 890d441..efabbf9 100644 --- a/src/user.rs +++ b/src/user.rs @@ -5,7 +5,7 @@ use chrono::{TimeZone, Utc}; #[path = "utils.rs"] mod utils; -use utils::{Params, Flair, Post, User, val, nested_val}; +use utils::{nested_val, val, Flair, Params, Post, User}; // STRUCTS #[derive(Template)] @@ -70,7 +70,7 @@ async fn posts(sub: String, sort: &String) -> Vec { let title = val(post, "title").await; posts.push(Post { - title: if title.is_empty() {"Comment".to_string()} else {title}, + title: if title.is_empty() { "Comment".to_string() } else { title }, community: val(post, "subreddit").await, body: String::new(), author: val(post, "author").await, diff --git a/src/utils.rs b/src/utils.rs index 4ab9634..660c040 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -60,4 +60,4 @@ pub async fn nested_val(j: &serde_json::Value, n: &str, k: &str) -> String { #[derive(serde::Deserialize)] pub struct Params { pub sort: Option, -} \ No newline at end of file +}