diff options
author | tpart <10518520-tpart@users.noreply.gitlab.com> | 2023-01-15 12:38:42 +0100 |
---|---|---|
committer | tpart <10518520-tpart@users.noreply.gitlab.com> | 2023-01-15 12:38:42 +0100 |
commit | 85abefbc5668d42c0d23735a4ce157ee8659c88b (patch) | |
tree | 4208c3aa8fc1b0404b41c22cf730101ab23291a5 /server/src | |
parent | e3f1a8ac9f4c9a015e9eac769fb3262e3bd16bad (diff) | |
download | jellything-85abefbc5668d42c0d23735a4ce157ee8659c88b.tar jellything-85abefbc5668d42c0d23735a4ce157ee8659c88b.tar.bz2 jellything-85abefbc5668d42c0d23735a4ce157ee8659c88b.tar.zst |
Use cantarell font
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/frontend/style/cantarell.woff2 | bin | 0 -> 93888 bytes | |||
-rw-r--r-- | server/src/frontend/style/layout.css | 9 | ||||
-rw-r--r-- | server/src/frontend/style/mod.rs | 21 | ||||
-rw-r--r-- | server/src/main.rs | 25 |
4 files changed, 39 insertions, 16 deletions
diff --git a/server/src/frontend/style/cantarell.woff2 b/server/src/frontend/style/cantarell.woff2 Binary files differnew file mode 100644 index 0000000..76fd894 --- /dev/null +++ b/server/src/frontend/style/cantarell.woff2 diff --git a/server/src/frontend/style/layout.css b/server/src/frontend/style/layout.css index 4418903..0612a7e 100644 --- a/server/src/frontend/style/layout.css +++ b/server/src/frontend/style/layout.css @@ -1,8 +1,11 @@ -@import url("https://s.metamuffin.org/static/font-ubuntu/include.css"); +@font-face { + font-family: 'Cantarell'; + src: url(/assets/cantarell.woff2) format('woff2'); +} * { color: white; - font-family: "Ubuntu", sans-serif; + font-family: "Cantarell", sans-serif; font-weight: 300; margin: 0px; padding: 0px; @@ -39,4 +42,4 @@ nav h1 { padding: 1em; color: rgb(255, 117, 117); font-family: monospace; -} +}
\ No newline at end of file diff --git a/server/src/frontend/style/mod.rs b/server/src/frontend/style/mod.rs index 9d0729e..1e51d10 100644 --- a/server/src/frontend/style/mod.rs +++ b/server/src/frontend/style/mod.rs @@ -1,2 +1,21 @@ +use std::{fs::{File, read_to_string}, io::Read}; -pub const CSS_BUNDLE: &'static str = include_str!("layout.css"); + + +pub fn css_bundle() -> String { + if cfg!(debug_assertions) { + read_to_string("server/src/frontend/style/layout.css").unwrap() + } else { + include_str!("layout.css").to_string() + } +} + +pub fn font_bundle() -> Vec<u8> { + if cfg!(debug_assertions) { + let mut woff = Vec::new(); + File::open("server/src/frontend/style/cantarell.woff2").unwrap().read_to_end(&mut woff).unwrap(); + woff + } else { + include_bytes!("cantarell.woff2").to_vec() + } +} diff --git a/server/src/main.rs b/server/src/main.rs index edf562a..a9db370 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -1,14 +1,17 @@ #![feature(box_syntax)] -use crate::frontend::{pages::MyError, style::CSS_BUNDLE}; +use crate::frontend::{pages::MyError}; use anyhow::{anyhow, Context}; use database::Database; -use frontend::pages::{home::page_home, node::page_library_node}; +use frontend::{ + pages::{home::page_home, node::page_library_node}, + style::{css_bundle, font_bundle}, +}; use jellyremuxer::RemuxerContext; use library::Library; use log::{debug, warn}; use rocket::{get, http::ContentType, launch, response::stream::ReaderStream, routes, State}; -use std::{fs::read_to_string, path::PathBuf, sync::Arc}; +use std::{path::PathBuf, sync::Arc}; use tokio::io::{duplex, DuplexStream}; use tokio_util::io::SyncIoBridge; @@ -18,14 +21,12 @@ pub mod library; #[get("/assets/style.css")] async fn assets_style() -> (ContentType, String) { - ( - ContentType::CSS, - if cfg!(debug_assertions) { - read_to_string("server/src/frontend/style/layout.css").unwrap() - } else { - CSS_BUNDLE.to_string() - }, - ) + (ContentType::CSS, css_bundle()) +} + +#[get("/assets/cantarell.woff2")] +async fn assets_font() -> (ContentType, Vec<u8>) { + (ContentType::WOFF2, font_bundle()) } #[get("/stream/<path..>?<selection>")] @@ -83,6 +84,6 @@ fn rocket() -> _ { rocket::build().manage(state).mount( "/", - routes![page_home, page_library_node, assets_style, stream], + routes![page_home, page_library_node, assets_style, assets_font, stream], ) } |