]> git.plutz.net Git - rawnet/blobdiff - index.cgi
channel view and overview pages
[rawnet] / index.cgi
index a2059e290bf84e58a20e733167123b3fa932d09c..fe324147c3ac60ce75dfd95067ec6ca7aece9862 100755 (executable)
--- a/index.cgi
+++ b/index.cgi
@@ -1,64 +1,73 @@
 #!/bin/sh
 
+USER_REQUIREEMAIL=false
+
 . "${_EXEC:-${0%/*}}"/cgilite/cgilite.sh
-. "$_EXEC"/cgilite/session.sh
-. "$_EXEC"/cgilite/file.sh
-. "$_EXEC"/cgilite/storage.sh
-. "$_EXEC"/widgets.sh
+. "$_EXEC"/cgilite/session.sh nocookie
+. "$_EXEC"/cgilite/users.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}/"
+export MD_HTML="false"
+if [ "$(which awk)" ]; then
+  markdown() { awk -f "$_EXEC/cgilite/markdown.awk"; }
+else
+  markdown() { busybox awk -f "$_EXEC/cgilite/markdown.awk"; }
 fi
 
 yield_page(){
-  title="${1:-Webpoll}" page="$2"
+  title="${1:-RAW:NET}" 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"]
+      [link rel="stylesheet" type="text/css" href="%s/cgilite/common.css"]
+      [link rel="stylesheet" type="text/css" href="%s/rawnet.css"]
       [title %s]
     ] [body class="%s"
-  ' "$_BASE" "$_BASE" "$_BASE" "$(HTML "$title")" "$page"
+  ' "$_BASE" "$_BASE" "$(HTML "$title")" "$page"
+  printf '
+      [header
+        [form method=POST action="%s/search/"
+          [input name=search placeholder="Search"]
+        ]
+      ]' "$_BASE"
   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;;
+  *.css)
+    . "${_EXEC}/cgilite/file.sh"
+    FILE "${_EXEC}/${PATH_INFO}"
+    ;;
+  /login/)
+    if [ "$USER_ID" ]; then
+      REDIRECT "${_BASE}/"
+    else
+      yield_page 'RAW:NET Login' login <<-EOF
+       $(w_user_login)
+       EOF
+    fi
+    ;;
+  /register/)
+    yield_page 'RAW:NET Register User' register <<-EOF
+       $(w_user_register)
+       EOF
+    ;;
+  /recover/)
+    yield_page 'RAW:NET Recover Account' recover <<-EOF
+       $(w_user_recover)
+       EOF
+    ;;
+  /|/channel/*) . "${_EXEC}/page_channel.sh";;
+  /playlist/*) . "${_EXEC}/page_playlist.sh";;
+  /search/*) . "${_EXEC}/page_search.sh";;
+  *) . "${_EXEC}/page_404.sh";;
 esac
 
 exit 0