aboutsummaryrefslogtreecommitdiff
path: root/src/ui.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-02-20 22:57:33 +0000
committerFuwn <[email protected]>2021-02-20 22:57:33 +0000
commit0a8126ac5330fc022b6d1b5fb4b9c2fa38028ef7 (patch)
treec4f1201aeea4fbac52fa033cda8c3f72beb062fa /src/ui.rs
parentchore: update log (diff)
downloadchan-0a8126ac5330fc022b6d1b5fb4b9c2fa38028ef7.tar.xz
chan-0a8126ac5330fc022b6d1b5fb4b9c2fa38028ef7.zip
chore: formatting
Diffstat (limited to 'src/ui.rs')
-rw-r--r--src/ui.rs58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/ui.rs b/src/ui.rs
index def8d76..d11412b 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -2,24 +2,24 @@ use rocket_contrib::templates::Template;
use crate::db::*;
-// GET: Index.
+/// GET: Index.
#[get("/")]
pub fn index() -> Template {
- Template::render("index", &())
+ Template::render("index", &())
}
#[catch(404)]
pub fn not_found() -> Template {
- Template::render("404", &())
+ Template::render("404", &())
}
-// GET: Make a new thread.
+/// GET: Make a new thread.
// #[get("/post")]
// pub fn make_post() -> Template {
// Template::render("post", &())
// }
-// GET: Check out all the threads.
+/// GET: Check out all the threads.
// #[get("/threads")]
// pub fn threads() -> Template {
// let context = get_all_threads().unwrap();
@@ -27,34 +27,34 @@ pub fn not_found() -> Template {
// Template::render("threads", threads)
// }
-// GET: Check out all the boards.
+/// GET: Check out all the boards.
#[get("/boards")]
pub fn boards() -> Template {
- let context = get_boards().unwrap();
- let threads = serde_json::json!(&context);
- Template::render("boards", threads)
+ let context = get_boards().unwrap();
+ let threads = serde_json::json!(&context);
+ Template::render("boards", threads)
}
-// GET: Check out all threads within a board.
+/// GET: Check out all threads within a board.
#[get("/board/<board>")]
pub fn board(board: String) -> Template {
- let boards = serde_json::json!(get_boards().unwrap());
-
- let mut board_count: i32 = 0;
- for i in boards.as_array().unwrap() {
- if i.get("tag") == Some(&serde_json::json!(board)) {
- board_count += 1;
- }
- }
- if board_count == 0 { return Template::render("404", &()); }
-
- // Return 404 if the board is not found.
- // This doesn't work, but I kept it because I might try to fix it later.
- // if !boards.as_array().unwrap().contains(&serde_json::json!(board)) {
- // return Template::render("404", &());
- // }
-
- let context = get_threads(board).unwrap();
- let threads = serde_json::json!(&context);
- Template::render("threads", threads)
+ let boards = serde_json::json!(get_boards().unwrap());
+
+ let mut board_count: i32 = 0;
+ for i in boards.as_array().unwrap() {
+ if i.get("tag") == Some(&serde_json::json!(board)) {
+ board_count += 1;
+ }
+ }
+ if board_count == 0 { return Template::render("404", &()); }
+
+ // Return 404 if the board is not found.
+ // This doesn't work, but I kept it because I might try to fix it later.
+ // if !boards.as_array().unwrap().contains(&serde_json::json!(board)) {
+ // return Template::render("404", &());
+ // }
+
+ let context = get_threads(board).unwrap();
+ let threads = serde_json::json!(&context);
+ Template::render("threads", threads)
}