dot

packages and services management
Log | Files | Refs | README

commit 4393a800228b4eb5e9b9602c7c1e6b56c285fd08
parent ffd19d732b7077a6d957ab84847b3fa9ace75417
Author: Josuah Demangeon <mail@josuah.net>
Date:   Fri,  7 Apr 2017 19:10:42 +0200

Simplified www-git and improved performances

Diffstat:
Mbin/www-git | 53++++++++++++++++++++++-------------------------------
1 file changed, 22 insertions(+), 31 deletions(-)

diff --git a/bin/www-git b/bin/www-git @@ -4,7 +4,7 @@ # 1: path to the parent 1 # 2: title of the page -head() +header() { printf '<!doctype html> <html> @@ -21,7 +21,7 @@ head() } -foot() +footer() { printf '</body> </html> @@ -33,37 +33,31 @@ foot() commit() { - git show -s --format='<pre> + git show --format='<pre> <b>commit</b> <a href="%H.html">%H</a> <b>parent</b> <a href="%P.html">%P</a> <b>author</b> %an &lt;<a href="mailto:%ae">%ae</a>&gt; <b>date</b> %aD +<hr /> %s -<b>diffstat</b> -' "$1" - - git show --stat --format='' "$1" | sed ' - s|\(+*\)\(-*\)$|<span style="color: green;">\1</span>\2| - s|-*$|<span style="color: red;">&</span>| - ' - - printf '</pre>\n<hr/>\n<pre>' - - git show "$1" --format='' | sed ' - s|&|\&amp;|g - s|<|\&lt;|g +<hr />' "$1" | sed ' /^diff/ { s|a/\([^ ]*\)|a/<a href="../file/\1.html">\1</a>| s|b/\([^ ]*\)|b/<a href="../file/\1.html">\1</a>| s|.*|<b>&</b>| } + + /^diff/,$ { + s|&|\&amp;|g + s|<|\&lt;|g + } + /^+/ s|.*|<span style="color: green;">&</span>| /^-/ s|.*|<span style="color: red;">&</span>| + /^@/ s|.*|<b style="color: blue;">&</b>| ' - - printf '</pre>\n' } @@ -81,9 +75,9 @@ commits() for hash in $(git log --format='%H') do { - head '../../..' "Commits - ${PWD##*/}" + header '../../..' "Commits - ${PWD##*/}" commit "$hash" - foot + footer } > "$pwd/$repo/commit/$hash.html" done @@ -99,11 +93,8 @@ file() if grep -qI . "$1" 1>/dev/null then - seq "$(wc -l < "$1")" | - sed 's|.*|<a id="&" href="#&">&</a>|' - + seq "$(wc -l < "$1")" | sed 's|.*|<a id="&" href="#&">&</a>|' printf '</pre></td>\n<td><pre>\n' - sed 's|&|\&amp;|g; s|<|\&lt;|g' "$1" else printf 'binary file' @@ -126,11 +117,11 @@ files() [ -z "${file##*/*}" ] && mkdir -p "$pwd/$repo/file/${file%/*}" { - head "../../$( + header "../../$( printf %s "$file" | sed 's|[^/]*||g; s|/|../|g' ).." "$file - $repo" file "$file" - foot + footer } > "$pwd/$repo/file/$file.html" printf '<tr>' @@ -152,12 +143,12 @@ repo() mkdir -p "$pwd/$repo/commit" { - head '../..' "$repo" - printf '<h2>files</h2>\n' + header '../..' "$repo" + printf '<h2>Files</h2>\n' files - printf '<h2>commits</h2>\n' + printf '<h2>Commits</h2>\n' commits - foot + footer } > "$pwd/$repo/index.html" printf '<tr>' @@ -175,7 +166,7 @@ repos() while read -r repo desc do - printf '%s\n' "$repo" 1>&2 + printf ' %s' "$repo" 1>&2 mkdir -p "$repo"