dot

packages and services management
Log | Files | Refs | README

commit 0eceb3b57a89b4377d94565dc04be6697610bfb6
parent b2273ce6f846c0db426c82b51107a97b44e5ef9b
Author: Josuah Demangeon⠠⠵ <mail@josuah.net>
Date:   Mon, 20 Feb 2017 22:21:42 +0100

Great tool: gix

Diffstat:
M.config/git/config | 2+-
MREADME | 17++++++++++++-----
Mbin/gix | 150+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------
Mbin/www | 13+++++++------
4 files changed, 133 insertions(+), 49 deletions(-)

diff --git a/.config/git/config b/.config/git/config @@ -3,7 +3,7 @@ [user] email = mail@josuah.net - name = josuah + name = Josuah Demangeon⠠⠵ [core] excludesfile = ~/.gitignore diff --git a/README b/README @@ -23,14 +23,21 @@ case "$1" in git clone http://github.com/josuah/www ~/www & - git clone http://github.com/josuah/iode & - git clone http://github.com/josuah/madown & - git clone http://github.com/josuah/cgr & + git clone http://github.com/josuah/alphabet & + git clone http://github.com/josuah/artisanat & + git clone http://github.com/josuah/bataille-navale & git clone http://github.com/josuah/build & - git clone http://github.com/josuah/notes & + git clone http://github.com/josuah/cgr & + git clone http://github.com/josuah/config & + git clone http://github.com/josuah/drawille & + git clone http://github.com/josuah/fs & git clone http://github.com/josuah/fungus-vs-pathogen & + git clone http://github.com/josuah/hud & + git clone http://github.com/josuah/iode & + git clone http://github.com/josuah/madown & git clone http://github.com/josuah/miniwi & - git clone http://github.com/josuah/drawille & + git clone http://github.com/josuah/notes & + git clone http://github.com/josuah/puissance-4 & wait ;; diff --git a/bin/gix b/bin/gix @@ -1,4 +1,8 @@ -# 1: path to the root +#!/bin/sh +# Static Git index generator inspired from stagit + + +# 1: path to the parent root # 2: title of the page head() @@ -8,12 +12,27 @@ head() <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>%s</title> -<link rel="icon" type="image/png" href="favicon.png" /> -<link rel="alternate" type="application/atom+xml" title="stagit.git Atom Feed" href="atom.xml" /> -<link rel="stylesheet" type="text/css" href="style.css" /> +<link rel="icon" type="image/png" href="../%s/favicon.png" /> +<link rel="stylesheet" type="text/css" href="../%s/git.css" /> </head> -<body>' +<body> +' "$2" "$1" "$1" +} + + +# 1: path to the root + +header() +{ + printf '<pre> +<a href="%s/..">&lt;</a> <b>%s</b> - <span style="color: grey;">%s</span> +<a href="%s/index.html">Log</a> | <a href="%s/files.html">Files</a> +</pre> +<hr>' "$1" "${PWD##*/}" "$(cat .git/description)" "$1" "$1" + + [ -f "$1/files/README" ] && printf ' | <a href="files/README.html">' + [ -f "$1/files/LICENCE" ] && printf ' | <a href="files/LICENCE.html">' } @@ -28,10 +47,10 @@ foot() log() { printf '<table>\n<thead>\n<tr>' - printf '<th>%s</th>' 'Date' 'Hash' 'Commit Message' 'Author' + printf '<th>%s</th>' 'Date' 'Hash' 'Commit message' 'Author' printf '</tr>\n</thead>\n<tbody>\n' - git log --pretty=format:"<tr>$( + git log --format="<tr>$( printf '<td>%s</td>' \ '%ad' '<a href="commit/%H.html">%h</a>' '%s' '%an' )</tr>" --date=format:'%y-%m-%d %H:%M' @@ -49,15 +68,23 @@ commit() <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 -</pre>' "$1" - printf '<hr/>' - printf '<pre>\n' +%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>| + ' - git diff "$1" | sed ' + printf '</pre>\n<hr/>\n<pre>' + + git show "$1" --format='' | sed ' /^diff/ { - s|a/\([^ ]*\)|a/<a href="../files/\1">\1</a>| - s|b/\([^ ]*\)|b/<a href="../files/\1">\1</a>| + s|a/\([^ ]*\)|a/<a href="../files/\1.html">\1</a>| + s|b/\([^ ]*\)|b/<a href="../files/\1.html">\1</a>| s|.*|<b>&</b>| } /^+/ s|.*|<span style="color: green;">&</span>| @@ -72,9 +99,16 @@ commit() commits() { - git log --pretty=format:'%H' | while IFS='' read -r hash + mkdir -p "$1/commit" + + for hash in $(git log --format='%H') do - (head; commit "$hash"; foot) > "$1/commit/$hash.html" + { + head '../..' "Files - ${PWD##*/}" + header '..' + commit "$hash" + foot + } > "$1/commit/$hash.html" done } @@ -83,15 +117,17 @@ commits() file() { - printf '<table><tr><td><pre>\n' + printf '<p>%s</p>\n<table class="file"' + printf '<tr>\n<td>\n<pre id="num">\n' - if grep -qI . "$file" 1>/dev/null + if grep -qI . "$1" 1>/dev/null then - seq "$(wc -l "$file")" | sed 's|.*|<a href="#&">&</a>|' - - printf '</td><td>' - - cat "$file" + 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' fi @@ -104,28 +140,58 @@ file() files() { + mkdir -p "$1/files" + + printf '<table>\n<thead>\n<tr>' + printf '<th>%s</th>' 'Mode' 'Name' 'Size' + printf '</tr>\n</thead>\n<tbody>\n' + git ls-files | while IFS='' read -r file do - [ -z "${file##*/*}" ] && mkdir -p "$1/files/${1%/*}" - (head; file "$file"; foot) > "$1/files/$1/$file" + [ -z "${file##*/*}" ] && mkdir -p "$1/files/${file%/*}" + + root="$(printf %s "$file" | sed 's|[^/]*||g; s|.|../|g').." + + { + head "../$root" "$file - ${PWD##*/}" + + header "$root" + file "$file" + foot + } > "$1/files/$file.html" printf '<tr>' + printf '<td>%s</td>' \ - "$(stat %A)" "<a href=\"$file\">$file</a>" - printf '</tr>' + "$(stat -c %A "$file")" \ + "<a href=\"files/$file.html\">$file</a>" \ + "$(wc -l < "$file")L" + printf '</tr>\n' done + + printf '\n</tbody>\n</table>\n' } # 1: target base directory -# 2: repository to process repo() { - (head; log; foot) > $1/$2/index.html - (head; files "$1"; foot) > $1/$2/files.html - - mkdir -p commit + { + head '..' "Log - ${1##*/}" + header '.' + log + foot + } > $1/index.html + + { + head '..' "Files - ${1##*/}" + header '.' + files "$1" + foot + } > $1/files.html + + commits "$1" } @@ -133,30 +199,40 @@ repo() list() { - printf '<table>\n' + printf '<table>\n<thead>\n<tr>' + printf '<th>%s</th>' 'Last commit' 'Name' 'Description' + printf '</tr>\n</thead>\n<tbody>\n' find "$1" -maxdepth 1 -mindepth 1 -type d | sort | while IFS='' read -r repo do - set -- "$(pwd)" + printf '%s\n' "$repo" 1>&2 mkdir -p "${repo##*/}" - (cd "$repo" && repo "$1" "${repo##*/}" || exit 1) + (pwd="$PWD"; cd "$repo" && repo "$pwd/${repo##*/}" || exit 1) printf '<tr>' printf '<td>%s</td>' \ + "$(git -C "$repo" log -1 \ + --format='%cd' \ + --date=format:'%y-%m-%d %H:%M')" \ "<a href=\"${repo##*/}\">${repo##*/}</a>" \ - "$(cat "$1/.git/description")" + "$(cat "$repo/.git/description")" printf '</tr>\n' done - printf '</table>\n' + printf '</tbody>\n</table>\n' } main() { - list "${1%/}" > index.html + { + head '.' 'Repositories' + printf '<a href="..">&lt;</a>\n<hr/>' + list "${1%/}" + foot + } > index.html } diff --git a/bin/www b/bin/www @@ -3,6 +3,7 @@ LAYOUT="layout.html" +CONVERTER="${CONVERTER:-madown}" # 1: name of item being parsed @@ -23,11 +24,11 @@ parse() case "${2%%\}\}*}" in *content* ) : - [ -f "$1/index.txt" ] && cat "$1/index.txt" + [ -f "$1" ] && $CONVERTER < "$1" ;; *list* ) - [ "$1" != '.' ] && list "$1" + [ -z "${1##*/*}" ] && [ "${1##*/}" = 'index.md' ] && list "${1%/*}" ;; *nav* ) @@ -39,11 +40,11 @@ parse() ;; *root* ) - if [ "$1" = '.' ] + if [ "${1##*/*}" ] then printf '.' else - printf %s/ "$1" | sed 's|[^/]||g; s|/|../|g; s|/$||' + printf %s "$1" | sed 's|[^/]||g; s|/|../|g; s|/$||' fi ;; esac @@ -88,9 +89,9 @@ main() fi # create index.html pages for each non-dotfile directory - find . ! -path '*/.*' -type d | while IFS='' read -r d + find . -name '*.md' -type f | sed 's|\./||' | while IFS='' read -r f do - parse "${d#./}" "$(cat "$LAYOUT")" > "$d/index.html" + parse "$f" "$(cat "$LAYOUT")" > "${f%.md}.html" done }