diff options
author | Katharina Fey <kookie@spacekookie.de> | 2020-10-31 18:57:39 +0100 |
---|---|---|
committer | Mx Kookie <kookie@spacekookie.de> | 2020-12-21 05:10:08 +0100 |
commit | 9dacf748651ea7139c0e9f3dee9ae66d949bf73f (patch) | |
tree | 7101bc20d5a531218ccd1b4cb9e04c67995f6d0e /apps/servers/octopus/src/pages | |
parent | 4e09fe2509904ee64d2470ca8d41006d51e4ffd6 (diff) |
Add 'apps/servers/octopus/' from commit '623954d19fdf0dca47db319e5c88ee561aa8d25c'
git-subtree-dir: apps/servers/octopus
git-subtree-mainline: 4e09fe2509904ee64d2470ca8d41006d51e4ffd6
git-subtree-split: 623954d19fdf0dca47db319e5c88ee561aa8d25c
Diffstat (limited to 'apps/servers/octopus/src/pages')
-rw-r--r-- | apps/servers/octopus/src/pages/files.rs | 20 | ||||
-rw-r--r-- | apps/servers/octopus/src/pages/mod.rs | 15 | ||||
-rw-r--r-- | apps/servers/octopus/src/pages/overview.rs | 24 | ||||
-rw-r--r-- | apps/servers/octopus/src/pages/p404.rs | 13 | ||||
-rw-r--r-- | apps/servers/octopus/src/pages/repo/about.rs | 26 | ||||
-rw-r--r-- | apps/servers/octopus/src/pages/repo/details.rs | 38 | ||||
-rw-r--r-- | apps/servers/octopus/src/pages/repo/mod.rs | 7 |
7 files changed, 143 insertions, 0 deletions
diff --git a/apps/servers/octopus/src/pages/files.rs b/apps/servers/octopus/src/pages/files.rs new file mode 100644 index 000000000000..73a86a46918e --- /dev/null +++ b/apps/servers/octopus/src/pages/files.rs @@ -0,0 +1,20 @@ +//! The main file browser + +use crate::templ_data::{files::Files, BaseData}; +use actix_web::{web, HttpRequest, HttpResponse, Result}; +use askama::Template; + +pub async fn render(req: HttpRequest) -> Result<HttpResponse> { + let files = Files { + base: BaseData { + sitename: "dev.spacekookie.de".into(), + ..BaseData::default() + }, + readme: None, + path: "".into(), + } + .render() + .unwrap(); + + Ok(HttpResponse::Ok().content_type("text/html").body(files)) +} diff --git a/apps/servers/octopus/src/pages/mod.rs b/apps/servers/octopus/src/pages/mod.rs new file mode 100644 index 000000000000..2f1ed579c9a9 --- /dev/null +++ b/apps/servers/octopus/src/pages/mod.rs @@ -0,0 +1,15 @@ +//! 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; + +mod overview; +pub use overview::render as overview; + +mod p404; +pub use p404::render as p404; + +mod files; +pub use files::render as files; diff --git a/apps/servers/octopus/src/pages/overview.rs b/apps/servers/octopus/src/pages/overview.rs new file mode 100644 index 000000000000..ca8c9b37064c --- /dev/null +++ b/apps/servers/octopus/src/pages/overview.rs @@ -0,0 +1,24 @@ +//! Overview page +//! +//! This is the first page a user sees when they just go to the site +//! root. It renders the `README`, or `README.md` file from the modo +//! repo root, to provide users with a starting point. + +use crate::templ_data::{overview::Index, BaseData}; +use actix_web::{web, HttpRequest, HttpResponse, Result}; +use askama::Template; + +pub async fn render(req: HttpRequest) -> Result<HttpResponse> { + let readme: String = markdown::to_html(include_str!("../../fake-readme.md").into()); + + let index = Index { + base: BaseData { + sitename: "dev.spacekookie.de".into(), + ..BaseData::default() + }, + readme, + } + .render() + .unwrap(); + Ok(HttpResponse::Ok().content_type("text/html").body(index)) +} diff --git a/apps/servers/octopus/src/pages/p404.rs b/apps/servers/octopus/src/pages/p404.rs new file mode 100644 index 000000000000..6427a19c60b7 --- /dev/null +++ b/apps/servers/octopus/src/pages/p404.rs @@ -0,0 +1,13 @@ +use actix_web::{HttpResponse, Result}; +use askama::Template; + +#[derive(Template)] +#[template(path = "404.html")] +struct P404; + +/// Render a simple 404 page +pub async fn render() -> Result<HttpResponse> { + Ok(HttpResponse::NotFound() + .content_type("text/html") + .body(P404.render().unwrap())) +} diff --git a/apps/servers/octopus/src/pages/repo/about.rs b/apps/servers/octopus/src/pages/repo/about.rs new file mode 100644 index 000000000000..1f207e2d56a5 --- /dev/null +++ b/apps/servers/octopus/src/pages/repo/about.rs @@ -0,0 +1,26 @@ +use crate::templ_data::repo::*; +use actix_web::{web, HttpRequest, HttpResponse, Result}; +use askama::Template; + +/// Renders the "repository/about" subpage +pub async fn render(req: HttpRequest, path: web::Path<String>) -> Result<HttpResponse> { + let repo = pages::About { + readme: include_str!("../../../README").to_string(), + 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(); + + Ok(HttpResponse::Ok().content_type("text/html").body(repo)) +} diff --git a/apps/servers/octopus/src/pages/repo/details.rs b/apps/servers/octopus/src/pages/repo/details.rs new file mode 100644 index 000000000000..7298e15af4b8 --- /dev/null +++ b/apps/servers/octopus/src/pages/repo/details.rs @@ -0,0 +1,38 @@ +use crate::templ_data::repo::*; +use actix_web::{web, HttpRequest, HttpResponse, Result}; +use askama::Template; + +/// Renders the "repository/about" subpage +pub async fn render(req: HttpRequest, path: web::Path<String>) -> Result<HttpResponse> { + 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(); + + Ok(HttpResponse::Ok().content_type("text/html").body(repo)) +} diff --git a/apps/servers/octopus/src/pages/repo/mod.rs b/apps/servers/octopus/src/pages/repo/mod.rs new file mode 100644 index 000000000000..2b93592624ac --- /dev/null +++ b/apps/servers/octopus/src/pages/repo/mod.rs @@ -0,0 +1,7 @@ +//! The repository page subtree + +mod about; +mod details; + +pub use about::render as about; +pub use details::render as details; |