]> git.plutz.net Git - shellwiki/commitdiff
nocache pragma
authorPaul Hänsch <paul@plutz.net>
Tue, 10 May 2022 22:20:21 +0000 (00:20 +0200)
committerPaul Hänsch <paul@plutz.net>
Tue, 10 May 2022 22:20:21 +0000 (00:20 +0200)
index.cgi

index b1b2c2dd2ab11cc4a0c7b8e7cc332503579ad41b..90f7d776bf4540a219aa016c2d2f37c77a918c97 100755 (executable)
--- a/index.cgi
+++ b/index.cgi
@@ -61,9 +61,12 @@ wiki() {
     mkdir -p -- "$_DATA/pages/$page/"
     # Macros expect to find page directory as working dir
     ( cd -- "$_DATA/pages/$page/";
-      md <"$mdfile" |tee -- "${cache}.$$"
+      sed -E '1,20{ /^%[a-z]+/d; }' "$mdfile" \
+      | md |tee -- "${cache}.$$"
     )
-    mv -- "${cache}.$$" "${cache}"
+    grep -q '^%nocache' "$mdfile" \
+    && rm -- "${cache}.$$" \
+    || mv -- "${cache}.$$" "${cache}"
   fi
 }
 
@@ -71,16 +74,18 @@ case "${PATH_INFO}" in
   /"[.]"/*)
     FILE "${_EXEC}/${PATH_INFO#/\[.\]}"
     ;;
+  */\[*\]/) :;;
   */)
     theme_page "${PATH_INFO}"
+    exit 0
     ;;
   */"[login]")
-    [ "$USER_NAME" ] \
-    && REDIRECT "./" \
-    || theme_login
+    theme_login
+    exit 0
     ;;
   */"[register]")
     theme_register
+    exit 0
     ;;
   */"#"*)
     :  # TODO: Invalid page name