]> git.plutz.net Git - shellwiki/blob - macros/revisions
basic revision listing
[shellwiki] / macros / revisions
1 #!/bin/sh
2
3 . "$_EXEC/cgilite/cgilite.sh"
4 . "$_EXEC/tools.sh"
5 . "$_EXEC/acl.sh"
6
7 page="$1"
8 page_abs="$(page_abs "$page")"
9
10 if ! acl_read "$page_abs"; then
11   return 0
12 elif [ ! "$(which git)" ]; then
13   printf '<div class="macro revisions error">GIT is not available to handle revisioning.</div>'
14 fi
15
16 printf '<ul class="macro revisions">'
17   IFS=" "
18   git -C "$_DATA" log --date=format:"%a, %x %H:%M" \
19                       --pretty=format:"%h       %cd     %s%n" \
20                       -- "pages${page_abs}#page.md" \
21   | while read hash date message; do
22     user="${message% @*}"; user="${user##*@ }"
23     printf '<a href="%s"><span class="hash">%s</span><span="date">%s</span><span class="user">%s</span></a>' \
24       "$(HTML "${page%/}/[revisions]/$hash")" "$(HTML "$hash")" "$(HTML "$date")" "$(HTML "$user")"
25   done
26 printf '</ul>'