moved goalposts LULW

This commit is contained in:
shockrahwow
2019-11-12 11:19:44 -08:00
parent 1e525e3c05
commit d3fd575b32
10 changed files with 848 additions and 1243 deletions

View File

@@ -1,3 +1,107 @@
fn main() {
println!("Hello, world!");
// 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 serde_derive;
#[macro_use] extern crate rocket;
extern crate rocket_contrib;
use rocket_contrib::templates::Template;
use rocket::response::NamedFile;
use std::io;
// Purely for backend purposes
#[derive(Serialize)]
struct PageAttrs {
og_title: &'static str,
og_type: &'static str,
og_desc: &'static str,
og_url: &'static str,
og_image: &'static str,
// General settings
favicon: &'static str, // path to the favicon
// Branding things
brand_url: &'static str, // default is freechat.io - clean url of domain
brand_motto: &'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() {
rocket::ignite()
.mount("/", routes![
homepage, login_page, server_info,
static_css, static_js
])
.attach(Template::fairing())
.launch();
}

95
server/src/website.rs Normal file
View File

@@ -0,0 +1,95 @@
// Basic router for that server's general website page.
// All new servers come with this as a default so that
use rocket_contrib::templates::Template;
use rocket::response::NamedFile;
use std::io;
// Purely for backend purposes
#[derive(Serialize)]
struct PageAttrs {
og_title: &'static str,
og_type: &'static str,
og_desc: &'static str,
og_url: &'static str,
og_image: &'static str,
// General settings
favicon: &'static str, // path to the favicon
// Branding things
brand_url: &'static str, // default is freechat.io - clean url of domain
brand_motto: &'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 {
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",
}
}
// 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
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")]
pub 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>")]
pub fn static_css(stylesheet: String) -> io::Result<NamedFile> {
println!("{}", stylesheet);
css!(stylesheet)
}
#[get("/static/js/<javascript>")]
pub fn static_js(javascript: String) -> io::Result<NamedFile> {
js!(javascript)
}