From d3319493d9212e48e5a936984cba23fec3414cb4 Mon Sep 17 00:00:00 2001 From: Bat Date: Thu, 10 May 2018 19:01:16 +0100 Subject: [PATCH] Serve static files --- src/main.rs | 2 ++ src/routes/mod.rs | 8 ++++++++ static/main.css | 4 ++++ templates/base.tera | 1 + 4 files changed, 15 insertions(+) create mode 100644 static/main.css diff --git a/src/main.rs b/src/main.rs index 78544691..e753e7b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,6 +58,8 @@ fn init_pool() -> PgPool { fn main() { rocket::ignite() .mount("/", routes![ + routes::static_files, + routes::well_known::host_meta, routes::well_known::webfinger, diff --git a/src/routes/mod.rs b/src/routes/mod.rs index 4b4a40af..2a72711b 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -1,3 +1,6 @@ +use rocket::response::NamedFile; +use std::path::{Path, PathBuf}; + pub mod blogs; pub mod comments; pub mod instance; @@ -6,3 +9,8 @@ pub mod posts; pub mod session; pub mod user; pub mod well_known; + +#[get("/static/")] +fn static_files(file: PathBuf) -> Option { + NamedFile::open(Path::new("static/").join(file)).ok() +} diff --git a/static/main.css b/static/main.css new file mode 100644 index 00000000..c8260b3e --- /dev/null +++ b/static/main.css @@ -0,0 +1,4 @@ +html { + margin: 0px; + padding: 0px; +} diff --git a/templates/base.tera b/templates/base.tera index 80f4b4b7..833f078f 100644 --- a/templates/base.tera +++ b/templates/base.tera @@ -3,6 +3,7 @@ {% block title %}{% endblock title %} ⋅ Plume + {% block content %}