]> git.plutz.net Git - shellwiki/commitdiff
removed various acl checks (previously moved to handlers), introduce revision theme
authorPaul Hänsch <paul@plutz.net>
Sun, 22 May 2022 11:15:57 +0000 (13:15 +0200)
committerPaul Hänsch <paul@plutz.net>
Sun, 22 May 2022 11:15:57 +0000 (13:15 +0200)
themes/default.sh

index 3c5f2a1819a000277c06dc31451a2013f1335812..e9e9d73f195466c6bfcf2433dfe0dcb8767aab60 100755 (executable)
@@ -15,21 +15,25 @@ theme_header(){
 }
 
 theme_footer(){
-  printf '<footer>%s</footer>' "$(wiki '[wiki]/footer/' ||echo No footer)"
+  printf '<footer>%s</footer>' "$(wiki '[wiki]/footer/')"
+}
+
+theme_pagemenu(){
+  local page="$1"
+
+  if acl_write "$page"; then
+    printf  '
+    <ul class="pagemenu">
+      <li><a href="[edit]">Edit</a></li>
+      <li><a href="[attachment]/">Attachments</a></li>
+    </ul>'
+  fi
 }
 
 theme_page(){
   local page="$1" title
   title="${page%/}"; title="${title##*/}"
 
-  if [ ! "$(mdfile "$page")" ]; then
-    theme_error 404
-    return 0
-  elif ! acl_read "$page"; then
-    theme_error 403
-    return 0
-  fi
-
   # Important! Web Server response including newline
   printf "%s\r\n" "Content-Type: text/html; charset=utf-8" ""
 
@@ -41,12 +45,7 @@ theme_page(){
        </head><body id="$(HTML "$page")">
          $(theme_header)
          <main>
-           $(acl_write "$page" && printf %s \
-             '<ul class="pagemenu">
-                <li><a href="[edit]">Edit</a></li>
-                <li><a href="[attachment]/">Attachments</a></li>
-              </ul>'
-           )
+           $(theme_pagemenu)
            <article>
              $(wiki "$page" || printf 'Error while loading page <br> function "wiki" of index.sh returned with an error.')
            </article>
@@ -60,11 +59,6 @@ theme_editor(){
   local page="$1" template="$2" title
   title="${page%/}"; title="${title##*/}"
 
-  if ! acl_write "$page"; then
-    theme_error 403
-    return 0
-  fi
-
   [ "$template" ] && acl_read "$template" || template="$page"
 
   # Important! Web Server response including newline
@@ -89,17 +83,31 @@ theme_editor(){
        EOF
 }
 
-theme_attachments(){
+theme_revisions(){
   local page="$1" title
   title="${page%/}"; title="${title##*/}"
 
-  if [ ! "$(mdfile "$page")" ]; then
-    theme_error 404
-    return 0
-  elif ! acl_read "$page"; then
-    theme_error 403
-    return 0
-  fi
+  # Important! Web Server response including newline
+  printf "%s\r\n" "Content-Type: text/html; charset=utf-8" ""
+
+  cat <<-EOF
+       <!DOCTYPE HTML>
+       <html><head>
+         $(theme_head)
+         <title>Revisions $(HTML "${title}")</title>
+       </head><body id="$(HTML "$page")[attachment]/">
+         $(theme_header)
+         <main>
+         $("$_EXEC/macros/revisions" "$page")
+         </main>
+         $(theme_footer)
+       </body></html>
+       EOF
+}
+
+theme_attachments(){
+  local page="$1" title
+  title="${page%/}"; title="${title##*/}"
 
   # Important! Web Server response including newline
   printf "%s\r\n" "Content-Type: text/html; charset=utf-8" ""