dot

packages and services management
Log | Files | Refs | README

commit 33649cf6ebd538d82b9be06aba263ece482d2a20
parent dc6a1229235cbd464f98259da0d7adb0d6f34fdb
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Sun, 23 Jul 2017 23:24:36 +0200

Merge branch 'master' of http://github.com/josuah/etc

Diffstat:
Mbin/www-git | 89++++++++++++++++++++++++++++++++++++-------------------------------------------
Mdarkhttpd/start | 2+-
2 files changed, 42 insertions(+), 49 deletions(-)

diff --git a/bin/www-git b/bin/www-git @@ -2,8 +2,21 @@ HEADER='<!doctype html><html><head><meta charset="utf-8"/></head><body><pre>' FOOTER='</pre></body></html>' -log() +name="${1##*/}" + +mkdir -p "git/$name/commit" "git/$name/file" +cd "git/$name" || exit 1 + + +# --- ./index.html --------------------------------------------------------------- + { + printf '%s <h1><a href="..">&lt;</a> %s</h1>' "$HEADER" "$name" + + git -C "$1" ls-files | sed 's|.*|<a href="file/&">&</a>|' + + printf '<hr/>\n' + git -C "$1" log --graph --date=short \ --format='{%% %H %%} %cd%d%n%cn <%ce>%n %s%n' | sed -r ' @@ -11,58 +24,38 @@ log() s|<|\&lt;|g s|\{% ([0-9a-f]+) %\}|<a href="commit/\1.html">\1</a>| ' -} - -tree() -{ - git -C "$1" ls-files | sed 's|.*|<a href="file/&.html">&</a>|' -} + printf '%s\n' "$FOOTER" +} > index.html -commits() -{ - for commit in $(git -C "$1" log --format='%H') - do - [ -f "$commit.html" ] && continue || echo "commit $commit" - - echo "$HEADER" > "$commit.html" - git -C "$1" show "$commit" | sed ' - s|&|\&amp;|g - s|<|\&lt;|g - /^commit/ s|.*|<b>&</b>| - /^diff/ s|.*|<b>&</b>| - /^+/ s|.*|<span style="color: green;">&</span>| - /^-/ s|.*|<span style="color: red;">&</span>| - /^@/ s|.*|<b style="color: blue;">&</b>| - ' >> "$commit.html" - echo "$FOOTER" >> "$commit.html" - done -} - - -files() -{ - git -C "$1" ls-files | while IFS='' read -r path - do - mkdir -p "$(dirname "$path")" - [ "$path" -nt "$1/$file" ] && git show "master:$path" > "$path" - done -} +# --- ./file/ -------------------------------------------------------------------- -name="${1##*/}" +git -C "$1" ls-files | while IFS='' read -r file +do + [ "$1/$file" -ot "file/$file" ] && continue + echo "file $file" + mkdir -p "file/$(dirname "$file")" + git -C "$1" show master:"$file" > "file/$file" +done -mkdir -p "git/$name/commit" "git/$name/file" -( - cd "git/$name" || exit - printf '%s <h1><a href="..">&lt;</a> %s</h1>' "$HEADER" "$name" - tree "$repo" - printf '<hr/>\n' - log "$repo" - printf '%s\n' "$FOOTER" -) > "$name/index.html" +# --- ./commits/ ------------------------------------------------------------------ -(cd "$name/file" && files "$repo") -(cd "$name/commit" && commits "$repo") +for commit in $(git -C "$1" log --format='%H') +do + [ -f "commit/$commit.html" ] && continue + echo "commit $commit" + echo "$HEADER" > "commit/$commit.html" + git -C "$1" show "$commit" | sed ' + s|&|\&amp;|g + s|<|\&lt;|g + /^commit/ s|.*|<b>&</b>| + /^diff/ s|.*|<b>&</b>| + /^+/ s|.*|<span style="color: green;">&</span>| + /^-/ s|.*|<span style="color: red;" >&</span>| + /^@/ s|.*|<b style="color: blue;" >&</b>| + ' >> "commit/$commit.html" + echo "$FOOTER" >> "commit/$commit.html" +done diff --git a/darkhttpd/start b/darkhttpd/start @@ -1 +1 @@ -darkhttpd --default-mimetype=text/plain $VAR/www & PID=$! +sudo "$(command -v darkhttpd)" "$VAR/www" --default-mimetype text/plain & PID=$!