From f3bffc527d5f7a440da642f8c9e3a171b81153f2 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Mon, 6 Jan 2025 13:51:03 -0300 Subject: m --- Makefile | 21 +- src/gistatic.in | 641 ++++++++++++++++++++++++----------------------- src/static/logo.svg | 62 ----- src/static/style.css | 133 ---------- src/templates/files.html | 311 ----------------------- src/templates/log.html | 83 ------ src/templates/refs.html | 213 ---------------- 7 files changed, 344 insertions(+), 1120 deletions(-) delete mode 100644 src/static/logo.svg delete mode 100644 src/static/style.css delete mode 100644 src/templates/files.html delete mode 100644 src/templates/log.html delete mode 100644 src/templates/refs.html diff --git a/Makefile b/Makefile index 96d228f..3482494 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ CONTRIBLANGS = .SUFFIXES: -.SUFFIXES: .c .o .to .in +.SUFFIXES: .in .in: sed \ @@ -38,7 +38,24 @@ tests/resources/repositories/repo-1/.git \ tests/resources/repositories/repo-2/.git: ln -s .gitdir $@ -check: all gistatic-tests \ + +shellcheck: + shellcheck src/gistatic.in + +emit-index: src/gistatic + rm -rf tmp/index/ + ./src/gistatic -i -o tmp/index/ ~/dev/published/git-permalink/ ../capim/ ../libedn/ ../listatic/ ../lisp-cli/ + ln -rfs tmp/git-permalink tmp/index/git-permalink + +emit-repo: src/gistatic + rm -rf tmp/git-permalink/ + time ./src/gistatic -o tmp/git-permalink/ -u FIXME-url-1 ~/dev/published/git-permalink/ + +run: shellcheck emit-index emit-repo + + + +check: all \ tests/resources/repositories/repo-1/.git \ tests/resources/repositories/repo-2/.git sh tests/build-sample.sh 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 + + + +
+
+

+ $MSG_ESCAPED_FOOTER_TEMPLATE +

