shifted goals for the codebase in client

it's now just the main website's code
This commit is contained in:
shockrah
2019-11-10 16:37:24 -08:00
parent 56c6a3ad16
commit ca6401afab
6 changed files with 1 additions and 3 deletions

53
website/src/main.rs Normal file
View File

@@ -0,0 +1,53 @@
// This client code really just serves as the url router for the main website where we describe what the project is about
#![feature(proc_macro_hygiene, decl_macro, plugin)]
//#[macro_use] extern crate serde_derive;
#[macro_use] extern crate rocket;
extern crate rocket_contrib;
use rocket::response::NamedFile;
use std::io;
macro_rules! page {
($type:expr, $item:expr) => {
// TODO: verify against directory traversals
NamedFile::open(format!("staic/{}/{}", $type, $item))
}
}
// Pages themselves
#[get("/")]
fn homepage() -> io::Result<NamedFile> {
// Be sure to include some kind of prompt
page!("html", "index")
}
// Handles logging in a user to their home instance
#[get("/login")]
fn login_page() -> io::Result<NamedFile> {
page!("html", "login")
}
#[get("/servers")]
fn server_info() -> io::Result<NamedFile> {
page!("html", "servers")
}
// Genearl resources
#[get("/static/css/<stylesheet>")]
fn static_css(stylesheet: String) -> io::Result<NamedFile> {
page!("css", stylesheet)
}
#[get("/static/js/<javascript>")]
fn static_js(javascript: String) -> io::Result<NamedFile> {
page!("js", javascript)
}
fn main() {
rocket::ignite()
.mount("/", routes![
homepage, login_page, server_info
])
.mount("/static", routes![
static_css, static_js
])
.launch();
}