- Commit
- 4ae93aea777dc128ae12b77fe6d35cf43622d7dc
- Parent
- de1997a74eaf34ef10126688839e76cc79afc713
- Author
- Pablo <pablo-pie@riseup.net>
- Date
Baked the configuration options in yagit.1 at build-time
Yet another static site generator for Git 🙀️
Baked the configuration options in yagit.1 at build-time
5 files changed, 129 insertions, 12 deletions
Status | Name | Changes | Insertions | Deletions |
Modified | .gitignore | 2 files changed | 2 | 0 |
Modified | Cargo.toml | 2 files changed | 4 | 0 |
Added | build.rs | 1 file changed | 25 | 0 |
Added | src/yagit.1 | 1 file changed | 78 | 0 |
Modified | yagit.1 | 2 files changed | 20 | 12 |
diff --git a/.gitignore b/.gitignore @@ -3,6 +3,8 @@ /site Cargo.lock +yagit.1 + /profiling perf.data perf.data.old
diff --git a/Cargo.toml b/Cargo.toml @@ -3,6 +3,7 @@ name = "yagit" version = "0.1.0" edition = "2021" description = "Yet another static site generator for Git" +build = "build.rs" [dependencies] git2 = "0.20.0" @@ -10,5 +11,8 @@ libc = "0.2.170" pulldown-cmark = { version = "0.13.0", features = ["simd"] } static-toml = "1.3.0" +[build-dependencies] +static-toml = "1.3.0" + [profile.release] debug = true
diff --git /dev/null b/build.rs @@ -0,0 +1,25 @@ +use std::{fs::File, io::Write}; + +static_toml::static_toml! { + static CONFIG = include_toml!("config.toml"); +} + +const STORE_PATH: &str = CONFIG.git.release.store_path; +const PRIVATE_STORE_PATH: &str = CONFIG.git.release.private_store_path; +const OUTPUT_PATH: &str = CONFIG.output.release.path; +const PRIVATE_OUTPUT_ROOT: &str = CONFIG.output.private_output_root; + +const MAN_SRC: &str = include_str!("src/yagit.1"); + +fn main() { + let man_src = MAN_SRC + .replace("PRIVATE_STORE_PATH", PRIVATE_STORE_PATH) + .replace("STORE_PATH", STORE_PATH) + .replace("OUTPUT_PATH", OUTPUT_PATH) + .replace("PRIVATE_OUTPUT_ROOT", PRIVATE_OUTPUT_ROOT); + + let mut man_page = File::create("yagit.1") + .expect("Could not create \"yagit.1\""); + + write!(&mut man_page, "{}", man_src).expect("Could not write to \"yagit.1\""); +}
diff --git /dev/null b/src/yagit.1 @@ -0,0 +1,78 @@ +.Dd April 2, 2025 +.Dt yagit 1 +.Au Pablo +.Sh NAME +.Nm yagit +.Nd Yet another static site generator for Git +.Sh SYNOPSIS +.Nm +.Op Fl \-\-private +.Op Fl \-\-full\-build +render-batch +.Nm +.Op Fl \-\-private +.Op Fl \-\-full\-build +render +.Ar repo-name +.Nm +.Op Fl \-\-private +\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ init\ \ +.Ar repo-name +.Nm +.Op Fl \-\-private +\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ delete +.Ar repo-name +.Sh DESCRIPTION +.Nm +maintains a store of Git repositories at +.Ar STORE_PATH +and renders HTML pages for such repositories at the location +.Ar OUTPUT_PATH. + +By default, +.Nm +renders HTML pages in incremental mode: pages for Git +commits and blobs are only renderer if the relevant commits are newer than the +page's last modification date. This option can be disabled with the +.Fl --full-build +flag. + +.Nm +also maintains a store of Git repositories at +.Ar PRIVATE_STORE_PATH, +which can be switched on using the +.Fl --private +flag. The HTML pages for repositories at +.Ar PRIVATE_STORE_PATH +are rendered at +.Ar OUTPUT_PATH/PRIVATE_OUTPUT_ROOT +.Sh COMMANDS +.Bl -tag -width Ds +.It \fBrender\-batch\fR +Renders the HTML pages for all repositories at +.Ar STORE_PATH +and updates the index page +.It \fBrender\fR Ar repo\-name +Renders the HTML pages for a repository at +.Ar STORE_PATH/repo\-name +and updates the index page +.It \fBinit\fR Ar repo\-name Ar description +Initializes and configures a Git repo at +.Ar STORE_PATH/repo\-name +.It \fBdelete\fR Ar repo\-name +Deletes the Git repository at +.Ar STORE_PATH/repo\-name +and re-renders the global repository index +.El +.Sh FLAGS +.Bl -tag -width Ds +.It Fl --full-build +Disables incremental builds (re\-renders all HTML pages) +.It Fl --private +Use the +.Ar PRIVATE_STORE_PATH +store instead of +.Ar STORE_PATH +.El +.Sh AUTHORS +.An Pablo Aq Mt pablo-pie@riseup.net
diff --git a/yagit.1 b/yagit.1 @@ -18,12 +18,16 @@ render .Op Fl \-\-private \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ init\ \ .Ar repo-name +.Nm +.Op Fl \-\-private +\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ delete +.Ar repo-name .Sh DESCRIPTION .Nm maintains a store of Git repositories at -.Ar REPOS_DIR/ +.Ar /var/git/public and renders HTML pages for such repositories at the location -.Ar OUTPUT_DIR/. +.Ar /var/www/git. By default, .Nm @@ -35,26 +39,30 @@ flag. .Nm also maintains a store of Git repositories at -.Ar PRIVATE_REPOS_DIR/, +.Ar /var/git/private, which can be switched on using the .Fl --private flag. The HTML pages for repositories at -.Ar PRIVATE_REPOS_DIR/ +.Ar /var/git/private are rendered at -.Ar OUTPUT_PATH/PRIVATE_OUTPUT_ROOT/ +.Ar /var/www/git/private/ .Sh COMMANDS .Bl -tag -width Ds .It \fBrender\-batch\fR Renders the HTML pages for all repositories at -.Ar REPOS_DIR/ +.Ar /var/git/public and updates the index page .It \fBrender\fR Ar repo\-name Renders the HTML pages for a repository at -.Ar REPOS_DIR/repo\-name +.Ar /var/git/public/repo\-name and updates the index page -.It \fBinit\fR Ar repo\-name -Initializes a bare Git repo at -.Ar REPOS_DIR/repo\-name +.It \fBinit\fR Ar repo\-name Ar description +Initializes and configures a Git repo at +.Ar /var/git/public/repo\-name +.It \fBdelete\fR Ar repo\-name +Deletes the Git repository at +.Ar /var/git/public/repo\-name +and re-renders the global repository index .El .Sh FLAGS .Bl -tag -width Ds @@ -62,9 +70,9 @@ Initializes a bare Git repo at Disables incremental builds (re\-renders all HTML pages) .It Fl --private Use the -.Ar PRIVATE_REPOS_DIR/ +.Ar /var/git/private store instead of -.Ar REPOS_DIR/ +.Ar /var/git/public .El .Sh AUTHORS .An Pablo Aq Mt pablo-pie@riseup.net