]> git.plutz.net Git - webtxt/blobdiff - index.cgi
switch to markdown
[webtxt] / index.cgi
index 32f1418ba05909631723e1e3a87378f174ee6713..3db279a222688073640145c8b1e629427668e9ce 100755 (executable)
--- a/index.cgi
+++ b/index.cgi
@@ -8,7 +8,7 @@ _DATA="${_DATA:-.}"
 . "$_EXEC"/cgilite/file.sh
 . "$_EXEC"/session_lock.sh
 
-git init "$_DATA"
+git init "$_DATA" >/dev/null
 
 yield_page(){
   page="$1"
@@ -36,10 +36,11 @@ case ${PATH_INFO##*/} in
        [form .new action=new [button type=submit New Note]
           $(if [ "$(COOKIE pages)" ]; then
            printf '[h2 Recent Pages][ul .recent'
-           { COOKIE pages; echo; } |tr \  \\n |while read page; do
-             [ "$(printf %s "$page" |checkid)" ] && printf '[li [a href="./%s" . %s]]' "$page" "$page"
+           for page in $(COOKIE pages); do
+             [ -f "$_DATA/$(printf %s "$page" |checkid)" ] && printf '[li [a href="./%s" . %s]]' "$page" "$page"
            done
-           fi)]
+            printf ']'
+         fi)
        ]
        EOF
     return 0
@@ -47,8 +48,8 @@ case ${PATH_INFO##*/} in
   new)
     newid="$(timeid)"
     touch "$_DATA/$newid"
-    git -C "$_DATA" add "$newid"
-    git -C "$_DATA" commit -m "new note \"${newid}\"" "$newid"
+    git -C "$_DATA" add "$newid" >/dev/null
+    git -C "$_DATA" commit -m "new note \"${newid}\"" "$newid" >/dev/null
     REDIRECT "./$newid"
     ;;
 esac
@@ -100,12 +101,12 @@ fi
 esac
 
 COOKIE pages |tr \  \\n |grep -qF "${doc##*/}" \
-|| SET_COOKIE +$((90 * 86400)) pages="$(COOKIE pages && printf ' %s' "${doc##*/}" || printf '%s' "${doc##*/}")"
+|| SET_COOKIE +$((90 * 86400)) pages="$(COOKIE pages && printf ' %s' "${doc##*/}" || printf '%s' "${doc##*/}")" Path="${PATH_INFO%/*}/"
 
 yield_page <<-EOF
        [form method=POST
           [input type=hidden name=session_key value="$SESSION_KEY"]
          [button type=submit name=action value=edit Edit]
        ]
-       [div .text . $(HTML <"$doc")]
+       [div .text . $(markdown <"$doc")]
        EOF