From f3bffc527d5f7a440da642f8c9e3a171b81153f2 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Mon, 6 Jan 2025 13:51:03 -0300 Subject: m --- src/gistatic.in | 641 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 325 insertions(+), 316 deletions(-) (limited to 'src/gistatic.in') diff --git a/src/gistatic.in b/src/gistatic.in index 21980a5..f3cb2d6 100755 --- a/src/gistatic.in +++ b/src/gistatic.in @@ -21,7 +21,7 @@ See "man gistatic" for more information.' MSG_MISSING_CLIARG_EN='Missing %s' MSG_INCOMPATIBLE_OPTIONS_EN='Incompatible options: ' -MSG_MISSING_ARGS_EN='[PATH | [PATHS]]' +MSG_MISSING_ARGS_EN='REPOSITORY' MSG_LANGNAME_EN='en' MSG_INDEX_DESCRIPTION_EN='Index of repositories' MSG_DEFAULT_TITLE_EN='Repositories' @@ -105,9 +105,13 @@ tac() { } escape() { - echo "$1" | - sed -e 's|&|\&|g;s|<|\<|g;s|>|\>|g;s|"|\"|g' \ - -e "s|'|\'|g" + printf '%s' "$1" | + sed \ + -e 's|&|\&|g' \ + -e 's|<|\<|g' \ + -e 's|>|\>|g' \ + -e 's|"|\"|g' \ + -e "s|'|\'|g" } realpath() { @@ -139,284 +143,284 @@ version() { # print_logo() { - cat < - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -EOF + cat <<-'EOF' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + EOF } print_style() { - cat < - - - - - - - - $(escape "$TITLE")" - - -
-
- $(escape -

- $(escape "$TITLE") -

-
-
-
-
- - - - - - - - - + cat <<-EOF + + + + + + + + + $(escape "$TITLE") + + +
+
+ $(escape +

+ $(escape "$TITLE") +

+
+
+
+
+
- $(escape "$MSG_NAME") - - $(escape "$MSG_DESCRIPTION") - - $(escape "$MSG_LAST_COMMIT") -
+ + + + + + + + EOF } @@ -424,46 +428,47 @@ print_index_row() { repo="$(basename "$(realpath "${1%.git}")")" description="$(cat "$1/description" 2>/dev/null ||:)" last_commit_date="$(git -C "$1" log -1 --format=%cd --date='format:%Y-%m:%d %H:%M' 2>/dev/null ||:)" - cat < - - - - -EOF + cat <<-EOF + + + + + + EOF } print_index_footer() { - cat < -
+ $(escape "$MSG_NAME") + + $(escape "$MSG_DESCRIPTION") + + $(escape "$MSG_LAST_COMMIT") +
- - $(escape "$repo") - - - $(escape "$description") - - $(escape "$last_commit_date") -
+ + $(escape "$repo") + + + $(escape "$description") + + $(escape "$last_commit_date") +
-
-
-
-

- $MSG_ESCAPED_FOOTER_TEMPLATE -

-
- - -EOF + cat <<-EOF + + + + + + + EOF } index_write() { - rm -f "$OUTDIR/index.html" - print_index_header >> "$OUTDIR/index.html" - for r in "$@"; do - print_index_row "$r" >> "$OUTDIR/index.html" - done - print_index_footer >> "$OUTDIR/index.html" + { + print_index_header + for r in "$@"; do + print_index_row "$r" + done + print_index_footer + } > "$OUTDIR/index.html" print_logo > "$OUTDIR/logo.svg" print_style > "$OUTDIR/style.css" @@ -486,12 +491,12 @@ cached_run() { fi if [ -e "$CACHE_DIR/$TARGET_PATH" ]; then - cp "$CACHE_DIR/$TARGET_PATH" "$OUTDIR/$TARGET_PATH" + $CMD "$CACHE_DIR/$TARGET_PATH" "$OUTDIR/$TARGET_PATH" else { genlog "$OUTDIR/$TARGET_PATH" "$@" - cp "$CACHE_DIR/$TARGET_PATH" "$OUTDIR/$TARGET_PATH" + $CMD "$CACHE_DIR/$TARGET_PATH" "$OUTDIR/$TARGET_PATH" } & parallel_n=$((parallel_n + 1)) if [ "$parallel_n" = "$MAX_JOBS" ]; then @@ -1179,6 +1184,9 @@ repo_write() { description="$(cat "$1/description" 2>/dev/null ||:)" CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/gistatic/$repo" + print_logo > "$OUTDIR/logo.svg" + print_style > "$OUTDIR/style.css" + repo_tarballs_write "$repo" print_repo_refs "$repo" "$description" > "$OUTDIR/refs.html" repo_commits_write "$repo" "$description" @@ -1186,8 +1194,6 @@ repo_write() { print_repo_index_page "$repo" "$description" > "$OUTDIR/index.html" repo_trees_write "$repo" "$description" - print_logo > "$OUTDIR/logo.svg" - print_style > "$OUTDIR/style.css" cd - > /dev/null } @@ -1222,7 +1228,8 @@ MAIN_BRANCH='main' MAIN_BRANCH_SET=false REPO= DESCRIPTION= -while getopts 'b:o:t:u:j:iqhV' flag; do +CMD='ln' +while getopts 'b:o:t:u:j:isqhV' flag; do case "$flag" in b) MAIN_BRANCH="$OPTARG" @@ -1246,6 +1253,9 @@ while getopts 'b:o:t:u:j:iqhV' flag; do q) VERBOSE=false ;; + s) + CMD='ln -s' + ;; h) usage help @@ -1270,7 +1280,6 @@ assert_arg() { exit 2 fi } - assert_arg "$OUTDIR" '-o DIRECTORY' if [ "$INDEX" = false ]; then -- cgit v1.2.3