From 04eec386b1fbaab82670900b155fb4197f77e10e Mon Sep 17 00:00:00 2001 From: asonix Date: Sun, 31 Jan 2021 15:43:29 -0600 Subject: [PATCH] Server: Add forkawesome --- src/main.rs | 17 ++++++++++++++--- templates/file_js.rs.html | 1 - templates/layouts/root.rs.html | 3 ++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3a286c9..94c857a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -123,7 +123,7 @@ async fn main() -> anyhow::Result<()> { .route("/", web::get().to(home)) .route("/browse", web::get().to(browse::index)) .route("/settings", web::get().to(settings)) - .route("/toolkit/{name}", web::get().to(toolkit)) + .route("/toolkit/{folder}/{name}", web::get().to(toolkit)) .route("/static/{name}", web::get().to(statics)) .service(web::scope("/.well-known").route( "/webfinger", @@ -274,7 +274,7 @@ impl fmt::Debug for State { } fn toolkit_path(name: &str) -> String { - format!("/toolkit/{}", name) + format!("/toolkit/static/{}", name) } fn statics_path(name: &str) -> String { @@ -289,7 +289,18 @@ async fn home(profile: Option) -> HttpResponse { } } -async fn toolkit(path: web::Path, startup: web::Data) -> HttpResponse { +async fn toolkit( + path: web::Path<(String, String)>, + startup: web::Data, +) -> HttpResponse { + let (folder, path) = path.into_inner(); + + let path = if folder == "fonts" { + format!("fonts/{}", path) + } else { + path + }; + if let Some(file) = hyaenidae_toolkit::templates::statics::StaticFile::get(&path) { return HttpResponse::Ok() .set(LastModified(SystemTime::clone(&startup).into())) diff --git a/templates/file_js.rs.html b/templates/file_js.rs.html index 81b3ddd..fca7d32 100644 --- a/templates/file_js.rs.html +++ b/templates/file_js.rs.html @@ -2,4 +2,3 @@ @() - diff --git a/templates/layouts/root.rs.html b/templates/layouts/root.rs.html index eed95ee..852c381 100644 --- a/templates/layouts/root.rs.html +++ b/templates/layouts/root.rs.html @@ -1,5 +1,5 @@ @use crate::{toolkit_path, statics_path, templates::statics::layout_css}; -@use hyaenidae_toolkit::templates::statics::toolkit_css; +@use hyaenidae_toolkit::templates::statics::{toolkit_css, fork_awesome_min_css}; @(title: &str, description: &str, dark: bool, head: Content, body: Content) @@ -12,6 +12,7 @@ @Html(title) +