From: Paul Hänsch Date: Mon, 2 Jul 2018 03:17:45 +0000 (+0200) Subject: css loading, externalize page code to file X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=10c72cceebb66db98ad621181369edfa6294f924;p=serve0 css loading, externalize page code to file --- diff --git a/cgilite b/cgilite index 3fdb8e7..3a5f8da 160000 --- a/cgilite +++ b/cgilite @@ -1 +1 @@ -Subproject commit 3fdb8e7e2ed8fcf3129de33147d1dd3b4a204b21 +Subproject commit 3a5f8da6c094474cb5de33d40fc94e4497450a25 diff --git a/index.cgi b/index.cgi index 54841bf..94309f3 100755 --- 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 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 ⚙] + $(w_prefs) +] ] +EOF + diff --git a/shcgi b/shcgi index c287482..8d60af4 160000 --- a/shcgi +++ b/shcgi @@ -1 +1 @@ -Subproject commit c287482dc24988cabd48a085e6d752d12b489550 +Subproject commit 8d60af41a80ea3760dd51c3bc34eab68d88b16ae diff --git a/style.css b/style.css new file mode 100644 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; +} diff --git a/widgets.sh b/widgets.sh index 149a813..fd9e72e 100644 --- a/widgets.sh +++ b/widgets.sh @@ -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)" }