added routes for js and random media
removed login logic from website as the app is needed for that
This commit is contained in:
parent
1706efc619
commit
9bdeedb3d8
@ -35,7 +35,7 @@ fn rocket() -> rocket::Rocket {
|
||||
rocket::ignite()
|
||||
.mount("/static", StaticFiles::from("/static"))
|
||||
.mount("/", routes![
|
||||
homepage, login_page, about_page, server_info,
|
||||
homepage, about_page, server_info,
|
||||
static_css,
|
||||
])
|
||||
.attach(Template::fairing())
|
||||
@ -61,7 +61,7 @@ mod test {
|
||||
}
|
||||
// Next we test the static resource routes
|
||||
#[test]
|
||||
fn static_css() {
|
||||
fn statics() {
|
||||
let client = Client::new(rocket()).expect("Valid rocket instance");
|
||||
let response = client.get("/static/css/index.css").dispatch();
|
||||
assert_eq!(response.status(), Status::Ok);
|
||||
|
@ -45,12 +45,7 @@ pub fn homepage() -> Template {
|
||||
let ctx = context();
|
||||
Template::render("index", &ctx)
|
||||
}
|
||||
// Handles logging in a user to their home instance
|
||||
#[get("/login")]
|
||||
pub fn login_page() -> Template {
|
||||
let ctx = context();
|
||||
Template::render("login", &ctx)
|
||||
}
|
||||
|
||||
#[get("/about")]
|
||||
pub fn about_page() -> Template {
|
||||
let ctx = context();
|
||||
@ -70,3 +65,20 @@ pub fn static_css(file: String) -> Option<NamedFile> {
|
||||
f = f.replace("%2e", "");
|
||||
NamedFile::open(Path::new("static/css/").join(f)).ok()
|
||||
}
|
||||
|
||||
#[get("/static/js/<file>")]
|
||||
pub fn static_js(file: String) -> Option<NamedFile> {
|
||||
let mut f = file;
|
||||
f = f.replace("..", "");
|
||||
f = f.replace("%2e", "");
|
||||
NamedFile::open(Path::new("static/js/").join(f)).ok()
|
||||
}
|
||||
|
||||
|
||||
#[get("/static/media/<file>")]
|
||||
pub fn static_js(file: String) -> Option<NamedFile> {
|
||||
let mut f = file;
|
||||
f = f.replace("..", "");
|
||||
f = f.replace("%2e", "");
|
||||
NamedFile::open(Path::new("static/media/").join(f)).ok()
|
||||
}
|
Loading…
Reference in New Issue
Block a user