aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock102
-rw-r--r--Cargo.toml1
-rw-r--r--README2
-rw-r--r--shell.nix4
-rw-r--r--src/main.rs89
-rw-r--r--src/pages/mod.rs6
-rw-r--r--src/pages/repo.rs36
-rw-r--r--src/repo.rs45
8 files changed, 209 insertions, 76 deletions
diff --git a/Cargo.lock b/Cargo.lock
index c6c9fc7..5948b12 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -431,6 +431,10 @@ dependencies = [
name = "cc"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "jobserver 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
[[package]]
name = "cfg-if"
@@ -621,6 +625,20 @@ dependencies = [
]
[[package]]
+name = "git2"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libgit2-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "h2"
version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -744,6 +762,16 @@ version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "jobserver"
+version = "0.1.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "kernel32-sys"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -768,6 +796,43 @@ version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "libgit2-sys"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libssh2-sys 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "libssh2-sys"
+version = "0.2.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
+ "vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "libz-sys"
+version = "1.0.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
+ "vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "linked-hash-map"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -926,6 +991,23 @@ dependencies = [
]
[[package]]
+name = "openssl-probe"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "openssl-sys"
+version = "0.9.53"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
+ "vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "parking_lot"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -960,6 +1042,11 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "pkg-config"
+version = "0.3.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "ppv-lite86"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1629,6 +1716,11 @@ dependencies = [
]
[[package]]
+name = "vcpkg"
+version = "0.2.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "version_check"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1651,6 +1743,7 @@ dependencies = [
"actix-web 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
"askama 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "git2 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1788,6 +1881,7 @@ dependencies = [
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
"checksum futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef"
"checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407"
+"checksum git2 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "77519ef7c5beee314d0804d4534f01e0f9e8d9acdee2b7a48627e590b27e0ec4"
"checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462"
"checksum hashbrown 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead"
"checksum hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120"
@@ -1802,10 +1896,14 @@ dependencies = [
"checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
"checksum ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa79fa216fbe60834a9c0737d7fcd30425b32d1c58854663e24d4c4b328ed83f"
"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
+"checksum jobserver 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b1d42ef453b30b7387e113da1c83ab1605d90c5b4e0eb8e96d016ed3b8c160"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a"
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8"
+"checksum libgit2-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9ec6bca50549d34a392611dde775123086acbd994e3fff64954777ce2dc2e51"
+"checksum libssh2-sys 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "5fcd5a428a31cbbfe059812d74f4b6cd3b9b7426c2bdaec56993c5365da1c328"
+"checksum libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe"
"checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83"
"checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc"
"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
@@ -1825,10 +1923,13 @@ dependencies = [
"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09"
"checksum num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "443c53b3c3531dfcbfa499d8893944db78474ad7a1d87fa2d94d1a2231693ac6"
"checksum num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72"
+"checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
+"checksum openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)" = "465d16ae7fc0e313318f7de5cecf57b2fbe7511fd213978b457e1c96ff46736f"
"checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252"
"checksum parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b"
"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
"checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
+"checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
"checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"
"checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5"
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
@@ -1902,6 +2003,7 @@ dependencies = [
"checksum v_escape 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "660b101c07b5d0863deb9e7fb3138777e858d6d2a79f9e6049a27d1cc77c6da6"
"checksum v_escape_derive 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c2ca2a14bc3fc5b64d188b087a7d3a927df87b152e941ccfbc66672e20c467ae"
"checksum v_htmlescape 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e33e939c0d8cf047514fb6ba7d5aac78bc56677a6938b2ee67000b91f2e97e41"
+"checksum vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168"
"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
"checksum version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce"
"checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d"
diff --git a/Cargo.toml b/Cargo.toml
index f21eac1..7b19748 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,6 +10,7 @@ actix-files = "0.1.7"
actix-web = "1.0.0"
askama = "0.8"
env_logger = "0.6"
+git2 = "0.11"
[build-dependencies]
askama = "0.8" \ No newline at end of file
diff --git a/README b/README
index 2a5500c..71e5eed 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
webgit
======
-A git hosting tool. Check my public inbox for a detailed vision. \ No newline at end of file
+The friendly and simple git web interface. \ No newline at end of file
diff --git a/shell.nix b/shell.nix
index 571ba07..aefc493 100644
--- a/shell.nix
+++ b/shell.nix
@@ -3,6 +3,8 @@ with import <nixpkgs> {};
stdenv.mkDerivation {
name = "webgit";
buildInputs = with pkgs; [
- rustracer rustup clangStdenv cargo-watch python3
+ rustracer rustup clangStdenv
+
+ cargo-watch openssl pkg-config
];
}
diff --git a/src/main.rs b/src/main.rs
index 44588b2..77288a7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,78 +1,19 @@
-use actix_files as fs;
-use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer, Result};
-use askama::Template;
-
-/// Represents a repository on disk
-struct Repository {
- /// We need to be able to query libgit2 later
- fs_path: String,
- /// The project name (last path element)
- name: String,
- /// The rope path excluding the name
- path: Vec<String>,
-}
-
-impl Repository {
- /// Returns a list of commit hashes for a project
- fn commits(&self) -> Vec<String> {
- vec!["f6ca929", "43fb776", "1a0fa2f".into()]
- .into_iter()
- .map(String::from)
- .collect()
- }
-
- /// Return the list of contributors
- fn contributors(&self) -> Vec<String> {
- vec![
- "Katharina Fey <kookie@spacekookie.de",
- "Robin Example <robin@example.com",
- "Ferris <ferris@the.crab>",
- ]
- .into_iter()
- .map(String::from)
- .collect()
- }
-}
-
-#[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,
-}
-
-fn repo(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))
-}
+mod pages;
+mod repo;
fn main() -> std::io::Result<()> {
+ // use actix_files as fs;
+ // use actix_web::{web, App, HttpServer};
+
// start http server
- HttpServer::new(move || {
- App::new()
- .service(fs::Files::new("/static", "static"))
- .service(web::resource("/{repo}").route(web::get().to(repo)))
- })
- .bind("127.0.0.1:8080")?
- .run()
+ // HttpServer::new(move || {
+ // App::new()
+ // .service(fs::Files::new("/static", "static"))
+ // .service(web::resource("/{repo}").route(web::get().to(pages::repo::render)))
+ // })
+ // .bind("127.0.0.1:8080")?
+ // .run()?;
+
+ //let r = repo::Repo::new("./test");
+ Ok(())
}
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))
+}
diff --git a/src/repo.rs b/src/repo.rs
index e69de29..0056575 100644
--- a/src/repo.rs
+++ b/src/repo.rs
@@ -0,0 +1,45 @@
+use git2::Repository;
+
+
+// /// Represents a repository on disk
+// struct Repository {
+// /// We need to be able to query libgit2 later
+// fs_path: String,
+// /// The project name (last path element)
+// name: String,
+// /// The rope path excluding the name
+// path: Vec<String>,
+// }
+
+/// A structure that represents an existing bare repo on disk
+pub struct Repo {
+ pub inner: Repository,
+}
+
+impl Repo {
+ pub fn new(path: &'static str) -> Self {
+ Self {
+ inner: Repository::open_bare(path).unwrap(),
+ }
+ }
+
+ /// Returns a list of commit hashes for a project
+ pub fn commits(&self) -> Vec<String> {
+ vec!["f6ca929", "43fb776", "1a0fa2f".into()]
+ .into_iter()
+ .map(String::from)
+ .collect()
+ }
+
+ /// Return the list of contributors
+ fn contributors(&self) -> Vec<String> {
+ vec![
+ "Katharina Fey <kookie@spacekookie.de",
+ "Robin Example <robin@example.com",
+ "Ferris <ferris@the.crab>",
+ ]
+ .into_iter()
+ .map(String::from)
+ .collect()
+ }
+}