moved website routes to they're own module:
Rationale - these routes are completely seperate from everything else after this point
This commit is contained in:
parent
b3fb0b07e8
commit
07390f1469
@ -6,8 +6,8 @@
|
|||||||
extern crate rocket_contrib;
|
extern crate rocket_contrib;
|
||||||
|
|
||||||
use rocket_contrib::templates::Template;
|
use rocket_contrib::templates::Template;
|
||||||
use rocket::response::NamedFile;
|
mod website;
|
||||||
use std::io;
|
use website::*;
|
||||||
|
|
||||||
// Purely for backend purposes
|
// Purely for backend purposes
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
@ -27,74 +27,6 @@ struct PageAttrs {
|
|||||||
brand_quip: &'static str
|
brand_quip: &'static str
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! html {
|
|
||||||
($page:expr) => {
|
|
||||||
NamedFile::open(format!("static/html/{}", $page))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
macro_rules! css {
|
|
||||||
($style:expr) => {
|
|
||||||
NamedFile::open(format!("static/css/{}", $style))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
macro_rules! js {
|
|
||||||
($js:expr) => {
|
|
||||||
NamedFile::open(format!("static/js/{}", $js))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pages themselves
|
|
||||||
|
|
||||||
#[get("/")]
|
|
||||||
fn homepage() -> Template {
|
|
||||||
// Be sure to include some kind of prompt
|
|
||||||
// TODO: read this type of data from a config or provide some function/macro that
|
|
||||||
// does that for us so that we don't hardcode these values in like ever
|
|
||||||
let context = PageAttrs {
|
|
||||||
og_title: "Freechat",
|
|
||||||
og_type: "Decentralized Chat",
|
|
||||||
og_desc: "Privacy and Freedom Respecting Chat Platform",
|
|
||||||
og_url: "freechat.io",
|
|
||||||
og_image: "https://images.pexels.com/photos/146071/pexels-photo-146071.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260",// recall this is meant to be a path to the favicon
|
|
||||||
|
|
||||||
favicon: "https://images.pexels.com/photos/146071/pexels-photo-146071.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260",
|
|
||||||
brand_url: "freechat.io",
|
|
||||||
brand_motto: "Freedom respecting chat platform",
|
|
||||||
brand_quip: "Join an realm",
|
|
||||||
};
|
|
||||||
Template::render("index", &context)
|
|
||||||
}
|
|
||||||
// Handles logging in a user to their home instance
|
|
||||||
#[get("/login")]
|
|
||||||
fn login_page() -> io::Result<NamedFile> {
|
|
||||||
html!("login")
|
|
||||||
}
|
|
||||||
#[get("/servers")]
|
|
||||||
fn server_info() -> Template {
|
|
||||||
let context = PageAttrs{
|
|
||||||
og_title: "title",
|
|
||||||
og_type: "title",
|
|
||||||
og_image: "asdf",
|
|
||||||
og_desc: "title",
|
|
||||||
og_url: "title",
|
|
||||||
favicon: "title",
|
|
||||||
brand_url: "title",
|
|
||||||
brand_motto: "title",
|
|
||||||
brand_quip: "title",
|
|
||||||
};
|
|
||||||
Template::render("servers", &context)
|
|
||||||
}
|
|
||||||
|
|
||||||
// General resources
|
|
||||||
#[get("/static/css/<stylesheet>")]
|
|
||||||
fn static_css(stylesheet: String) -> io::Result<NamedFile> {
|
|
||||||
println!("{}", stylesheet);
|
|
||||||
css!(stylesheet)
|
|
||||||
}
|
|
||||||
#[get("/static/js/<javascript>")]
|
|
||||||
fn static_js(javascript: String) -> io::Result<NamedFile> {
|
|
||||||
js!(javascript)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
rocket::ignite()
|
rocket::ignite()
|
||||||
|
@ -22,21 +22,6 @@ struct PageAttrs {
|
|||||||
brand_quip: &'static str
|
brand_quip: &'static str
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! html {
|
|
||||||
($page:expr) => {
|
|
||||||
NamedFile::open(format!("static/html/{}", $page))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
macro_rules! css {
|
|
||||||
($style:expr) => {
|
|
||||||
NamedFile::open(format!("static/css/{}", $style))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
macro_rules! js {
|
|
||||||
($js:expr) => {
|
|
||||||
NamedFile::open(format!("static/js/{}", $js))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn context() -> PageAttrs {
|
fn context() -> PageAttrs {
|
||||||
PageAttrs {
|
PageAttrs {
|
||||||
@ -56,40 +41,29 @@ fn context() -> PageAttrs {
|
|||||||
// Pages themselves
|
// Pages themselves
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
fn homepage() -> Template {
|
pub fn homepage() -> Template {
|
||||||
// Be sure to include some kind of prompt
|
let ctx = context();
|
||||||
// TODO: read this type of data from a config or provide some function/macro that
|
Template::render("index", &ctx)
|
||||||
// does that for us so that we don't hardcode these values in like ever
|
|
||||||
Template::render("index", &context())
|
|
||||||
}
|
}
|
||||||
// Handles logging in a user to their home instance
|
// Handles logging in a user to their home instance
|
||||||
#[get("/login")]
|
#[get("/login")]
|
||||||
fn login_page() -> io::Result<NamedFile> {
|
pub fn login_page() -> Template {
|
||||||
html!("login")
|
let ctx = context();
|
||||||
|
Template::render("login", &ctx)
|
||||||
}
|
}
|
||||||
#[get("/servers")]
|
#[get("/servers")]
|
||||||
pub fn server_info() -> Template {
|
pub fn server_info() -> Template {
|
||||||
let context = PageAttrs{
|
let ctx = context();
|
||||||
og_title: "title",
|
Template::render("servers", &ctx)
|
||||||
og_type: "title",
|
|
||||||
og_image: "asdf",
|
|
||||||
og_desc: "title",
|
|
||||||
og_url: "title",
|
|
||||||
favicon: "title",
|
|
||||||
brand_url: "title",
|
|
||||||
brand_motto: "title",
|
|
||||||
brand_quip: "title",
|
|
||||||
};
|
|
||||||
Template::render("servers", &context)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// General resources
|
// General resources
|
||||||
#[get("/static/css/<stylesheet>")]
|
#[get("/static/css/<stylesheet>")]
|
||||||
pub fn static_css(stylesheet: String) -> io::Result<NamedFile> {
|
pub fn static_css(stylesheet: String) -> io::Result<NamedFile> {
|
||||||
println!("{}", stylesheet);
|
println!("{}", stylesheet);
|
||||||
css!(stylesheet)
|
NamedFile::open(format!("static/css/{}", stylesheet))
|
||||||
}
|
}
|
||||||
#[get("/static/js/<javascript>")]
|
#[get("/static/js/<javascript>")]
|
||||||
pub fn static_js(javascript: String) -> io::Result<NamedFile> {
|
pub fn static_js(javascript: String) -> io::Result<NamedFile> {
|
||||||
js!(javascript)
|
NamedFile::open(format!("static/js/{}", javascript))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user