From f11723b82ebb9e1fa8892c457de3542dd7a8ed85 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Wed, 22 Sep 2021 16:25:07 +0200 Subject: [PATCH] initial commit --- Makefile | 9 ++++++++ index.cgi | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 Makefile create mode 100755 index.cgi diff --git a/Makefile b/Makefile new file mode 100644 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 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 -- 2.39.2