3 _EXEC="${_EXEC:-${0%/*}/}"
6 . "$_EXEC"/cgilite/cgilite.sh
7 . "$_EXEC"/cgilite/session.sh
8 . "$_EXEC"/cgilite/file.sh
9 . "$_EXEC"/session_lock.sh
15 printf '%s\r\n' 'Content-Type: text/html; charset=utf-8' \
16 "Content-Security-Policy: script-src 'none'" \
20 [meta name="viewport" content="width=device-width"]
21 [link rel="stylesheet" type="text/css" href="common.css"]
22 [link rel="stylesheet" type="text/css" href="webnote.css"]
28 } |"$_EXEC/cgilite/html-sh.sed" -u
31 case ${PATH_INFO##*/} in
32 favicon.ico) printf '%s\r\n' 'Content-Length: 0' '';;
33 common.css) FILE "$_EXEC/cgilite/common.css";;
34 webnote.css) FILE "$_EXEC/webnote.css";;
36 [form .new action=new [button type=submit New Note]
37 $(if [ "$(COOKIE pages)" ]; then
38 printf '[h2 Recent Pages][ul .recent'
39 { COOKIE pages; echo; } |tr \ \\n |while read page; do
40 [ "$(printf %s "$page" |checkid)" ] && printf '[li [a href="./%s" . %s]]' "$page" "$page"
50 git -C "$_DATA" add "$newid"
51 git -C "$_DATA" commit -m "new note \"${newid}\"" "$newid"
56 doc="$_DATA/$(printf %s ${PATH_INFO##*/} |checkid)"
58 if [ ! -f "$doc" ]; then
59 REDIRECT "${PATH_INFO%/*}/"
63 [ $REQUEST_METHOD = POST ] && case $(POST action) in
65 if temp=$(SLOCK "$doc"); then
68 [input type=hidden name=session_key value="$SESSION_KEY"]
69 [button type=submit name=action value=cancel Cancel]
70 [button type=submit name=action value=update Update]
71 [textarea name=document . $(HTML <"$doc")]
76 [p .error .locked Someone else is already editing this Dokument. Wait a few minutes and try again. [a href="$PATH_INFO" Nothing else I can do.]]
86 if temp=$(CHECK_SLOCK "$doc"); then
88 POST document >"${doc}"
89 git -C "$_DATA" commit -m "update note ${doc##*/} \"$(sed '1{s;\r;;; q;}' "$doc")\"" "${doc##*/}" >/dev/null
93 [p .error .stolen Your edit took too long and someone else is now editing this file. [a href="$PATH_INFO" Dang, I must be quicker next time!]]
94 [p Copy your Content for reference:]
95 [div .text . $(POST document |HTML)]
102 COOKIE pages |tr \ \\n |grep -qF "${doc##*/}" \
103 || SET_COOKIE +$((90 * 86400)) pages="$(COOKIE pages && printf ' %s' "${doc##*/}" || printf '%s' "${doc##*/}")"
107 [input type=hidden name=session_key value="$SESSION_KEY"]
108 [button type=submit name=action value=edit Edit]
110 [div .text . $(HTML <"$doc")]