Server: Add forkawesome

This commit is contained in:
asonix 2021-01-31 15:43:29 -06:00
parent b01ee00541
commit 04eec386b1
3 changed files with 16 additions and 5 deletions

View file

@ -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<UserProfile>) -> HttpResponse {
}
}
async fn toolkit(path: web::Path<String>, startup: web::Data<SystemTime>) -> HttpResponse {
async fn toolkit(
path: web::Path<(String, String)>,
startup: web::Data<SystemTime>,
) -> 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()))

View file

@ -2,4 +2,3 @@
@()
<script src="@crate::toolkit_path(file_input_js.name)"></script>

View file

@ -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 @@
<title>@Html(title)</title>
<link href="@toolkit_path(toolkit_css.name)" rel="stylesheet" type="text/css" />
<link href="@statics_path(layout_css.name)" rel="stylesheet" type="text/css" />
<link href="@toolkit_path(fork_awesome_min_css.name)" rel="stylesheet" type="text/css" />
<meta property="og:title" content="@title" />
<meta property="og:description" content="@description" />
<meta property="og:type" content="website" />