]> git.plutz.net Git - shellwiki/commitdiff
revision display
authorPaul Hänsch <paul@plutz.net>
Mon, 23 May 2022 17:32:18 +0000 (19:32 +0200)
committerPaul Hänsch <paul@plutz.net>
Mon, 23 May 2022 17:32:18 +0000 (19:32 +0200)
handlers/20_revision.sh
macros/revisions

index b34b2b9681378aae5fc0e7d67c29b63b5063a9ab..dd78b92ca4aba36c683015c24cb8d7a3cb0053cb 100644 (file)
@@ -2,7 +2,7 @@
 
 case "${PATH_INFO}" in
   */\[revision\]/)
-    REDIRECT "${_BASE}/${PATH_INFO%/}"
+    REDIRECT "${_BASE}${PATH_INFO%/}"
     ;;
   */\[revision\])
     if ! acl_read "${PATH_INFO%\[revision\]}"; then
@@ -12,7 +12,24 @@ case "${PATH_INFO}" in
     fi
     return 0
     ;;
-  */[revision]/*):;;
+  */\[revision\]/\[*\]|*/\[revision\]/*/*)
+    REDIRECT "${_BASE}${PATH_INFO%%\[revision\]/*}${PATH_INFO##*/\[revision\]/}"
+    ;;
+  */\[revision\]/*)
+    page="${PATH_INFO%\[revision\]/*}"
+    rev="${PATH_INFO##*/}"
+    if ! acl_read "${page}"; then
+      theme_error 403
+    else
+    ( export PATH_INFO="${page}"
+      cd "${_DATA}/pages${page}"
+      git show "${rev}:./#page.md" \
+      | { printf '<article class="revision">'; md; printf '</article>'; } \
+      | theme_page - "${page##*/}"
+    )
+    fi
+    return 0
+    ;;
 esac
 
 return 1
index 2bd83f5ae487d2f4f38b17a2e7401f9cda2e61da..9a5730f4021d5a069a748b8e7265658bef8cf433 100755 (executable)
@@ -22,6 +22,6 @@ printf '<ul class="macro revisions">\n'
   } | while read -r hash date message; do
     user="${message% @*}"; user="${user##*@ }"
     printf '<li><span class="hash"><a href="%s">%s</a></span><span class="date">%s</span><span class="user">%s</span></li>\n' \
-      "$(HTML "${page%/}/[revisions]/$hash")" "$(HTML "$hash")" "$(HTML "$date")" "$(HTML "$user")"
+      "$(HTML "${page%/}/[revision]/$hash")" "$(HTML "$hash")" "$(HTML "$date")" "$(HTML "$user")"
   done
 printf '</ul>\n'