diff options
Diffstat (limited to '')
-rw-r--r-- | src/pages/repo/about.rs | 33 | ||||
-rw-r--r-- | src/pages/repo/details.rs | 50 | ||||
-rw-r--r-- | src/pages/repo/mod.rs | 8 |
3 files changed, 38 insertions, 53 deletions
diff --git a/src/pages/repo/about.rs b/src/pages/repo/about.rs index fa88eb1..1f207e2 100644 --- a/src/pages/repo/about.rs +++ b/src/pages/repo/about.rs @@ -1,32 +1,23 @@ -use super::RepoWrapper; -use crate::types::RepoData; +use crate::templ_data::repo::*; use actix_web::{web, HttpRequest, HttpResponse, Result}; use askama::Template; -#[derive(Template)] -#[template(path = "repo/about.html")] -struct AboutRepo { - repo: RepoWrapper, - readme: String, -} - /// Renders the "repository/about" subpage pub async fn render(req: HttpRequest, path: web::Path<String>) -> Result<HttpResponse> { - let repo = AboutRepo { + let repo = pages::About { readme: include_str!("../../../README").to_string(), - repo: RepoWrapper { - data: RepoData { - owner: "spacekookie".into(), - name: "octopus".into(), - tagline: "A lightweight web frontend for git repositories".into(), - num_commit: 141, - num_branch: 1, - num_tag: 0, - num_contributor: 3, - size: "13.12M".into(), - }, + repo: RepoData { + owner: "spacekookie".into(), + name: "octopus".into(), + tagline: "A lightweight web frontend for git repositories".into(), + num_commit: 141, + num_branch: 1, + num_tag: 0, + num_contributor: 3, + size: "13.12M".into(), logo: "fakeavi.png".into(), }, + base: Default::default(), } .render() .unwrap(); diff --git a/src/pages/repo/details.rs b/src/pages/repo/details.rs index 4745e96..d5822d6 100644 --- a/src/pages/repo/details.rs +++ b/src/pages/repo/details.rs @@ -1,34 +1,36 @@ -use super::RepoWrapper; -use crate::types::{BranchData, CommitData, RepoData}; +use crate::templ_data::repo::*; use actix_web::{web, HttpRequest, HttpResponse, Result}; use askama::Template; -#[derive(Template)] -#[template(path = "repo/details.html")] -struct AboutRepo { - repo: RepoWrapper, - branches: Vec<BranchData>, - commits: Vec<CommitData>, -} - /// Renders the "repository/about" subpage pub async fn render(req: HttpRequest, path: web::Path<String>) -> Result<HttpResponse> { - let repo = AboutRepo { - branches: vec![], - commits: vec![], - repo: RepoWrapper { - data: RepoData { - owner: "spacekookie".into(), - name: "octopus".into(), - tagline: "A lightweight web frontend for git repositories".into(), - num_commit: 141, - num_branch: 1, - num_tag: 0, - num_contributor: 3, - size: "13.12M".into(), - }, + let last_commit = CommitData { + hash: "84a9a0".into(), + message: "Updating just like... a bunch of shit".into(), + author: "Katharina Fey".into(), + date: "Today".into(), + diff: (125, 55) + }; + + let repo = pages::Details { + branches: vec![ BranchData { + name: "develop".into(), + last_commit: last_commit.clone(), + } + ], + commits: vec![ last_commit ], + repo: RepoData { + owner: "spacekookie".into(), + name: "octopus".into(), + tagline: "A lightweight web frontend for git repositories".into(), + num_commit: 141, + num_branch: 1, + num_tag: 0, + num_contributor: 3, + size: "13.12M".into(), logo: "fakeavi.png".into(), }, + base: Default::default(), } .render() .unwrap(); diff --git a/src/pages/repo/mod.rs b/src/pages/repo/mod.rs index 7d90c97..2b93592 100644 --- a/src/pages/repo/mod.rs +++ b/src/pages/repo/mod.rs @@ -5,11 +5,3 @@ mod details; pub use about::render as about; pub use details::render as details; - -use crate::types::RepoData; - -/// A template wrapper for repository data -pub(self) struct RepoWrapper { - pub(self) data: RepoData, - pub(self) logo: String, -} |