]> git.plutz.net Git - rawnet/commitdiff
initial commit
authorPaul Hänsch <paul@plutz.net>
Wed, 22 Sep 2021 14:25:07 +0000 (16:25 +0200)
committerPaul Hänsch <paul@plutz.net>
Wed, 22 Sep 2021 14:25:07 +0000 (16:25 +0200)
Makefile [new file with mode: 0644]
index.cgi [new file with mode: 0755]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..24781a9
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,9 @@
+.PHONY: _subtrees
+
+_subtrees: _cgilite
+
+cgilite:
+       git subtree add --squash -P $@ https://git.plutz.net/git/$@ master
+
+_cgilite: cgilite
+       git subtree pull --squash -P $< https://git.plutz.net/git/$< master
diff --git a/index.cgi b/index.cgi
new file mode 100755 (executable)
index 0000000..a2059e2
--- /dev/null
+++ b/index.cgi
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+. "${_EXEC:-${0%/*}}"/cgilite/cgilite.sh
+. "$_EXEC"/cgilite/session.sh
+. "$_EXEC"/cgilite/file.sh
+. "$_EXEC"/cgilite/storage.sh
+. "$_EXEC"/widgets.sh
+
+PATH_INFO="$(PATH "/${PATH_INFO#${_BASE}}")"
+
+# bookmarks_cookie="$(COOKIE bookmarks |grep -xE '[0-9a-zA-Z:=]{16}(/[0-9a-zA-Z:=]{16})?( [0-9a-zA-Z:=]{16}(/[0-9a-zA-Z:=]{16})?)*')"
+bookmarks=''
+for bm in $(COOKIE bookmarks); do
+  [ -f "${_DATA}/$(checkid "${bm%/*}")" ] && bookmarks="${bookmarks}${bookmarks:+ }${bm}"
+done
+if [ "$bookmarks" ]; then
+  SET_COOKIE +$((182 * 86400)) bookmarks="${bm}" Path="${_BASE}/"
+fi
+
+yield_page(){
+  title="${1:-Webpoll}" page="$2"
+  printf '%s\r\n' 'Content-Type: text/html; charset=utf-8' \
+                  "Content-Security-Policy: script-src 'none'" \
+                  ''
+  { printf '[html
+    [head
+      [meta name="viewport" content="width=device-width"]
+      [link rel="stylesheet" type="text/css" href="%s/common.css"]
+      [link rel="stylesheet" type="text/css" href="%s/widgets.css"]
+      [link rel="stylesheet" type="text/css" href="%s/webpoll.css"]
+      [title %s]
+    ] [body class="%s"
+  ' "$_BASE" "$_BASE" "$_BASE" "$(HTML "$title")" "$page"
+  cat
+  printf '] ]'
+  } |"$_EXEC/cgilite/html-sh.sed" -u
+}
+
+pagename() {
+  local id="$1"
+  local file="$_DATA/$id"
+  if [ -f "$file" ]; then
+    DBM "$file" get title || printf 'Unnamed Page'
+  else
+    return 1;
+  fi
+}
+
+   page_home() { . "$_EXEC"/home.sh; }
+page_newdate() { . "$_EXEC"/newdate.sh; }
+   page_poll() { . "$_EXEC"/poll.sh; }
+
+case ${PATH_INFO} in
+  /favicon.ico) printf '%s\r\n' 'Content-Length: 0' '';;
+  /common.css) FILE "$_EXEC/cgilite/common.css";;
+  /widgets.css|/webpoll.css) FILE "${_EXEC}/${PATH_INFO}";;
+  /) page_home;;
+  /[0-9a-zA-Z:=]???????????????/[0-9a-zA-Z:=]???????????????) page_newdate;;
+  /*/newoptions);;
+  /[0-9a-zA-Z:=]???????????????) page_poll;;
+  /*) page_home;;
+esac
+
+exit 0