+
+ + + 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 diff --git a/src/static/logo.svg b/src/static/logo.svg deleted file mode 100644 index ce566b2..0000000 --- a/src/static/logo.svg +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/static/style.css b/src/static/style.css deleted file mode 100644 index d1fc04d..0000000 --- a/src/static/style.css +++ /dev/null @@ -1,133 +0,0 @@ -:root { - --row-light-gray: #eee; - --row-background-light-gray: #ccc; - --background-light-gray: #999; - font-family: sans-serif; -} - -a { - color: black; - text-decoration: none; -} - -a:hover { - text-decoration: underline; -} - -#horizontal-aligner-of-logo-and-header-items { - display: flex; -} - -#vertical-aligner-of-header-items { - display: flex; - flex-direction: row; -} - -div#vertical-aligner-of-header-items > h2 { - font-weigth: normal; - color: red; -} - -#repository-logo { - width: 5em; - margin: 2em; -} - -hr { - border: none; - height: 5px; - background-color: var(--background-light-gray); -} - -nav ul { - display: flex; - list-style-type: none; - border-bottom: 5px solid var(--background-light-gray); -} - -nav li { - margin-left: 10px; -} - -nav a { - padding-top: 2px; - padding-left: 8px; - padding-right: 8px; -} - -nav .selected-nav-item a { - background-color: var(--background-light-gray); -} - -main { - padding: 2em; -} - -table { - text-align: left; - border: none; - border-collapse: collapse; - width: 100%; -} - -table tr.table-no-highlight-row { - background-color: white; -} - -table tr.table-no-highlight-row:hover { - background-color: white; -} - -table tr:hover { - background-color: var(--row-background-light-gray); -} - -tr:nth-child(odd) { - background-color: white; -} - -tr:nth-child(even) { - background-color: var(--row-light-gray); -} - -footer { - text-align: center; -} - -/* Page log.html */ - -.log-commit-box { - padding: 1em; - background-color: var(--row-light-gray); -} - -.log-head-highlight { - padding: 2px; - background-color: #ff8888; - border: 1px solid; -} - -.log-branch-highlight { - padding: 2px; - background-color: #88ff88; - border: 1px solid; -} - -.log-tag-highlight { - padding: 2px; - background-color: #ffff88; - border: 1px solid; -} - - -/* Page tree.html */ - -table#files-table td:nth-child(1) { - width: 10%; - padding-right: 2em; -} - -.files-row-item-directory { - color: blue; - font-weight: bold; -} diff --git a/src/templates/files.html b/src/templates/files.html deleted file mode 100644 index fb556be..0000000 --- a/src/templates/files.html +++ /dev/null @@ -1,311 +0,0 @@ - - - - - - - - - - - - $PROJECT_NAME - $PROJECT_DESCRIPTION - - - - - - - - -
-
- -
-

- $PROJECT_NAME -

-

- $PROJECT_DESCRIPTION -

- - git clone $PROJECT_CLONE_URL - -
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Mode - - Name - - Size -
- - -rw-r--r-- - - - - - .gitignore - - - - - 123B - -
- - -rw-r--r-- - - - - - CHAGELOG.md - - - - - 123B - -
- - -rw-r--r-- - - - - - COPYING - - - - - 123B - -
- - -rw-r--r-- - - - - - Makefile - - - - - 123B - -
- - -rw-r--r-- - - - - - README.md - - - - - 123B - -
- - -rw-r--r-- - - - - - TODOs.md - - - - - 123B - -
- - d--------- - - - - - aux/ - - - - - 123B - -
- - -rw-r--r-- - - - - - description - - - - - 123B - -
- - d--------- - - - - - doc/ - - - - - 123B - -
- - -rw-r--r-- - - - - - long-description - - - - - 123B - -
- - d--------- - - - - - src/ - - - - - 123B - -
- - d--------- - - - - - tests/ - - - - - 123B - -
-
-
-

README

-

This does something.

-
-
-
-
-

- Generated by gistatic $VERSION at $NOW -

-
- - diff --git a/src/templates/log.html b/src/templates/log.html deleted file mode 100644 index 9f85189..0000000 --- a/src/templates/log.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - $PROJECT_NAME - $PROJECT_DESCRIPTION - - - - - - - - -
-
- -
-

- $PROJECT_NAME -

-

- $PROJECT_DESCRIPTION -

- - git clone $PROJECT_CLONE_URL - -
-
- -
-
-
-

- 739a235c - | - EuAndreh - HEAD - main - v0.2.1 -

-
Only display filename if it's set
-
-This prevents None from showing up in different places when pastes are
-submitted through the API.
-
Notes:
-  See CI logs with:
-    git notes --ref=refs/notes/ci-logs show 92bfa3c5f06558cebcfa06bf78159e76254e07fd
-    git notes --ref=refs/notes/ci-data show 92bfa3c5f06558cebcfa06bf78159e76254e07fd
-
-
-
-
-

- Generated by gistatic $VERSION at $NOW -

-
- - diff --git a/src/templates/refs.html b/src/templates/refs.html deleted file mode 100644 index 8af5803..0000000 --- a/src/templates/refs.html +++ /dev/null @@ -1,213 +0,0 @@ - - - - - - - - - - - - $PROJECT_NAME - $PROJECT_DESCRIPTION - - - - - - - - -
-
- -
-

- $PROJECT_NAME -

-

- $PROJECT_DESCRIPTION -

- - git clone $PROJECT_CLONE_URL - -
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Branch - - Commit message - - Author - - Date -
- - - main - - - - - aux/workflow/public.sh: Mark as executable - - - EuAndreh - - 2021-01-02 15:26 -3 -
 
- Tag - - Download - - Author - - Date -
- - v0.2.1 - - - - remembering-0.2.1.tar.xz - - (sig) - - EuAndreh - - 2021-01-05 15:26 -3 -
- - v0.2.0 - - - - remembering-0.2.0.tar.xz - - (sig) - - EuAndreh - - 2021-01-04 15:26 -3 -
- - v0.1.2 - - - - remembering-0.2.1.tar.xz - - (sig) - - EuAndreh - - 2021-01-03 15:26 -3 -
- - v0.1.1 - - - - remembering-0.2.1.tar.xz - - (sig) - - EuAndreh - - 2021-01-02 15:26 -3 -
- - v0.1.0 - - - - remembering-0.2.1.tar.xz - - (sig) - - EuAndreh - - 2021-01-01 15:26 -3 -
-
- - - -- cgit v1.2.3