Skip to content

Commit

Permalink
added a title to some pages
Browse files Browse the repository at this point in the history
  • Loading branch information
masalachai committed Jul 10, 2021
1 parent 237eb14 commit 486f867
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 10 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion deploy/environments/development/assets/config.toml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
allowed = ["repo-ns", "repo-ns/sample.git"]
allowed = ["repo-ns", "repo-ns/sample.git"]
title = "Demo"
3 changes: 2 additions & 1 deletion deploy/environments/production/assets/config.toml
Original file line number Diff line number Diff line change
@@ -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"]
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 -"
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Response> {
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct RepoDetails {

pub struct RepoDir {
dir_path: String,
config: util::Config,
pub config: util::Config,
}

pub struct Repo<'a> {
Expand Down
6 changes: 5 additions & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ use std::{error::Error, fs, path::Path};

#[derive(Serialize, Deserialize, Debug)]
pub struct Config {
pub title: String,
pub allowed: Vec<String>,
}

impl ::std::default::Default for Config {
fn default() -> Self {
Self { allowed: vec![] }
Self {
title: String::from(""),
allowed: vec![],
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions templates/index.hbs
Original file line number Diff line number Diff line change
@@ -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}}
Expand Down
2 changes: 1 addition & 1 deletion templates/ns.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Gemini Git Browser
# {{ ns }} - Gemini Git Browser

## Repositories

Expand Down
3 changes: 3 additions & 0 deletions templates/repo.hbs
Original file line number Diff line number Diff line change
@@ -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 }}
Expand Down

0 comments on commit 486f867

Please sign in to comment.