- Commit
- 8f5bfd0d4321dd1c384463ed134c017c31c48ffe
- Parent
- 63217da2a0ed5d3ee04cb88cc5fb7735762b1c84
- Author
- Pablo <pablo-pie@riseup.net>
- Date
Restructure the index
Restructure the cards in the index page, removing the "author" field
Yet another static site generator for Git 🙀️
Restructure the index
Restructure the cards in the index page, removing the "author" field
3 files changed, 7 insertions, 44 deletions
| Status | Name | Changes | Insertions | Deletions |
| Modified | config.toml | 2 files changed | 0 | 1 |
| Modified | src/config.rs | 2 files changed | 0 | 1 |
| Modified | src/main.rs | 2 files changed | 7 | 42 |
diff --git a/config.toml b/config.toml @@ -9,5 +9,4 @@ group_id = 33 # group ID for the output directories [git] store_path = "/var/git/public" # path to the public repo store private_store_path = "/var/git/private" # path to the private repo store -store_owner = "Pablo" user = "git"
diff --git a/src/config.rs b/src/config.rs @@ -20,7 +20,6 @@ pub const GROUP_ID: u32 = CONFIG.output.group_id as u32; #[cfg(not(debug_assertions))] pub const GIT_USER: &str = CONFIG.git.user; -pub const OWNER: &str = CONFIG.git.store_owner; #[cfg(debug_assertions)] pub const STORE_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/test/public");
diff --git a/src/main.rs b/src/main.rs @@ -1,7 +1,6 @@ use std::{ io::{self, Read, Write}, fs::{self, File}, - os::unix, path::{Path, PathBuf}, mem, env, @@ -39,7 +38,7 @@ use config::{ use escape::Escaped; #[cfg(not(debug_assertions))] -use std::borrow::Cow; +use std::{borrow::Cow, os::unix}; #[macro_use] mod log; @@ -56,16 +55,15 @@ const LICENSE_NAME: &str = "LICENSE"; #[derive(Clone, Copy, Debug, PartialEq, Eq)] enum PageTitle<'a> { Index, - Summary { repo_name: &'a str }, - Log { repo_name: &'a str }, - TreeEntry { repo_name: &'a str, path: &'a Path, }, - Commit { repo_name: &'a str, summary: &'a str }, - License { repo_name: &'a str }, + Summary { repo_name: &'a str, }, + Log { repo_name: &'a str, }, + TreeEntry { repo_name: &'a str, path: &'a Path, }, + Commit { repo_name: &'a str, summary: &'a str, }, + License { repo_name: &'a str, }, } struct RepoInfo { pub name: String, - pub owner: String, pub description: Option<String>, pub repo: Repository, @@ -117,28 +115,6 @@ impl RepoInfo { return Err(()); } - let owner = { - let mut owner_path = path.clone(); - if !repo.is_bare() { owner_path.push(".git"); } - owner_path.push("owner"); - - let mut owner = String::with_capacity(32); - let read = File::open(owner_path) - .map(|mut f| f.read_to_string(&mut owner)); - - match read { - Ok(Ok(_)) => owner, - Ok(Err(e)) => { - errorln!("Could not read the owner of {path:?}: {e}"); - return Err(()); - } - Err(e) => { - errorln!("Could not read the owner of {path:?}: {e}"); - return Err(()); - } - } - }; - let description = { let mut dsc_path = path.clone(); if !repo.is_bare() { dsc_path.push(".git"); } @@ -163,7 +139,6 @@ impl RepoInfo { Ok(Self { name: String::from(name.as_ref()), - owner, description, repo, first_commit, @@ -197,8 +172,7 @@ impl RepoInfo { } } - result.sort_by(|r1, r2| r2.first_commit.cmp(&r1.first_commit)); - + result.sort_by_key(|r| cmp::Reverse(r.first_commit)); Ok(result) } Err(e) => { @@ -1428,7 +1402,6 @@ fn render_index(repos: &[RepoInfo], private: bool) -> io::Result<()> { writeln!(&mut f, "</h4>")?; writeln!(&mut f, "<div>")?; - writeln!(&mut f, "<span>{owner}</span>", owner = Escaped(&repo.owner))?; writeln!(&mut f, "<time datetime=\"{datetime}\">{date}</time>", datetime = DateTime(repo.last_commit), date = Date(repo.last_commit))?; @@ -1462,14 +1435,6 @@ fn setup_repo( path.push(".git"); // ========================================================================== - let mut owner_path = path.clone(); - owner_path.push("owner"); - - let mut owner_f = create_file(owner_path)?; - - write!(&mut owner_f, "{}", config::OWNER.trim())?; - - // ========================================================================== let mut dsc_path = path.clone(); dsc_path.push("description");