From 371e1b23e6d8d5da0d2b31327d1f6033bdf95c88 Mon Sep 17 00:00:00 2001 From: glyph Date: Sat, 9 May 2020 11:33:19 +0100 Subject: [PATCH] Add basic nav and content, split index into component templates --- .gitignore | 1 + src/main.rs | 10 +++- static/favicon.png | Bin 0 -> 1052 bytes static/glyph.svg | 4 ++ templates/base.html.tera | 81 ++++++++++++++++++++++++++++++++ templates/index.html.tera | 83 ++++----------------------------- templates/index.html.tera.dark | 76 ++++++++++++++++++++++++++++++ templates/nav.html.tera | 22 +++++++++ 8 files changed, 203 insertions(+), 74 deletions(-) create mode 100644 static/favicon.png create mode 100644 static/glyph.svg create mode 100644 templates/base.html.tera create mode 100644 templates/index.html.tera.dark create mode 100644 templates/nav.html.tera diff --git a/.gitignore b/.gitignore index 2b2e86d..9c5a16b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target +/screenshots notes diff --git a/src/main.rs b/src/main.rs index 8275223..bf1bb7c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,9 @@ extern crate rocket_contrib; extern crate serde_derive; extern crate tera; +use std::path::{Path, PathBuf}; + +use rocket::response::NamedFile; use rocket_contrib::templates::Template; #[derive(Debug, Serialize)] @@ -26,6 +29,11 @@ fn index() -> Template { Template::render("index", &context) } +#[get("/")] +fn files(file: PathBuf) -> Option { + NamedFile::open(Path::new("static/").join(file)).ok() +} + #[catch(404)] fn not_found() -> Template { debug!("404 Page Not Found"); @@ -38,7 +46,7 @@ fn not_found() -> Template { fn main() { rocket::ignite() - .mount("/", routes![index]) + .mount("/", routes![index, files]) .register(catchers![not_found]) .attach(Template::fairing()) .launch(); diff --git a/static/favicon.png b/static/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..2415c04af3ed074a323b1ddc82a54204b9c8830d GIT binary patch literal 1052 zcmV+%1mpXOP)WFU8GbZ8()Nlj2>E@cM*00V$YL_t(&-rbr%OcP-k z#(&?}S|9`&Isk+GNk|>kp$sqxi3xEfY~Vyp05xe7HIc;u99%R(lXg%bAx_9fSPcmY zFyKHJ9c)PW;{XgDkRYYBJ%?*+dv`rbY0DkY)PB9YKF>YhpZ9y;Pbi9l354c*{)^)= zh-|~o25hbS*bN2P55sXp{k_%=jUH(B`f2M5($WF$R&cr~1;jZ*%n^^l<|-@&P6#bj z7xfHpf0SN-4ei~R5>=d#=n<^U!2HW1--1xR*8cavq@ZUQs_V)uB$-t;&UHrf>|s&(z4c8nwk&Aylu*d`uQ2sUxiInbP>8V6 zIYH-O34|<8++p#}kCF<|V#EPTGPlif0}^NI=f3f~^iBLMUda3lAKyL($|m3<4n2JC zXW&Ed;zG=vD7An>1(`TwEW~U~lv~7kV)Bd`y^w=2yuPhx>u|y6Q!0ulRgj43+u#1u z&1Shmk_mWq%Xo^dloN$GQ{M#de~avOM&?|wHVcP)`i1DKL>T?Ibf_HHX7e}_Jp$iN z#WGG5;!N<5NQX239a)*dcF5waIueh;(<L`%(z9ik?d@s>sEHd&IXdL zbsu)e*1Au!8_EsSomKV|vKtCW_QRTaIck04+HtZUMrQI(cE)i;6ExZwl3KU@Rn)qX zG z)1{{N?Fw&y^#8`H*I%PoF74q)io43Tz1!d}#U75NxXa8yAD9#cy#Xt^F)%68la$PC zgnNeVH$JjB%gnC6x=yVWL2iQ13a(^xNOK#S7TF~_p(sjPO!B&yV*s{>3b!BRLQZiy1JZkD*i{x2lyVeT#JS`n+(J4J9 z@^q){@WZYL281?_y8ICir>pc?%Ca8e$i}4))#O3(hib%iIp!oUCqygiY7U+WK>Py` W{e$#m^(nvr0000k^ literal 0 HcmV?d00001 diff --git a/static/glyph.svg b/static/glyph.svg new file mode 100644 index 0000000..3b9dfc2 --- /dev/null +++ b/static/glyph.svg @@ -0,0 +1,4 @@ + + + + diff --git a/templates/base.html.tera b/templates/base.html.tera new file mode 100644 index 0000000..b1488c5 --- /dev/null +++ b/templates/base.html.tera @@ -0,0 +1,81 @@ + + + + + + + mycelial technology | glyph + + + + + + + {% block nav %}{% endblock %} + + diff --git a/templates/index.html.tera b/templates/index.html.tera index 47992a0..d243088 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -1,75 +1,12 @@ - - - - - - mycelial technology | glyph - - - - - - -

mycelial technology

-
- +{% extends "nav" %} +{% block content %} +

Welcome to the personal website of glyph.

Contact Information

-
- - - +
+ +{%- endblock %} diff --git a/templates/index.html.tera.dark b/templates/index.html.tera.dark new file mode 100644 index 0000000..c7623e8 --- /dev/null +++ b/templates/index.html.tera.dark @@ -0,0 +1,76 @@ + + + + + + mycelial technology | glyph + + + + + + +

mycelial technology

+
+ +

Welcome to the personal website of glyph.

+

Contact Information

+
+ + + diff --git a/templates/nav.html.tera b/templates/nav.html.tera new file mode 100644 index 0000000..be00b6c --- /dev/null +++ b/templates/nav.html.tera @@ -0,0 +1,22 @@ +{% extends "base" %} +{% block nav -%} +

mycelial technology

+
+ + {%- block content %}{%- endblock %} + +{%- endblock %}