💾 Archived View for lists.flounder.online › patches › threads › 20210316220018.8546-2-johann@qwertqw… captured on 2022-04-28 at 19:25:15. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
From: johann@qwertqwefsday.eu
Date: Tue, 16 Mar 2021 23:00:16 +0100
Message-Id: 20210316220018.8546-2-johann@qwertqwefsday.eu
To: <~aw/patches@lists.sr.ht>
In-Reply-To: 20210316220018.8546-1-johann@qwertqwefsday.eu
Cc: "Johann150" <johann@qwertqwefsday.eu>
--------------------------------------
From: Johann150 <johann@qwertqwefsday.eu>
As said on the mailing list earlier, I think it would be nice to be
more or less compatible with gitweb since others also orient themselves
on this. One point about this would be to use the same configuration
option names. Of course not all of them are good, e.g. projectroot
does not follow the naming convention, so we might want to change that.
Docs for gitweb config are at <https://git-scm.com/docs/gitweb.conf>.
---
mygit.toml | 7 ++++---
src/main.rs | 10 ++++++----
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/mygit.toml b/mygit.toml
index 63b2292..8b25b45 100644
--- a/mygit.toml
+++ b/mygit.toml
@@ -1,5 +1,6 @@
port = 8081
-# Directory to store git repos
-repo_directory = "repos"
+# Directory to find git repos
+projectroot = "repos"
emoji_favicon = "💻"
-page_title = "My git repositories"
+site_name = "My git repositories"
+export_ok = "git-daemon-export-ok"
diff --git a/src/main.rs b/src/main.rs
index 342248f..a19fd07 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -13,8 +13,10 @@ use tide::Request;
#[derive(Deserialize, Debug)]
pub struct Config {
port: u16,
- repo_directory: String,
+ projectroot: String,
emoji_favicon: String,
+ site_name: String,
+ export_ok: String,
}
const HELP: &str = "\
@@ -56,14 +58,14 @@ struct IndexTemplate {
}
async fn index(req: Request<()>) -> tide::Result {
- let repos = fs::read_dir(&CONFIG.repo_directory)
+ let repos = fs::read_dir(&CONFIG.projectroot)
.map(|entries| {
entries
.filter_map(|entry| Some(entry.ok()?.path()))
.filter(|entry| {
// check for the export file
let mut path = entry.clone();
- path.push("git-daemon-export-ok");
+ path.push(&CONFIG.export_ok);
path.exists()
})
.filter_map(|entry| Repository::open(entry).ok())
@@ -93,7 +95,7 @@ fn repo_from_request(repo_name: &str) -> Result<Repository> {
let repo_name = percent_encoding::percent_decode_str(repo_name)
.decode_utf8_lossy()
.into_owned();
- let repo_path = Path::new(&CONFIG.repo_directory).join(repo_name);
+ let repo_path = Path::new(&CONFIG.projectroot).join(repo_name);
// TODO CLEAN PATH! VERY IMPORTANT! DONT FORGET!
let r = Repository::open(repo_path)?;
Ok(r)
--
2.20.1