summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Reeder <colin@vpzom.click>2020-06-16 20:43:10 -0600
committerColin Reeder <colin@vpzom.click>2020-06-16 20:43:10 -0600
commit11df82f9f9b0caec879b137901b6f4b3556e8c98 (patch)
tree4ebc00c9867f49744e816cd3af714f42f4af2e31
parentd502022425d811b2df51928fadac51d5e467d382 (diff)
Introduce some CSS
-rw-r--r--Cargo.lock5
-rw-r--r--Cargo.toml2
-rw-r--r--res/main.css20
-rw-r--r--src/routes/mod.rs7
-rw-r--r--src/routes/static.rs26
5 files changed, 55 insertions, 5 deletions
diff --git a/Cargo.lock b/Cargo.lock
index fc4eb1c..06191e3 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -786,11 +786,12 @@ checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860"
[[package]]
name = "trout"
-version = "0.1.1"
+version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "97ed60cc6988f3a6acf7c32a49c258a3b41049cab7b9eef409a5871b567b4679"
+checksum = "c525ebdc306faebb8a191ad8be3fa914d7aaf8e7d724ab0471d1f9d380c4e4e2"
dependencies = [
"hyper",
+ "percent-encoding",
]
[[package]]
diff --git a/Cargo.toml b/Cargo.toml
index 3a75cb6..de43582 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,7 +9,7 @@ license = "AGPL-3.0-or-later"
[dependencies]
render = { git = "https://github.com/vpzomtrrfrt/render.rs", rev = "0604925" }
-trout = "0.1.1"
+trout = "0.2.0"
hyper = "0.13.6"
hyper-tls = "0.4.1"
tokio = { version = "0.2.21", features = ["macros"] }
diff --git a/res/main.css b/res/main.css
new file mode 100644
index 0000000..543f186
--- /dev/null
+++ b/res/main.css
@@ -0,0 +1,20 @@
+body {
+ margin: 8px;
+}
+.mainHeader {
+ margin: -8px -8px 0 -8px;
+ padding: 8px;
+ border-bottom: 1px solid rgba(0,0,0,.24);
+ box-shadow: 0 1px 3px rgba(0,0,0,.24);
+}
+.mainHeader:after {
+ content: "";
+ clear: both;
+ display: block;
+}
+.mainHeader > .left {
+ float: left;
+}
+.mainHeader > .right {
+ float: right;
+}
diff --git a/src/routes/mod.rs b/src/routes/mod.rs
index f37f576..11f672e 100644
--- a/src/routes/mod.rs
+++ b/src/routes/mod.rs
@@ -3,6 +3,7 @@ use std::borrow::Cow;
use std::sync::Arc;
mod communities;
+mod r#static;
const COOKIE_AGE: u32 = 60 * 60 * 24 * 365;
@@ -146,11 +147,12 @@ fn HTPage<'base_data, Children: render::Render>(
<html>
<head>
<meta charset={"utf-8"} />
+ <link rel={"stylesheet"} href={"/static/main.css"} />
</head>
<body>
<header class={"mainHeader"}>
- <div><a href={"/"}>{"lotide"}</a></div>
- <div>
+ <div class={"left"}><a href={"/"}>{"lotide"}</a></div>
+ <div class={"right"}>
{
match base_data.login {
Some(_) => None,
@@ -845,4 +847,5 @@ pub fn route_root() -> crate::RouteNode<()> {
crate::RouteNode::new().with_handler_async("POST", handler_signup_submit),
),
)
+ .with_child("static", r#static::route_static())
}
diff --git a/src/routes/static.rs b/src/routes/static.rs
new file mode 100644
index 0000000..0a55472
--- /dev/null
+++ b/src/routes/static.rs
@@ -0,0 +1,26 @@
+use std::sync::Arc;
+
+const FILE_MAIN_CSS: &[u8] = include_bytes!("../../res/main.css");
+
+pub fn route_static() -> crate::RouteNode<()> {
+ crate::RouteNode::new()
+ .with_child_str(
+ crate::RouteNode::new()
+ .with_handler_async("GET", handler_static_get)
+ )
+}
+
+async fn handler_static_get(
+ params: (String,),
+ _ctx: Arc<crate::RouteContext>,
+ _req: hyper::Request<hyper::Body>,
+) -> Result<hyper::Response<hyper::Body>, crate::Error> {
+ if params.0 == "main.css" {
+ let mut resp = hyper::Response::new(FILE_MAIN_CSS.into());
+ resp.headers_mut().insert(hyper::header::CONTENT_TYPE, hyper::header::HeaderValue::from_static("text/css"));
+
+ Ok(resp)
+ } else {
+ Err(crate::Error::RoutingError(trout::RoutingFailure::NotFound))
+ }
+}