]> git.plutz.net Git - serve0/commitdiff
css loading, externalize page code to file
authorPaul Hänsch <paul@plutz.net>
Mon, 2 Jul 2018 03:17:45 +0000 (05:17 +0200)
committerPaul Hänsch <paul@plutz.net>
Mon, 2 Jul 2018 03:17:45 +0000 (05:17 +0200)
cgilite
index.cgi
list.sh [new file with mode: 0644]
shcgi
style.css [new file with mode: 0644]
widgets.sh

diff --git a/cgilite b/cgilite
index 3fdb8e7e2ed8fcf3129de33147d1dd3b4a204b21..3a5f8da6c094474cb5de33d40fc94e4497450a25 160000 (submodule)
--- a/cgilite
+++ b/cgilite
@@ -1 +1 @@
-Subproject commit 3fdb8e7e2ed8fcf3129de33147d1dd3b4a204b21
+Subproject commit 3a5f8da6c094474cb5de33d40fc94e4497450a25
index 54841bf4338feab6adce565f87d6c71ad34b28b4..94309f3305a50b3690311c0e6a1cbc433fa755b8 100755 (executable)
--- a/index.cgi
+++ b/index.cgi
@@ -19,35 +19,31 @@ case $(GET a) in
     SET_COOKIE +$((86400 * 90)) pagesize="$(POST pagesize |grep -m1 -xE '[1-9][0-9]*' || printf 50)"
     SET_COOKIE +$((86400 * 90))  fakemp4="$(POST  fakemp4 |grep -m1 -xE 'yes' || printf no)"
     printf 'Location: %s\r\n\r\n' "$(POST ref)"
+    exit 0
   ;;
 esac
 
-if [ -f "$_DATA/$item" ]; then
+if [ "$item" = "/style.css" ]; then
+  . "$_EXEC/cgilite/file.sh"
+  [ -r "$_DATA/$item" ] && FILE "$_DATA/$item" \
+                        || FILE "$_EXEC/style.css"
+elif [ -f "$_DATA/$item" ]; then
   case $(GET a) in
     tag)
     ;;
-    download)
-    ;;
     thumbnail)
     ;;
     delete)
     ;;
-    *)
+    *) . "$_EXEC/cgilite/file.sh"
+      FILE "$_DATA/$item"
     ;;
   esac
 elif [ -d "$_DATA/$item" ]; then
   case $(GET a) in
     multitag)
     ;;
-    *) printf 'Content-Type: text/html;charset=utf-8\r\n\r\n'
-       "$_EXEC/cgilite/html-sh.sed" <<-EOF
-       [!DOCTYPE HTML]
-       [html [head [title Listing]
-       ] [body
-       $(w_search) $(w_prefs)
-       ] ]
-       EOF
-       exit 0
+    *) . "$_EXEC/list.sh"
     ;;
   esac
 else
diff --git a/list.sh b/list.sh
new file mode 100644 (file)
index 0000000..b8c3a4e
--- /dev/null
+++ b/list.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+printf 'Content-Type: text/html;charset=utf-8\r\n\r\n'
+
+"$_EXEC/cgilite/html-sh.sed" <<-EOF
+[!DOCTYPE HTML]
+[html [head [title Listing]
+  [link rel=stylesheet href="/style.css" ]
+] [body
+  $(w_search)
+  [input type=checkbox #t_prefs .toggle ][label for=t_prefs &#x2699;]
+  $(w_prefs)
+] ]
+EOF
+
diff --git a/shcgi b/shcgi
index c287482dc24988cabd48a085e6d752d12b489550..8d60af41a80ea3760dd51c3bc34eab68d88b16ae 160000 (submodule)
--- a/shcgi
+++ b/shcgi
@@ -1 +1 @@
-Subproject commit c287482dc24988cabd48a085e6d752d12b489550
+Subproject commit 8d60af41a80ea3760dd51c3bc34eab68d88b16ae
diff --git a/style.css b/style.css
new file mode 100644 (file)
index 0000000..90bb4ea
--- /dev/null
+++ b/style.css
@@ -0,0 +1,54 @@
+body {
+  color: white;
+  background-color: black;
+  margin: 0;
+  padding: 0;
+}
+
+input.toggle {
+  display: none;
+}
+input.toggle + label + * {
+  display: block;
+  overflow: hidden;
+  height: 0;
+}
+input.toggle:checked + label + * { height: auto; }
+
+#search {
+  text-align: center;
+  background-color: #333;
+  padding: .25em;
+  border-bottom: 1px solid;
+  margin: 0;
+}
+
+label[for=t_prefs] {
+  position: absolute;
+  font-size: 1.5em;
+  top: 0; right: .25em;
+}
+
+#t_prefs:checked + label + #prefs {
+  background-color: #333;
+  border: 1px solid;
+  border-top: none;
+  border-right: none;
+  padding: .5em 1em;
+  margin: 0;
+  position: relative;
+  top: -1px;
+  width: 13em;
+  margin-left: auto;
+}
+
+#prefs label[for=prefs_ps] {
+  font-weight: bold;
+}
+#prefs #prefs_ps {
+  max-width: 3em;
+  margin-bottom: 1em;
+}
+#prefs button {
+  margin-top: 1em;
+}
index 149a8131fc5ced0f4f046ca3a3da89e1434ccb0f..fd9e72e938a165b0087559528010b672985382a7 100644 (file)
@@ -2,7 +2,7 @@
 
 w_search(){
   printf '
-  [form method=GET action=?
+  [form #search method=GET action=?
     [select name=o size=1 
       [option disabled=disabled Order By]
       [option value=Name Name]
@@ -17,13 +17,15 @@ w_search(){
 
 w_prefs(){
   printf '
-  [form method=POST action=?a=setprefs
+  [form #prefs method="POST" action="?a=setprefs"
     [hidden "ref" "%s"]
     [label for=prefs_ps Pagesize]
-    [input type=number name=pagesize value="%s"]
-    [checkbox "fakemp4" "yes" #prefs_fmp4] [label for=prefs_fmp4 Fake .MP4 file ending]
+    [input #prefs_ps type=number name=pagesize value="%s"][br]
+    [checkbox "fakemp4" "yes" %s #prefs_fmp4] [label for=prefs_fmp4 Fake .MP4 file ending][br]
     [submit "store" "store" Set Cookie]
   ]
   ' \
-  "$(HTML "$REQUEST_URI")" "$pagesize"
+  "$(HTML "$REQUEST_URI")" \
+  "$(COOKIE pagesize |grep -m1 -xE '[0-9]+' || printf 50)" \
+  "$(COOKIE fakemp4 |grep -m1 -qx yes && printf checked)"
 }