diff --git a/README.md b/README.md index 67e537c..fab189e 100644 --- a/README.md +++ b/README.md @@ -28,11 +28,12 @@ To use it with your repos, please note the following. REPO_DIR=/repositories ``` -3. A `config.toml` file also needs to be created and placed at `$HOME/.config/config`. Within the `config.toml` there must be a list of namespace dirs and repo dirs which are allowed to be served. +3. A `config.toml` file also needs to be created and placed at `$HOME/.config/config`. Within the `config.toml` there must be a list of namespace dirs and repo dirs which are allowed to be served, and a title, which may be left blank if unneeded. ``` # $HOME/.config/config/config.toml allowed = allowed = ["masalachai", "masalachai/gemini-git-browser"] +title = "" ``` One the `REPO_DIR` variable and `config.toml` file is set, executing the binary should serve the repos at the gemini port. diff --git a/deploy/environments/development/assets/config.toml b/deploy/environments/development/assets/config.toml index c6ea325..8703201 100644 --- a/deploy/environments/development/assets/config.toml +++ b/deploy/environments/development/assets/config.toml @@ -1 +1,2 @@ -allowed = ["repo-ns", "repo-ns/sample.git"] \ No newline at end of file +allowed = ["repo-ns", "repo-ns/sample.git"] +title = "Demo" \ No newline at end of file diff --git a/deploy/environments/production/assets/config.toml b/deploy/environments/production/assets/config.toml index 1313218..26294ec 100644 --- a/deploy/environments/production/assets/config.toml +++ b/deploy/environments/production/assets/config.toml @@ -1 +1,2 @@ -allowed = ["chitlangi", "ritesh", "chitlangi/ritesh.ch.git", "chitlangi/gemini-git-browser.git", "ritesh/epp-rtk-java-extensions.git", "ritesh/epp-rtk-java-extras.git", "ritesh/deploy-scripts.git", "ritesh/gemini-git-browser.git"] \ No newline at end of file +allowed = ["chitlangi", "ritesh", "chitlangi/ritesh.ch.git", "chitlangi/gemini-git-browser.git", "ritesh/epp-rtk-java-extensions.git", "ritesh/epp-rtk-java-extras.git", "ritesh/deploy-scripts.git", "ritesh/gemini-git-browser.git"] +title = "Ritesh Chitlangi -" \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 70e9360..ab10674 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,7 +77,7 @@ pub mod actions { let repos = repo::REPO_DIR.get_ns_repos(path).unwrap(); let repo_list = serde_json::to_value(&repos).unwrap(); - get_html("ns", "./templates/ns.hbs", &json!({"ns": path, "repos": &repo_list})).await + get_html("ns", "./templates/ns.hbs", &json!({"title": repo::REPO_DIR.config.title, "ns": path, "repos": &repo_list})).await } async fn get_page(request: Request) -> anyhow::Result { @@ -115,7 +115,7 @@ pub mod actions { let repos_json = serde_json::to_value(&repos).unwrap(); - get_html("index", "./templates/index.hbs", &repos_json).await + get_html("index", "./templates/index.hbs", &json!({"title": repo::REPO_DIR.config.title, "repos": repos_json})).await } else { get_page(request).await } diff --git a/src/repo.rs b/src/repo.rs index f5c69df..ab5efe1 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -33,7 +33,7 @@ pub struct RepoDetails { pub struct RepoDir { dir_path: String, - config: util::Config, + pub config: util::Config, } pub struct Repo<'a> { diff --git a/src/util.rs b/src/util.rs index a600ac4..591e729 100644 --- a/src/util.rs +++ b/src/util.rs @@ -3,12 +3,16 @@ use std::{error::Error, fs, path::Path}; #[derive(Serialize, Deserialize, Debug)] pub struct Config { + pub title: String, pub allowed: Vec, } impl ::std::default::Default for Config { fn default() -> Self { - Self { allowed: vec![] } + Self { + title: String::from(""), + allowed: vec![], + } } } diff --git a/templates/index.hbs b/templates/index.hbs index 8b08f9d..023e886 100644 --- a/templates/index.hbs +++ b/templates/index.hbs @@ -1,8 +1,8 @@ -# Gemini Git Browser +# {{title}} Gemini Git Browser ## Repositories -{{#each this as |value key|}} +{{#each repos as |value key|}} {{#each value}} => /{{key}}/{{this}} 📚{{key}}/{{this}} {{/each}} diff --git a/templates/ns.hbs b/templates/ns.hbs index 69c0138..01aa637 100644 --- a/templates/ns.hbs +++ b/templates/ns.hbs @@ -1,4 +1,4 @@ -# Gemini Git Browser +# {{ ns }} - Gemini Git Browser ## Repositories diff --git a/templates/repo.hbs b/templates/repo.hbs index efdaf8b..4a464a4 100644 --- a/templates/repo.hbs +++ b/templates/repo.hbs @@ -1,8 +1,11 @@ +# {{ path }} - Gemini Git Browser + ## Branches {{#each details.branches}} => /{{ ../path }}/branch/{{ this }} 🎋 {{ this }} {{/each}} + ## Tree {{#each details.tree}} => /{{ ../path }}/{{ this.item_type }}/{{ this.id }} {{ this.icon }} {{ this.name }}