use askama_rocket::Template; use rocket::{http::Status, response::content::RawCss}; use rust_embed::{EmbeddedFile, RustEmbed}; use shared::names::Site; use std::borrow::Cow; #[derive(RustEmbed)] #[folder = "public/"] pub struct PublicAssets; impl PublicAssets { fn get_asset(file_path: &str) -> Result { match PublicAssets::get(file_path) { Some(asset) => Ok(asset), None => Err(Status::NotFound), } } fn get_string(file_path: &str) -> Result { let asset = PublicAssets::get_asset(file_path)?; match std::str::from_utf8(&asset.data) { Ok(string) => Ok(string.to_string()), Err(_) => Err(Status::InternalServerError), } } } #[derive(Responder)] #[response(status = 200, content_type = "font/woff2")] pub struct RawWoff2Font(pub Cow<'static, [u8]>); #[derive(Responder)] #[response(status = 200, content_type = "font/woff")] pub struct RawWoffFont(pub Cow<'static, [u8]>); #[derive(Template)] #[template(path = "error.html")] pub struct ErrorTemplate<'a> { pub error: &'a str, pub error_description: &'a str, } #[derive(Template)] #[template(path = "index.html")] pub struct IndexTemplate { pub sites: Vec, } #[derive(Responder)] pub struct ErrorTemplateResponder<'a> { template: ErrorTemplate<'a>, } #[get("/css/