diff options
author | Katharina Fey <kookie@spacekookie.de> | 2019-12-28 23:58:14 +0100 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2019-12-28 23:58:14 +0100 |
commit | 81ae20b5a0bca84166076d91b8b32a19d2d451ae (patch) | |
tree | 54de2fed2f08ff7f65eb709686f72d76bd34ad66 /src/pages | |
parent | baf496acf0640fecdc01864989f2142a9757ba14 (diff) |
Refactoring basic project structure
Diffstat (limited to 'src/pages')
-rw-r--r-- | src/pages/mod.rs | 6 | ||||
-rw-r--r-- | src/pages/repo.rs | 36 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/pages/mod.rs b/src/pages/mod.rs new file mode 100644 index 0000000..9de9d47 --- /dev/null +++ b/src/pages/mod.rs @@ -0,0 +1,6 @@ +//! All the pages in webgit +//! +//! A page is defined by it's template type as well as it's route, +//! which is exported from the module and then called by the router + +pub mod repo; diff --git a/src/pages/repo.rs b/src/pages/repo.rs new file mode 100644 index 0000000..aa66839 --- /dev/null +++ b/src/pages/repo.rs @@ -0,0 +1,36 @@ +//! The view that renders a repository + +use actix_web::{web, HttpRequest, HttpResponse, Result}; +use askama::Template; + +#[derive(Template)] +#[template(path = "repo.html")] +struct Repo<'a> { + project_owner: &'a str, + project_summary: &'a str, + project_name: &'a str, + project_logo: &'a str, + project_logo_alt_text: &'a str, + first_commit: &'a str, + num_commits: usize, + num_contributors: usize, +} + +pub fn render(req: HttpRequest, path: web::Path<(String)>) -> Result<HttpResponse> { + println!("Rendering path: {:#?}", path); + dbg!(req); + + let repo = Repo { + project_owner: "spacekookie", + project_summary: "A lightweight web frontend for git repositories", + project_name: "webgit", + project_logo: "rust.png", + project_logo_alt_text: "Rust logo", + first_commit: "f6ca929", + num_commits: 123, + num_contributors: 3, + } + .render() + .unwrap(); + Ok(HttpResponse::Ok().content_type("text/html").body(repo)) +} |