From 754a1d2c3100e2fc533bfd4a23735ba4448ebe0a Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 8 Sep 2021 15:37:19 -0300 Subject: src/gistatic.in: Finish refs page with signatures, start commit pages - actually implement HTML escaping; - include cached_run for (hopefully) reusing across HTML generating functions; - include the repository name on the $CACHE_DIR; - use the existence of a .asc file to decide on which HTML to output on the refs page; - implement all FIXMEs but the WIP one on the commit HTML generation. --- src/gistatic.in | 74 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 20 deletions(-) diff --git a/src/gistatic.in b/src/gistatic.in index f18742a..589d2f6 100755 --- a/src/gistatic.in +++ b/src/gistatic.in @@ -88,11 +88,15 @@ case "$(get_lang)" in ;; esac + +# # Utilities +# escape() { - # FIXME: HTML escape - echo "$1" + echo "$1" | + sed -e 's|&|\&|g;s|<|\<|g;s|>|\>|g;s|"|\"|g' \ + -e "s|'|\'|g" } realpath() { @@ -102,7 +106,9 @@ realpath() { } -# Helpers +# +# Documentation functions +# usage() { printf '%s\n' "$MSG_USAGE" @@ -116,6 +122,11 @@ version() { printf '@NAME@-@VERSION@ @DATE@\n' } + +# +# Template strings +# + print_logo() { cat < @@ -381,7 +392,6 @@ index_write() { print_repo_refs() { repo="$1" description="$2" - show_signature="$3" cat < @@ -496,8 +506,8 @@ EOF EOF - for tag in $(git tag); do - if [ "$show_signature" = true ]; then + for tag in $(git tag | sed '1!G;h;$!d'); do + if [ -e "$CACHE_DIR/tarballs/$repo-$tag.tar.gz.asc" ]; then tarball_link="(tarball, sig)" else @@ -536,7 +546,16 @@ EOF EOF } +print_formatted_diff() { + sha="$1" + printf '
'
+	git show -p "$sha"
+	printf '
\n' +} + print_repo_commit_page() { + sha="$2" + summary="$(git log -1 --format=%B "$sha")" cat < @@ -548,7 +567,7 @@ print_repo_commit_page() { - $(escape "$repo") - FIXME put content here + $(escape "$repo")@$(escape "$sha") - $(escape "$summary")
@@ -592,7 +611,7 @@ print_repo_commit_page() {
- CODE HR +$(print_formatted_diff "$sha")