]> git.plutz.net Git - shellwiki/blob - macros/revisions
Merge commit '6cba2fc3839ec90b51cdf90a936d95bc3c7c023d'
[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">\n'
17   IFS=" "
18   { git -C "$_DATA" log --date=format:"%a, %x %H:%M" \
19                       --pretty=format:"%h       %cd     %s" \
20                       -- "pages${page_abs}#page.md"
21     printf '\n'
22   } | while read -r hash date message; do
23     user="${message% @*}"; user="${user##*@ }"
24     printf '<li><span class="hash"><a href="%s">%s</a></span><span class="date">%s</span><span class="user">%s</span></li>\n' \
25       "$(HTML "${page%/}/[revision]/$hash")" "$(HTML "$hash")" "$(HTML "$date")" "$(HTML "$user")"
26   done
27 printf '</ul>\n'