diff --git a/src/main.rs b/src/main.rs index 581f0ec..4d0114b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,32 +15,15 @@ use database::{clean_loop, Database, Mmid, MochiFile}; use endpoints::{file_info, lookup_mmid, lookup_mmid_name, lookup_mmid_noredir, server_info}; use log::info; use maud::{html, Markup, PreEscaped}; -use pages::{about, api_info, footer, head}; +use pages::{about, api_info, favicon, fira_code, footer, form_handler_js, head, roboto_flex, stylesheet}; use rocket::{ - data::{Limits, ToByteUnit}, form::Form, fs::TempFile, get, http::ContentType, post, response::content::{RawCss, RawJavaScript}, routes, serde::{json::Json, Serialize}, tokio, Config, FromForm, State + data::{Limits, ToByteUnit}, form::Form, fs::TempFile, get, post, routes, serde::{json::Json, Serialize}, tokio, Config, FromForm, State }; use settings::Settings; use strings::{parse_time_string, to_pretty_time}; use utils::hash_file; use uuid::Uuid; -/// Stylesheet -#[get("/resources/main.css")] -fn stylesheet() -> RawCss<&'static str> { - RawCss(include_str!("../web/main.css")) -} - -/// Upload handler javascript -#[get("/resources/request.js")] -fn form_handler_js() -> RawJavaScript<&'static str> { - RawJavaScript(include_str!("../web/request.js")) -} - -#[get("/resources/favicon.svg")] -fn favicon() -> (ContentType, &'static str) { - (ContentType::SVG, include_str!("../web/favicon.svg")) -} - #[get("/")] fn home(settings: &State) -> Markup { html! { @@ -237,17 +220,19 @@ async fn main() { home, api_info, about, + favicon, + form_handler_js, + stylesheet, + fira_code, + roboto_flex, ], ) .mount( config.server.root_path.clone() + "/", routes![ handle_upload, - form_handler_js, - stylesheet, server_info, file_info, - favicon, lookup_mmid, lookup_mmid_noredir, lookup_mmid_name, diff --git a/src/pages.rs b/src/pages.rs index 6d4290e..07bf400 100644 --- a/src/pages.rs +++ b/src/pages.rs @@ -1,5 +1,5 @@ use maud::{html, Markup, DOCTYPE}; -use rocket::{get, State}; +use rocket::{get, http::ContentType, response::content::{RawCss, RawJavaScript}, State}; use crate::settings::Settings; @@ -26,6 +26,32 @@ pub fn footer() -> Markup { } } +/// Stylesheet +#[get("/resources/main.css")] +pub fn stylesheet() -> RawCss<&'static str> { + RawCss(include_str!("../web/main.css")) +} + +/// Upload handler javascript +#[get("/resources/request.js")] +pub fn form_handler_js() -> RawJavaScript<&'static str> { + RawJavaScript(include_str!("../web/request.js")) +} + +#[get("/resources/favicon.svg")] +pub fn favicon() -> (ContentType, &'static str) { + (ContentType::SVG, include_str!("../web/favicon.svg")) +} + +#[get("/resources/Roboto.woff2")] +pub fn roboto_flex() -> (ContentType, &'static [u8]) { + (ContentType::WOFF2, include_bytes!("../web/fonts/roboto.woff2")) +} +#[get("/resources/FiraCode.woff2")] +pub fn fira_code() -> (ContentType, &'static [u8]) { + (ContentType::WOFF2, include_bytes!("../web/fonts/fira-code.woff2")) +} + #[get("/api")] pub fn api_info(settings: &State) -> Markup { let domain = &settings.server.domain; @@ -154,11 +180,10 @@ pub fn about(settings: &State) -> Markup { software available under the terms of the " a target="_blank" href="//www.gnu.org/licenses/agpl-3.0.txt" {"AGPL-3.0 license"} ". The source code is available on " - a target="_blank" href="https://github.com/Dangoware/confetti-box" {"GitHub"} - " and a couple of other places. The AGPL is very restrictive - when it comes to use on servers, so if you would like to use - Confetti-Box for a commercial purpose, please contact - Dangoware." + a target="_blank" href="//github.com/Dangoware/confetti-box" {"GitHub"} + ". The AGPL is very restrictive when it comes to use on + servers, so if you would like to use Confetti-Box for a + commercial purpose, please contact Dangoware." } p { diff --git a/web/fonts/fira-code.woff2 b/web/fonts/fira-code.woff2 new file mode 100644 index 0000000..00c8383 Binary files /dev/null and b/web/fonts/fira-code.woff2 differ diff --git a/web/fonts/roboto.woff2 b/web/fonts/roboto.woff2 new file mode 100644 index 0000000..2d7b215 Binary files /dev/null and b/web/fonts/roboto.woff2 differ diff --git a/web/main.css b/web/main.css index 70cd9d2..7233d63 100644 --- a/web/main.css +++ b/web/main.css @@ -1,7 +1,19 @@ -@import url('https://fonts.googleapis.com/css2?family=Chokokutai&family=Fira+Code:wght@300..700&family=M+PLUS+Rounded+1c:wght@100;300;400;500;700;800;900&family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap'); +@font-face { + font-family: "Roboto"; + src: + /*local("Roboto"),*/ + url("/resources/Roboto.woff2"); +} + +@font-face { + font-family: "Fira Code"; + src: + /*local("Fira Code"),*/ + url("/resources/FiraCode.woff2"); +} body { - font-family: "Roboto Flex", sans-serif; + font-family: "Roboto", sans-serif; font-size: 14pt; font-optical-sizing: auto; }