Cleanup code
This commit is contained in:
parent
66da2274a7
commit
208cfe3608
1 changed files with 31 additions and 29 deletions
60
src/main.rs
60
src/main.rs
|
|
@ -20,36 +20,38 @@ fn main() {
|
||||||
let js = include_bytes!("project-card.js");
|
let js = include_bytes!("project-card.js");
|
||||||
rouille::Response::from_data("application/javascript", js.as_ref())
|
rouille::Response::from_data("application/javascript", js.as_ref())
|
||||||
},
|
},
|
||||||
(GET) ["/projects"] => {
|
(GET) ["/projects"] => display_projects(),
|
||||||
let projects = db::list_all_projects().unwrap_or_default();
|
|
||||||
|
|
||||||
let markup = html! {
|
|
||||||
(DOCTYPE)
|
|
||||||
html {
|
|
||||||
head {
|
|
||||||
meta charset="utf-8";
|
|
||||||
meta name="viewport" content="width=device-width, initial-scale=1";
|
|
||||||
link rel="stylesheet" href="/main.css";
|
|
||||||
script src="/project-card.js" {}
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
main {
|
|
||||||
section {
|
|
||||||
@for project in &projects {
|
|
||||||
project-card
|
|
||||||
title=(project.title)
|
|
||||||
percentage=(project.percentage_completed)
|
|
||||||
archived=(project.archived) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
rouille::Response::html(markup.into_string())
|
|
||||||
},
|
|
||||||
_ => rouille::Response::empty_404()
|
_ => rouille::Response::empty_404()
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn display_projects() -> rouille::Response {
|
||||||
|
let projects = db::list_all_projects().unwrap_or_default();
|
||||||
|
|
||||||
|
let markup = html! {
|
||||||
|
(DOCTYPE)
|
||||||
|
html {
|
||||||
|
head {
|
||||||
|
meta charset="utf-8";
|
||||||
|
meta name="viewport" content="width=device-width, initial-scale=1";
|
||||||
|
link rel="stylesheet" href="/main.css";
|
||||||
|
script src="/project-card.js" {}
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
main {
|
||||||
|
section {
|
||||||
|
@for project in &projects {
|
||||||
|
project-card
|
||||||
|
title=(project.title)
|
||||||
|
percentage=(project.percentage_completed)
|
||||||
|
archived=(project.archived) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
rouille::Response::html(markup.into_string())
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue