From dfdfcfb7ac57a823e639a19d268436753385cbed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Sat, 7 Jul 2018 14:14:00 +0200 Subject: [PATCH] indexing stubs --- .gitmodules | 3 - actions/dirindex.sh | 23 ---- actions/filter.sh | 42 ------- actions/meta.sh | 58 ---------- actions/multitag.sh | 64 ----------- actions/playctl.sh | 69 ------------ actions/preferences.sh | 16 --- actions/transcode.sh | 34 ------ actions/watch.sh | 112 ------------------- globals.sh | 35 ------ index.cgi | 9 ++ list.sh | 68 +++++------ pages/browse.sh | 205 ---------------------------------- pages/common.sh | 116 ------------------- pages/list.sh | 168 ---------------------------- pages/playctl.sh | 92 --------------- pages/quicklinks.sh | 60 ---------- pages/stereoview.sh | 30 ----- pages/view.sh | 46 -------- shcgi | 1 - style.css | 79 +++++++++---- templates/advfilter.html.sh | 81 -------------- templates/browse.html.sh | 93 --------------- templates/download.html.sh | 69 ------------ templates/frame.html.sh | 34 ------ templates/list.html.sh | 90 --------------- templates/playctl.html.sh | 146 ------------------------ templates/preferences.html.sh | 46 -------- templates/quicklinks.html.sh | 63 ----------- templates/tagger.html.sh | 54 --------- templates/view.html.sh | 106 ------------------ widgets.sh | 12 ++ 32 files changed, 114 insertions(+), 2010 deletions(-) delete mode 100755 actions/dirindex.sh delete mode 100755 actions/filter.sh delete mode 100755 actions/meta.sh delete mode 100755 actions/multitag.sh delete mode 100755 actions/playctl.sh delete mode 100755 actions/preferences.sh delete mode 100755 actions/transcode.sh delete mode 100755 actions/watch.sh delete mode 100755 globals.sh delete mode 100755 pages/browse.sh delete mode 100755 pages/common.sh delete mode 100755 pages/list.sh delete mode 100755 pages/playctl.sh delete mode 100755 pages/quicklinks.sh delete mode 100755 pages/stereoview.sh delete mode 100755 pages/view.sh delete mode 160000 shcgi delete mode 100755 templates/advfilter.html.sh delete mode 100755 templates/browse.html.sh delete mode 100755 templates/download.html.sh delete mode 100755 templates/frame.html.sh delete mode 100755 templates/list.html.sh delete mode 100755 templates/playctl.html.sh delete mode 100755 templates/preferences.html.sh delete mode 100755 templates/quicklinks.html.sh delete mode 100755 templates/tagger.html.sh delete mode 100755 templates/view.html.sh diff --git a/.gitmodules b/.gitmodules index ed9b4ba..2b34196 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "shcgi"] - path = shcgi - url = https://git.plutz.net/git/shcgi [submodule "cgilite"] path = cgilite url = https://git.plutz.net/git/cgilite diff --git a/actions/dirindex.sh b/actions/dirindex.sh deleted file mode 100755 index baf99bb..0000000 --- a/actions/dirindex.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/zsh - -# Copyright 2017 Paul Hänsch -# -# This file is part of Serve0. -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0. If not, see . - -directory="$(invalidate "${_GET[d]}" '(.*/)?\.\.(/.*)?|' /)" -mkdir -p "${treeroot}/${directory#/}/.index" - -redirect "?p=browse&d=$(urlsafe "${directory%/}")" diff --git a/actions/filter.sh b/actions/filter.sh deleted file mode 100755 index f5057be..0000000 --- a/actions/filter.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/zsh -# Copyright 2014 - 2016 Paul Hänsch -# -# This file is part of Serve0 -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0 If not, see . - -order=$(validate "${_POST[o]}" 'Name|Length|Date' Name) - -for fn in {0..9}; do - category="$(validate "${_POST[category$fn]}" '[[:alnum:]_-]+' none)" - - n=''; while [ -n "${_POST[cfilter${fn}_$n]}" ]; do - #cfilter="$(validate "${_POST[cfilter${fn}_$n]}" '[[:alnum:]\?!\._=\(\)+-]+' '#')" - cfilter="${_POST[cfilter${fn}_$n]}" - - if [ -z "$n" ]; then - [ -n "$filters" ] && filters="${filters}^" - [ "${_POST[type$fn]}" = 'neg' ] && filters="${filters}!" - n=0 - else - filters="${filters}|" - n=$(($n + 1)) - fi - [ "$category" = "none" ] && filters="${filters}${cfilter}" \ - || filters="${filters}${category}:${cfilter}" - done -done - -printf %s\\n "?o=${order}&f=${filters}" >>${_DATA}/meta/recent -redirect "?o=${order}&f=${filters}" diff --git a/actions/meta.sh b/actions/meta.sh deleted file mode 100755 index ab46894..0000000 --- a/actions/meta.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/zsh -# Copyright 2014 - 2016 Paul Hänsch -# -# This file is part of Serve0 -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0 If not, see . - -cgi_refdata - - info="${_GET[i]:-$_REF[i]}" - order="${_GET[o]}" -search="${_GET[s]}" -filter="${_GET[f]}" - page="${_GET[pn]}" -file="${_DATA}/meta/$info.meta" - -length="${_POST[length]}" - width="${_POST[width]}" -height="${_POST[height]}" - trash="${_POST[trash]}" -cancel="${_POST[cancel]}" -tagacc="${_POST[tag]}" -tags="$(htmlsafe "${_POST[tags]}" |sed -r 's:\t: :g;s:^!|[\r\$\^\|]::g;' |tr '\n' '|')" -description="$(htmlsafe "${_POST[description]}")" - -n=0; while [ -n "${_POST[tag$n]}" ]; do - tagacc="$(htmlsafe ${_POST[tag$n]} |sed -r '2,$d;s:\t| :_:g;s:^!|\r|\$|\^::g;')|$tagacc" - n=$(($n + 1)) -done - -[ -z "$cancel" -a -n "$info" ] && if [ -n "$trash" ]; then - rm "${_DATA}/thumbs/$info.jpg" 2>/dev/null - mv "${_DATA}/videos/$info" "${_DATA}/meta/$info.meta" "${_DATA}/trash/" 2>/dev/null - rm "${_DATA}/cache/$info.cache" 2>/dev/null - rm ${_DATA}/cache/\?* 2>/dev/null -else - cat >$file </dev/null - rm ${_DATA}/cache/\?* 2>/dev/null - rm ${_DATA}/cache/taglist_set ${_DATA}/cache/taglist_filter 2>/dev/null -fi - -redirect "${_POST[referrer]:-?i=&pn=${page}&s=${search}&f=${filter}&o=${order}#${info}}" diff --git a/actions/multitag.sh b/actions/multitag.sh deleted file mode 100755 index b38b204..0000000 --- a/actions/multitag.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/zsh -# Copyright 2014 - 2017 Paul Hänsch -# -# This file is part of Serve0 -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0 If not, see . - -backlink="${_POST[page]}" - -addtag(){ - meta="$1" - tag="$2" - - length=0; width=0; height=0; - if [ -r "$meta" ]; then - head -n1 "$meta" |read length width height info - tags="$(sed -n 2p "$meta" |sed -r 's:^\|(.*)$:\1:')" - description="$(sed -n '3,$p' "$meta")" - fi - - egrep -q "(^|.*\|)$tag(\|.*|$)" <<<"$tags" || tags="$tag|$tags" - - cat <"$meta" -$length $width $height $info -$tags -$description -EOF -} - -n='' -while [ -n "${_POST[tagsel$n]}" ]; do - tagsel="${_POST[tagsel$n]}" - ( t='' - while [ -n "${_POST[ctag$t]}" ]; do - htmlsafe "${_POST[ctag$t]}" - printf \\n - [ -z "$t" ] && t=0 || t=$(($t + 1)) - done - htmlsafe "${_POST[tags]}" - printf \\n - ) | sed -r 's:\t: :g;s:^!|[\r\$\^\|]::g;' \ - | while read tag; do - addtag "${_DATA}/meta/$tagsel.meta" "$tag" - done - rm "${_DATA}/cache/$tagsel.cache" 2>/dev/null - - n=$((${n:--1} + 1)) -done - -rm "${_DATA}"/cache/\?* 2>/dev/null -[ -n "${_POST[tags]}" ] && rm "${_DATA}"/cache/taglist_set "${_DATA}"/cache/taglist_filter 2>/dev/null - -redirect "$backlink#$tagsel" diff --git a/actions/playctl.sh b/actions/playctl.sh deleted file mode 100755 index ae1a51b..0000000 --- a/actions/playctl.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/zsh -# Copyright 2016 Paul Hänsch -# -# This file is part of Serve0 -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0 If not, see . - -fifofile="${_DATA}/mplayer.fifo" -statusfile="${_DATA}/mplayer.status" -statusfile="/tmp/mplayer.status" -volfile="${_DATA}/mplayer.volume" - -[ -z "$DISPLAY" ] && export DISPLAY=":0" -[ -z "$XDG_RUNTIME_DIR" ] && export XDG_RUNTIME_DIR="/run/user/$(id |sed -rn '1s;.*uid=([0-9]+)[^0-9].*;\1;p')" - -printf '\rBREAK\r' >> "$statusfile" - -if [ "${_GET[api]}" = progress ]; then - cr="$(printf \\r)" - printf 'Content-Type: text/plain\r\n\r\n' - - read length <${_DATA}/mplayer.meta - tail --pid=$$ -c100 -f "$statusfile" \ - | while read -d "$cr" line; do - [ "$line" = "BREAK" ] && exit 0 - printf '%s\n' "$line" - done \ - | sed -urn '1~12s;^.* V: *+([0-9]+)(\.[0-9]+) A-V:.*$;\1;p' - exit 0 -elif [ "${_GET[api]}" = volume ]; then - printf 'Content-Type: text/plain\r\n\r\n' - validate "$(cat "$_DATA/mplayer.volume")" '[1-9]?[0-9]|100' 20 - exit 0 -fi - -if [ -n "${_POST[amp]+x}" ]; then - amp $(validate "${_POST[amp]}" '(on|off)' off) -elif [ -n "${_POST[vol]+x}" ]; then - vol=$(validate "${_POST[vol]}" '[1-9]?[0-9]|100' 10) - printf %s\\n $vol >"$volfile" - printf 'volume %s 1\n' $vol >"$fifofile" -elif [ -n "${_POST[ctl]+x}" ]; then - printf '%s\n' $(validate "${_POST[ctl]}" "pause|stop" pause) >"$fifofile" -elif [ -n "${_POST[seek]+x}" ]; then - printf 'seek %s\n' $(validate "${_POST[seek]}" "[+-]?[0-9]+" 0) >"$fifofile" -elif [ -n "${_POST[pasink]+x}" ]; then - stream="$(\ - pactl list sink-inputs \ - | sed -rn '/Sink Input #/{:X;N;/application.name =/!bX;s;Sink Input #([0-9]+).+application.name = "(MPlayer|mplayer2)";\1;p}' \ - )" - pactl move-sink-input "$stream" "${_POST[pasink]}" -elif [ -n "${_POST[osd]+x}" ]; then - case ${_POST[osd]} in - progression) printf "osd_show_progression\\n";; - esac >"$fifofile" -fi & - -redirect "${_POST[referrer]}" diff --git a/actions/preferences.sh b/actions/preferences.sh deleted file mode 100755 index f9c2707..0000000 --- a/actions/preferences.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/zsh - -fakemp4=$( validate "${_POST[fakemp4]}" yes no) -watch=$( validate "${_POST[watch]}" '(240p|480p|download|raspi|player|server)' player) -pagesize=$(validate "${_POST[pagesize]}" '[1-9][0-9]*' 50) - -debug '== Setting Preferences ==' -debug "fakemp4 = $fakemp4" -debug "watch = $watch" -debug "pagesize = $pagesize" - -set_cookie '+ 1 month' "fakemp4=${fakemp4}" HttpOnly -set_cookie '+ 1 month' "watch=${watch}" HttpOnly -set_cookie '+ 1 month' "pagesize=${pagesize}" HttpOnly - -redirect "$_POST[referrer]" diff --git a/actions/transcode.sh b/actions/transcode.sh deleted file mode 100755 index 35ff8f4..0000000 --- a/actions/transcode.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/zsh -# Copyright 2015 - 2016 Paul Hänsch -# -# This file is part of Serve0 -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0 If not, see . - -info="${_GET[i]}" -target="${_GET[t]}" -video="${_DATA}/videos/$info" -meta="${_DATA}/meta/$info.meta" -trans="${_DATA}/transcoded/${info}.${target}p.webm" - -head -n1 "$meta" |read length width height name - -twidth=$(($width * $target / $height)) - -if ! [ -f "$trans" ]; then - [ "$target" -le 240 ] && nohup avconv -i "$video" -s "${twidth}x${target}" -b:a 80k -threads auto "$trans" & - [ "$target" -gt 240 ] && nohup avconv -i "$video" -s "${twidth}x${target}" -threads auto "$trans" & -fi - -redirect "/transcoded/${info}.${target}p.webm" diff --git a/actions/watch.sh b/actions/watch.sh deleted file mode 100755 index 1ba0954..0000000 --- a/actions/watch.sh +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/zsh - -cgi_refdata -info="${_GET[i]}" -location="$(invalidate "${_GET[l]}" '(.*/)?\.\.(/.*)?|' /)" -foreign="$(validate "${_GET[url]}" 'https?://.*' '')" -order="${_POST[o]}" -search="${_POST[s]}" -filter="${_POST[f]}" -page="${_POST[pn]}" - -watch_link="${_POST[page]}&" -[ -n "$location" ] && watch_link="l=$(urlsafe "${location}")&" -[ -n "$info" ] && watch_link="i=$(urlsafe "${info}")&" - -meta="${_DATA}/meta/$info.meta" -head -n1 "$meta" |read length width height filename -[ "$length" -gt 0 ] || length=0 -[ "$width" -gt 0 ] || width=0 -[ "$height" -gt 0 ] || height=0 - -linkinfo="$(urlsafe "$info")" - -if [ "${_COOKIE[fakemp4]}" = yes ]; then - fakename="$(printf %s "${info}" |sed -r 's;.*/;;g; s;.[^.]+$;;; s;\.;_;g;')" - if [ "$info" != "${fakename}.mp4" ]; then - [ -e "${_DATA}/mp4/${fakename}.mp4" ] || ln -s "${_DATA}/videos/$info" "${_DATA}/mp4/${fakename}.mp4" - videourl="$(urlsafe "mp4/${fakename}.mp4")" - else - videourl="$(urlsafe "videos/$info")" - fi -elif [ -n "$foreign" ]; then - _COOKIE[watch]=server - videourl="${_GET[url]}" - watch_link="w=$(urlsafe "${_GET[return]}")" -elif [ -z "$info" ]; then - videourl="$(urlsafe "${location#/}")" -else - videourl="$(urlsafe "videos/$info")" -fi - -case "$_COOKIE[watch]" in - raspi) - ncat "$RHOST" "$RPORT" >&- <<-EOF - GET /?action=watch&url=$(urlsafe "http://${HTTP_HOST}/${videourl}") HTTP/1.1$(printf \\r) - Host: ${RHOST}$(printf \\r) - $(printf \\r) - EOF - redirect "?p=playctl&${watch_link}w=$(urlsafe "${_POST[page]}#${_GET[i]}")" - ;; - 480p) - [ $height -gt 480 ] && redirect "?action=transcode&i=${linkinfo}&t=480" \ - || redirect "$videourl" - ;; - 240p) - [ $height -gt 240 ] && redirect "?action=transcode&i=${linkinfo}&t=240" \ - || redirect "$videourl" - ;; - download) - redirect "$videourl" - ;; - server) - [ -n "$location" ] && playuri="${treeroot%/}/${location#/}" - [ -n "$info" ] && playuri="${_DATA}/videos/$info" - [ -n "$foreign" ] && playuri="$videourl" - - metafile="${_DATA}/meta/${info}.meta" - - playmeta="${_DATA}/mplayer.meta" - fifofile="${_DATA}/mplayer.fifo" - statusfile="${_DATA}/mplayer.status" - statusfile="/tmp/mplayer.status" - volume="$(validate "$(cat "${_DATA}/mplayer.volume" || true)" '[1-9]?[0-9]|100' 20)" - [ \! -p "$fifofile" ] && rm -f "$fifofile" && mkfifo -m 600 "$fifofile" - - debug PLAYURI "$playuri" - - if [ -f "$metafile" ]; then - cp "$metafile" "$playmeta" - else - rm "$playmeta" - "${_EXEC}"/helpers/genmeta.sh "$playuri" "$playmeta" >&- - fi - - export DISPLAY=":0" - uid="$(id |sed -rn '1s;.*uid=([0-9]+)[^0-9].*;\1;p')" - export XDG_RUNTIME_DIR="/run/user/$uid" # required for Pulseaudio - xrandr || true >&- # helps enable all screens - xvkbd -text '\x+10000\y+10000' || true >&- - - if mplayer |grep -q MPlayer2; then - nohup /usr/bin/mplayer \ - --slave --input=file="$fifofile" \ - --volume="$volume" \ - "$playuri" 2>"$statusfile" >&- & - else - nohup /usr/bin/mplayer \ - -slave -input file="$fifofile" \ - -volume "$volume" \ - "$playuri" >"$statusfile" & - fi - - chmod 600 "$statusfile" - - redirect "?p=playctl&${watch_link}" - ;; - *) redirect "?p=view&${watch_link}" - ;; -esac - - - diff --git a/globals.sh b/globals.sh deleted file mode 100755 index 402cba2..0000000 --- a/globals.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/zsh - -# Copyright 2014 - 2017 Paul Hänsch -# -# This file is part of Serve0. -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0. If not, see . - -alias _wiki="stx2any --no-template --link-abbrevs --quote -T html" -file_pattern='^.*\.(mov|ts|mpg|mpeg|mp4|m4v|avi|mkv|flv|sfv|wmv|ogm|ogv|webm|iso|rmvb)$' - -data_dirs cache meta mp4 videos thumbs trash transcoded - -PAGE="${_GET[p]:-${PAGE:-browse}}" -treeroot="${treeroot:-${_DATA}}" - -_GET[o]=$( validate "${_GET[o]}" 'Name|Date|Length' Name) -_GET[pn]=$(validate "${_GET[pn]}" '[1-9][0-9]*' 1) - -cgi_cookie -_COOKIE[pagesize]=$(validate "${_COOKIE[pagesize]}" '[1-9][0-9]*' 50) - -[ -z "$RHOST" ] && RHOST=localhost -[ -z "$RPORT" ] && RPORT=80 diff --git a/index.cgi b/index.cgi index 7b4921a..000e855 100755 --- a/index.cgi +++ b/index.cgi @@ -40,6 +40,15 @@ elif [ -f "$_DATA/$ITEM" ]; then esac elif [ -d "$_DATA/$ITEM" ]; then case $(GET a) in + spawnindex) + if [ "$(POST recursive)" = yes ]; then + find "$_DATA/$ITEM" -depth -type d \! -name .index \ + -exec mkdir -p '{}'/.index \; + else + mkdir -p "$_DATA/$ITEM/.index" + fi + REDIRECT "$(POST ref)" + ;; multitag) ;; *) . "$_EXEC/list.sh" diff --git a/list.sh b/list.sh index 8d76f18..61099e7 100644 --- a/list.sh +++ b/list.sh @@ -13,32 +13,31 @@ list_item(){ fi } -list_dirs(){ - [ "$ITEM" ] && printf '..\n' - (cd "$_DATA/$ITEM"; - find ./ -type d -mindepth 1 -maxdepth 1 \ - -exec stat -c '%Y %n' '{}' + - ) \ - | { [ "$(GET o)" = Date ] && sort -rn || sort -k 2; } \ - | cut -d/ -f2- -} - -list_files(){ - (cd "$_DATA/$ITEM"; - find ./ -type f -mindepth 1 -maxdepth 1 \ - -exec stat -c '%Y %n' "${f#./}" '{}' + 2>&- - ) \ - | { [ "$(GET o)" = Date ] && sort -rn || sort -k 2; } \ - | cut -d/ -f2- -} +list_items(){ + mode="$(COOKIE mode |grep -m1 -xE 'index|browse' || printf browse )" -list_tree(){ - (cd "$_DATA/$ITEM"; - find ./ -type f \ - -exec stat -c '%Y %n' '{}' + - ) \ - | { [ "$(GET o)" = Date ] && sort -rn || sort -k 2; } \ + [ "$mode" = browse -a "$ITEM" ] && printf '..\n' + if [ "$mode" = browse ]; then + [ -d "$_DATA/$ITEM/.index" -a "$_DATA/$ITEM" -nt "$_DATA/$ITEM/.index/meta" ] \ + && . "$_EXEC/update_meta.sh" + (cd "$_DATA/$ITEM"; + find ./ -type d \! -name .index -mindepth 1 -maxdepth 1 \ + -exec stat -c '%Y %n' '{}' + + find ./ -type f -mindepth 1 -maxdepth 1 \ + -exec stat -c '%Y %n' '{}' + + ) + elif [ "$mode" = index ]; then + (cd "$_DATA/$ITEM"; + find ./ -type f \ + -exec stat -c '%Y %n' '{}' + + ) + fi \ + | case $ORDER in + Date) sort -rn;; + Name) sort -k 2;; + esac \ | cut -d/ -f2- + } list_paginate(){ @@ -70,17 +69,20 @@ printf 'Content-Type: text/html;charset=utf-8\r\n\r\n' [html [head [title Listing] [link rel=stylesheet href="/style.css" ] ] [body - $(w_search) - [input type=checkbox #t_prefs .toggle ][label for=t_prefs ⚙] + [div #navigation + [a #t_bookmarks href="#bookmarks" ★] + $(w_search) + [a #t_avsearch href="#advsearch" Advanced] + [a #t_prefs href="#prefs" ⚙] + ] $(w_prefs) - $(if [ "$(COOKIE mode)" = index ]; then - list_tree - else - list_dirs - list_files - fi \ - | list_paginate + + $(list_items \ + | list_paginate ) + [div #editing + $(w_index) + ] ] ] EOF diff --git a/pages/browse.sh b/pages/browse.sh deleted file mode 100755 index faf4e67..0000000 --- a/pages/browse.sh +++ /dev/null @@ -1,205 +0,0 @@ -#!/bin/zsh - -# Copyright 2014 - 2017 Paul Hänsch -# -# This file is part of Serve0. -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0. If not, see . - -directory="$(invalidate "${_GET[d]}" '(.*/)?\.\.(/.*)?|' /)" -page_link="p=browse&d=$(urlsafe "$directory")&" - -. $_EXEC/pages/common.sh - -[ -d "${treeroot%/}${directory%/}/.index" ] && indexed=true || indexed=false -filters="${_GET[f]}" -debug "FILTERS: $filters" - -present_filter(){ - printf %s\\n "$*" \ - | sed -r 's;(^|!|\^|\|)([^!\^\|:]+:);\1;g;s;\^;\n;g' \ - | sort -r \ - | sed -r '$q;s;$; \&\; ;g' -} - -if [ -n "$search" ]; then - TITLE="$search by $order" -elif [ -n $filter ]; then - TITLE="$(present_filter "$filter") by $order" -else - TITLE="List by $order" -fi - -category_selected(){ - cat="${1}:" - filter="$2" - [ "$cat" = "none:" ] && cat='' - - printf %s "$taglist_filter" \ - | sed -r 's;^('"$filter"')$;1 &;;t;s;^;0 ;' \ - | sed -rn 's;^(0|1) '"$cat"'([^:]+)$;\1 \2;p' \ - | sed 's;^0 ;;' -} - -_printVideo(){ - name="$1" - - video="${treeroot%/}${directory%/}/${name}" - thumb="${treeroot%/}${directory%/}/.index/${name}.jpg" - meta="${treeroot%/}${directory%/}/.index/${name}.meta" - - [ -f "$thumb" ] || genthumb "$video" "$thumb" - [ -f "$meta" ] || genmeta "$video" "$meta" - - { read -r length width height filename - read -r tags - } <"$meta" - read length width height <<-EOF - $(validate "$length $width $height" '[0-9]+ [0-9]+ [0-9]+' "0 0 0") - EOF - - location="$(attribsafe "${directory%/}/${name}")" - thumblocation="$(attribsafe "${directory%/}/.index/${name}.jpg")" - display="$(htmlsafe "$name")" - - minutes="$(printf "%d:%02d" $(($length / 60)) $(($length % 60)) )" - - cat < - -

${display}

- - - ${minutes}min - ${width}x${height} - $(printf %s "$tags" |sed -r 's:\|*([^|]+)\|*: \1:g') - -VIDEOend -} - -selectionlist() { - cachebase="?o=${order}&s=${search//\//}&f=${filter//\//}" - cache="${_DATA}/cache/${cachebase}" - if [ -s "$cache" -a "$cache" -nt ${_DATA}/videos -a "$cache" -nt ${_DATA}/meta ]; then - cat "$cache" - else - filterex="s;^([0-9]+\t){3}(.+)\n.*$;\2;p" - printf '%s\n' "$filter" |tr '^' '\n' \ - | sed -r 's;[]\/\(\)\\\^\$\?\.\+\*\;\[\{\}];\\\\&;g' \ - | while read each; do - [ "${each:0:1}" = '!' ] && filterex="/^[^\n]+\n(.*\|)?(${each#?})(\|.*)?$/d;{${filterex}}" \ - || filterex="/^[^\n]+\n(.*\|)?(${each})(\|.*)?$/{${filterex}}" - done - - genlist \ - | if [ -n "$search" ] ; then - debug "Applying search: ${search}" - xargs -d '\n' printf "${_DATA}/meta/%s.meta\n" \ - | xargs -d '\n' egrep -sil "$search" \ - | sed -r 's;^.*/;;;s;\.meta$;;' - elif [ -n "$filter" ]; then - debug "Applying filters: ${filter} ++ ${filterex}" - xargs -d '\n' printf "${_DATA}/meta/%s.meta\n" \ - | xargs -d '\n' sed -srn ":a;N;2!ba;{${filterex}}" - else - debug "No search or filtering" - cat - fi \ - | tee "$cache" - fi -} - -filelist(){ - dir="${treeroot%/}${directory%/}" - - case "$order" in - Name) - find -L "$dir" -mindepth 1 -maxdepth 1 -type d \! -name ".index" -print0 \ - | sort -fz \ - | xargs -0 printf 'directory %s\n' - - find -L "$dir" -mindepth 1 -maxdepth 1 \! -type d -print0 \ - | grep -ziE "$file_pattern" \ - | sort -fz \ - | xargs -0 printf 'video %s\n' - - find -L "$dir" -mindepth 1 -maxdepth 1 \! -type d -print0 \ - | grep -zviE "$file_pattern" \ - | sort -fz \ - | xargs -0 printf 'plain %s\n' - ;; - Date) - find -L "$dir" -mindepth 1 -maxdepth 1 -type d \! -name ".index" -print0 \ - | xargs -0 stat -c '%Z directory %n' \ - | sort -r |cut -c12- - - find -L "$dir" -mindepth 1 -maxdepth 1 \! -type d -print0 \ - | grep -ziE "$file_pattern" \ - | xargs -0 stat -c '%Y video %n' \ - | sort -r |cut -c12- - - find -L "$dir" -mindepth 1 -maxdepth 1 \! -type d -print0 \ - | grep -zviE "$file_pattern" \ - | xargs -0 stat -c '%Y plain %n' \ - | sort -r |cut -c12- - ;; - Length) - find -L "$dir" -mindepth 1 -maxdepth 1 -type d \! -name ".index" -print0 \ - | sort -z \ - | xargs -0 printf 'directory %s\n' - - head -qn1 "${dir}"/.index/*.meta \ - | sort \ - | cut -f4- \ - | tr \\n \\0 \ - | xargs -0 printf 'video %s\n' - - find -L "$dir" -mindepth 1 -maxdepth 1 \! -type d -print0 \ - | grep -zviE "$file_pattern" \ - | sort -z \ - | xargs -0 printf 'plain %s\n' - ;; - esac -} - -thumblist(){ - debug "Filelist with dir = $directory" - - [ -n "${directory#/}" ] && printf %s ".." - - filelist \ - | sed -n "$page,$(($page + $pagesize - 1))p" \ - | while read -r type name; do - case $type in - directory) - printf '%s\n' \ - "$(urlsafe "${directory%/}/${name##*/}")" "$(htmlsafe "${name##*/}")" - ;; - video) - $indexed && _printVideo "${name##*/}" \ - || printf '%s\n' \ - "$(urlsafe "${directory%/}/${name##*/}")" "$(htmlsafe "${name##*/}")" - ;; - plain) - printf '%s\n' "$(htmlsafe "${name##*/}")" - ;; - esac - done -} - -pagecount() { - printf "$(( $(filelist | wc -l) / $pagesize + 1 ))" -} diff --git a/pages/common.sh b/pages/common.sh deleted file mode 100755 index 7532055..0000000 --- a/pages/common.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/zsh - -# Copyright 2014 - 2016 Paul Hänsch -# -# This file is part of Serve0. -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0. If not, see . - -filter="${_GET[f]}" -search="${_GET[s]}" -order="${_GET[o]}" #validated -page="${_GET[pn]}" #validated -pagesize="${_COOKIE[pagesize]}" #validated -pagecount=0 - -#page_link='' -[ -n "$info" ] && page_link="${page_link}i=$(urlsafe "$info")&" -[ -n "$order" ] && page_link="${page_link}o=${order}&" -[ -n "$search" ] && page_link="${page_link}s=${search}&" -[ -n "$filter" ] && page_link="${page_link}f=${filter}&" -[ "$page" -le "$pagesize" ] && page_prev="${page_link}pn=1" || page_prev="${page_link}pn=$(($page - $pagesize))" -page_next="${page_link}pn=$(($page + $pagesize))" -page_this="${page_link}pn=$page" - -taglist_set=$( - if [ -r ${_DATA}/cache/taglist_set ]; then - cat ${_DATA}/cache/taglist_set - else - truncate -s0 ${_DATA}/cache/taglist_set - truncate -s0 ${_DATA}/cache/tagnorm - - ( sed -sn '2s;|;\n;gp' "${_DATA}/meta/"*.meta \ - | sort - printf \\n - ) | while read tag; do - if [ "$tag" = "$lasttag" ]; then - tagcount=$(( ${tagcount:-0} + 1 )) - else - [ -n "$lasttag" ] && printf '%s\t%s\n' "$tagcount" "$lasttag" - tagcount=1 - fi - lasttag="$tag" - done \ - | sort -rn \ - | while read x tag; do - topcnt=$(grep -c "${tag%%:*}" ${_DATA}/cache/taglist_set) - [ $topcnt -lt 10 ] \ - && printf %s\\n "$tag" >>${_DATA}/cache/taglist_set \ - || printf %s\\n "$tag" >>${_DATA}/cache/tagnorm - done - - cat ${_DATA}/cache/taglist_set - sort ${_DATA}/cache/tagnorm \ - | tee -a ${_DATA}/cache/taglist_set - rm ${_DATA}/cache/tagnorm - fi -) - -taglist_filter=$( - if [ -r ${_DATA}/cache/taglist_filter ]; then - cat ${_DATA}/cache/taglist_filter - else - truncate -s0 ${_DATA}/cache/taglist_filter - truncate -s0 ${_DATA}/cache/tagnorm - - sed -sn '2s;|;\n;gp' "${_DATA}/meta/"*.meta \ - | sort -u \ - | while read tag; do - cnt="$(grep -cF "$tag" ${_DATA}/meta/recent)" - printf '%s\t%s\n' "$cnt" "$tag" - done \ - | sort -rn \ - | while read x tag; do - topcnt=$(grep -c "${tag%%:*}" ${_DATA}/cache/taglist_filter) - [ $topcnt -lt 10 ] \ - && printf %s\\n "$tag" >>${_DATA}/cache/taglist_filter \ - || printf %s\\n "$tag" >>${_DATA}/cache/tagnorm - done - - cat ${_DATA}/cache/taglist_filter - sort ${_DATA}/cache/tagnorm \ - | tee -a ${_DATA}/cache/taglist_filter - rm ${_DATA}/cache/tagnorm - fi -) - -list_categories(){ - printf none\\n - printf %s "$taglist_filter" |sed -rn 's;^([^:]+):.*$;\1;p' |sort -u -} - -genthumb(){ - videofile="$1" - thumb="$2" - - nohup nice -10 "${_EXEC}"/helpers/genthumb.sh "$videofile" "$thumb" >/dev/null 2>/dev/null & - #printf '%s\n' "${_EXEC}/helpers/genthumb.sh '$videofile' '$thumb' >/dev/null 2>/dev/null" \ - #| batch -} -genmeta(){ - videofile="$1" - meta="$2" - - "${_EXEC}"/helpers/genmeta.sh "$videofile" "$meta" >/dev/null -} diff --git a/pages/list.sh b/pages/list.sh deleted file mode 100755 index 89576f8..0000000 --- a/pages/list.sh +++ /dev/null @@ -1,168 +0,0 @@ -#!/bin/zsh - -# Copyright 2014 - 2017 Paul Hänsch -# -# This file is part of Serve0. -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0. If not, see . - -page_link="p=list&" - -. $_EXEC/pages/common.sh - -LF=' -' -filters="${_GET[f]}" -debug "FILTERS: $filters" - -present_filter(){ - printf %s\\n "$*" \ - | sed -r 's;(^|!|\^|\|)([^!\^\|:]+:);\1;g;s;\^;\n;g' \ - | sort -r \ - | sed -r '$q;s;$; \&\; ;g' -} - -if [ -n "$search" ]; then - TITLE="$search by $order" -elif [ -n $filter ]; then - TITLE="$(present_filter "$filter") by $order" -else - TITLE="List by $order" -fi - -category_selected(){ - cat="${1}:" - filter="$2" - [ "$cat" = "none:" ] && cat='' - - printf %s "$taglist_filter" \ - | sed -r 's;^('"$filter"')$;1 &;;t;s;^;0 ;' \ - | sed -rn 's;^(0|1) '"$cat"'([^:]+)$;\1 \2;p' \ - | sed 's;^0 ;;' -} - -_printVideo(){ - info="$1" - cache="${_DATA}/cache/$info.cache" - meta="${_DATA}/meta/$info.meta" - - if [ "$cache" -nt "$meta" ]; then - cat "$cache" - else - videofile="${_DATA}/videos/$info" - thumb="${_DATA}/thumbs/${info}.jpg" - [ -r "$thumb" ] || genthumb "$videofile" "$thumb" - [ -r "$meta" ] || genmeta "$videofile" "$meta" - - head -n1 "$meta" |read length width height filename - length=$(validate "$length" '[0-9]+' 0) - width=$(validate "$width" '[0-9]+' 0) - height=$(validate "$height" '[0-9]+' 0) - - tags="$(sed -n 2p "$meta")" - video="$(urlsafe "videos/$info")" - thumb="$(urlsafe "thumbs/$info.jpg")" - linkinfo="$(urlsafe "$info")" - htmlinfo="$(htmlsafe "$info")" - attrinfo="$(attribsafe "$info")" - - minutes="$(printf "%d:%02d" $(($length / 60)) $(($length % 60)) )" - - { tr -d '\n' |tee "$cache"; } <<-VIDEOend -
  • - -

    ${htmlinfo}

    - - - ${minutes}min - ${width}x${height} - $(printf %s "$tags" |sed -r 's:\|*([^|]+)\|*: \1:g') -
  • -VIDEOend - fi -} - -genlist(){ - case "$order" in - Date) - find "${_DATA}"/videos/ -maxdepth 1 -mindepth 1 -printf '%i\t%p\n' \ - | sort -n \ - | while read i file; do printf '%s\000' "$file"; done \ - | xargs -0 stat -c '%Y %n' \ - | sort -nr \ - | cut -f2- \ - | sed 's;^.*/;;g;' \ - | egrep -i "$file_pattern" - ;; - Length) - sed -sn 1p "${_DATA}"/meta/*.meta \ - | sort -n \ - | sed -r 's;^[0-9\t]+\t;;' \ - | while read file; do - [ -f "${_DATA}/videos/${file}" ] && printf '%s\n' "$file" - done - ;; - Name) - find "${_DATA}"/videos/ -maxdepth 1 -mindepth 1 -printf '%f\n' \ - | sort -f \ - | egrep -i "$file_pattern" - ;; - esac -} - -selectionlist() { - cachebase="?o=${order}&s=${search//\//}&f=${filter//\//}" - cache="${_DATA}/cache/${cachebase}" - if [ -s "$cache" -a "$cache" -nt ${_DATA}/videos -a "$cache" -nt ${_DATA}/meta ]; then - cat "$cache" - else - filterex="s;^([0-9]+\t){3}(.+)\n.*$;\2;p" - printf '%s\n' "$filter" |tr '^' '\n' \ - | sed -r 's;[]\/\(\)\\\^\$\?\.\+\*\;\[\{\}];\\\\&;g' \ - | while read each; do - [ "${each:0:1}" = '!' ] && filterex="/^[^\n]+\n(.*\|)?(${each#?})(\|.*)?$/d;{${filterex}}" \ - || filterex="/^[^\n]+\n(.*\|)?(${each})(\|.*)?$/{${filterex}}" - done - - genlist \ - | if [ -n "$search" ] ; then - debug "Applying search: ${search}" - xargs -d '\n' printf "${_DATA}/meta/%s.meta\n" \ - | xargs -d '\n' egrep -sil "$search" \ - | sed -r 's;^.*/;;;s;\.meta$;;' - elif [ -n "$filter" ]; then - debug "Applying filters: ${filter} ++ ${filterex}" - xargs -d '\n' printf "${_DATA}/meta/%s.meta\n" \ - | xargs -d '\n' sed -srn ":a;N;2!ba;{${filterex}}" - else - debug "No search or filtering" - cat - fi \ - | tee "$cache" - fi -} - -thumblist() { - selectionlist \ - | sed -n "$page,$(($page + $pagesize - 1))p" \ - | while read line; do - _printVideo "$line" - done -} - -pagecount() { - printf "$(( $(selectionlist | wc -l) / $pagesize + 1 ))" -} diff --git a/pages/playctl.sh b/pages/playctl.sh deleted file mode 100755 index f8247e0..0000000 --- a/pages/playctl.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/zsh - -# Copyright 2014, 2016, 2017 Paul Hänsch -# -# This file is part of Serve0. -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0. If not, see . - -. $_EXEC/pages/common.sh - -CR="$(printf \\r)" - -info="${_GET[i]}" -location="$(invalidate "${_GET[l]}" '(.*/)?\.\.(/.*)?|' /)" -directory="${location%/*}" -statusfile="$_DATA/mplayer.status" -statusfile="/tmp/mplayer.status" - -if [ -n "$info" ]; then - video="${_DATA}/videos/$info" - meta="${_DATA}/meta/${info}.meta" -else - video="${treeroot%/}/${location#/}" - meta="${treeroot%/}${location%/*}/.index/${location##*/}.meta" -fi - -[ -r "$meta" ] || meta="${_DATA}/mplayer.meta" - -tags="$(sed -n '2p' "$meta")" -description="$(sed -n '3,$p' "$meta")" -head -n1 "$meta" |read length width height TITLE - -debug VIDEO: $video - -if [ "$_COOKIE[watch]" = raspi ]; then - actionuri="//${RHOST}:${RPORT}/?action=playctl" - volume="$({ncat "$RHOST" "$RPORT" <<-EOF - GET /?action=playctl&api=volume HTTP/1.0${CR} - Host: ${RHOST}${CR} - ${CR} - EOF - } | sed -r '1,/^\r$/d')" - volume=$(validate "${volume}" '[1-9]?[0-9]|100' 20) -else - actionuri='?action=playctl' - volume=$(validate "$(cat "$_DATA/mplayer.volume")" '[1-9]?[0-9]|100' 20) -fi - -pa_sinks(){ - if which pactl >/dev/null; then - export DISPLAY=":0" - export XDG_RUNTIME_DIR="/run/user/$(id |sed -rn '1s;.*uid=([0-9]+)[^0-9].*;\1;p')" - - pactl list sinks \ - | sed -rn '/Sink #/{:X;N;/Description: /!bX;s;Sink #([0-9]+).+Description: (.*);\1 \2;p}' - fi -} - -printf 'Refresh: 1\r\n' - -progress(){ - if [ "$_COOKIE[watch]" = raspi ]; then - { ncat "$RHOST" "$RPORT" <<-EOF - GET /?action=playctl&api=progress HTTP/1.0${CR} - Host: ${RHOST}${CR} - ${CR} - EOF - } | sed -ur '1,/^\r$/d' - else - tail --pid=$$ -c100 -f "$statusfile" \ - | while read -d "$CR" line; do - [ "$line" = "BREAK" ] && exit 0 - printf '%s\n' "$line" - done \ - | sed -urn '1~12s;^.* V: *+([0-9]+)(\.[0-9]+) A-V:.*$;\1;p' - fi \ - | while read m; do - [ "$m" != "$previous" ] && printf "%d %d\n" "$(($m * 100 / ${length:--1}))" "$m" - previous="$m" - done -} diff --git a/pages/quicklinks.sh b/pages/quicklinks.sh deleted file mode 100755 index f22a412..0000000 --- a/pages/quicklinks.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/zsh - -# Copyright 2014 - 2016 Paul Hänsch -# -# This file is part of Serve0. -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0. If not, see . - -. $_EXEC/pages/common.sh - -LF=' -' -filters="${_GET[f]}" -debug "FILTERS: $filters" - -present_filter(){ - printf %s "$*" |sed -nr '1s;^.*(\?|&)o=([^&]+)&?.*$;by \2: ;p' - - printf %s "$*" \ - | sed -nr '1s;^.*(\?|&)f=([^&]+)&?.*$;\2;p' \ - | sed -r 's;(^|!|\^|\|)([^!\^\|:]+:);\1;g;s;\^;\n;g' \ - | sort -r \ - | sed -r ':X;N;$!bX;s;\n; \&\; ;g' -} - -quicklinks(){ - output='' - tac ${_DATA}/meta/recent \ - | while [ "$(printf %s "$output" |wc -l)" -lt 30 ] && read line; do - norm="$(present_filter "$line")" - printf %s "$output" |grep -qF "$norm" || output="$output$line $norm$LF" - done - printf %s "$output" |while read line norm; do - printf '%s' \ - "$line" "${norm}" - done -} - -category_selected(){ - cat="${1}:" - filter="$2" - [ "$cat" = "none:" ] && cat='' - - printf %s "$taglist_filter" \ - | sed -r 's;^('"$filter"')$;1 &;;t;s;^;0 ;' \ - | sed -rn 's;^(0|1) '"$cat"'([^:]+)$;\1 \2;p' \ - | sed 's;^0 ;;' -} - diff --git a/pages/stereoview.sh b/pages/stereoview.sh deleted file mode 100755 index 3f7a986..0000000 --- a/pages/stereoview.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/zsh - -# Copyright 2018 Paul Hänsch -# -# This file is part of Serve0. -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0. If not, see . - -. $_EXEC/pages/common.sh - -info="${_GET[i]}" -render="$(validate "${_GET[r]}" '(180|360)' 360)" -location="$(invalidate "${_GET[l]}" '(.*/)?\.\.(/.*)?|' /)" -directory="${location%/*}" - -TITLE="$info" - -[ -n "$info" ] && video="videos/$info" \ - || video="${location#/}" diff --git a/pages/view.sh b/pages/view.sh deleted file mode 100755 index fef4f78..0000000 --- a/pages/view.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/zsh - -# Copyright 2014 2016 Paul Hänsch -# -# This file is part of Serve0. -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0. If not, see . - -. $_EXEC/pages/common.sh - -info="${_GET[i]}" -location="$(invalidate "${_GET[l]}" '(.*/)?\.\.(/.*)?|' /)" -directory="${location%/*}" - -TITLE="$info" - -meta="${_DATA}/meta/$info.meta" -[ -n "$info" ] && video="${_DATA}/videos/$info" \ - || video="${treeroot%/}/${location#/}" -tags="$(sed -n '2p' "$meta")" -description="$(sed -n '3,$p' "$meta")" -length=0; width=0; height=0; - -debug "Analysing video: $video" -printf '' |mplayer -input nodefault-bindings -nosound -vo null -identify -frames 0 "$video" \ -| sort \ -| sed -rn 's:ID_LENGTH=(.*)(\..*)$:\1:p; - s:ID_VIDEO_HEIGHT=(.*):\1:p; - s:ID_VIDEO_WIDTH=(.*):\1:p;' \ -| tr '\n' ' ' \ -| read length height width 2>/dev/null - -video="videos/$info" -[ -n "$info" ] && video="videos/$info" \ - || video="${location#/}" diff --git a/shcgi b/shcgi deleted file mode 160000 index 8d60af4..0000000 --- a/shcgi +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8d60af41a80ea3760dd51c3bc34eab68d88b16ae diff --git a/style.css b/style.css index bcd6e37..c668365 100644 --- a/style.css +++ b/style.css @@ -1,49 +1,75 @@ * { box-sizing: border-box; + margin: 0; padding: 0; } +button { padding: .125em .5em; } +a { color: inherit; text-decoration: none;} body { color: white; background-color: black; - margin: 0; - padding: 0; } -input.toggle { - display: none; -} -input.toggle + label + * { +#prefs, #bookmarks { display: block; overflow: hidden; height: 0; } -input.toggle:checked + label + * { height: auto; } +#prefs:target, +#bookmarks:target { + height: auto; +} -#search { +#navigation{ text-align: center; background-color: #333; padding: .25em; border-bottom: 1px solid; - margin: 0; } -label[for=t_prefs] { +#search { display: inline; } + +a[href="#prefs"] { position: absolute; - font-size: 1.5em; top: 0; right: .25em; + font-size: 1.5em; +} + +a[href="#bookmarks"] { + position: absolute; + top: 0; left: .25em; + font-size: 1.5em; } -#t_prefs:checked + label + #prefs { +a[href="#advsearch"] { + margin-left: .5em; +} +a[href="#advsearch"]:before { + content: '\25b8'; + margin: 0 .5em; +} + +#prefs:target { + position: absolute; + right: 0; width: 13em; + margin-left: auto; + margin-top: -1px; 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; + z-index: 1; + overflow: visible; +} + +#prefs:target a[href="#"] { + position: absolute; + right: .25em; margin-top: -1.5em; + font-size: 1.5em; + padding: 0 .25em; + background-color: #333; + z-index: 1; } #prefs label[for=prefs_ps] { @@ -64,14 +90,13 @@ label[for=t_prefs] { max-width: 85%; } -.itemlist { overflow: hidden;} +.itemlist { overflow: hidden; } .list { position: relative; display: block; float: left; width: 25%; min-width: 250px; padding: .5em 1em; - margin: 0; overflow: none; word-wrap: break-word; vertical-align: top; @@ -100,7 +125,19 @@ label[for=t_prefs] { .page { display: inline-block; padding: .25em .5em; - background-color: #FAA; + color: black; + background-color: #FDD; border: 1px solid; + margin: 0 .125em; } -.page:nth-of-type(1) {clear: left;} + +#editing { + position: absolute; + width: 100%; bottom: 0; + background-color: #333; + border-top: 1px solid; + padding: .25em; +} + +#index label:first-of-type { font-weight: bold; } +#index input, #index button { margin-left: 1em;} diff --git a/templates/advfilter.html.sh b/templates/advfilter.html.sh deleted file mode 100755 index 3f8c620..0000000 --- a/templates/advfilter.html.sh +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright 2014 - 2016 Paul Hänsch -# -# This file is part of Serve0 -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0 If not, see . - -category_tabs(){ - for cat in "$@"; do - cat < - - - - -EOF - done -} - -filterbox(){ - for n in "$@"; do - filter="$(printf '%s^' "$filters" |cut -d^ -f$(($n+1)))" - fneg="${filter%%[a-zA-Z]*}" - filter="${filter#!}" - fcat="${filter%%:*}" - [ "$fcat" = "$filter" ] && fcat=none - - debug "fneg: $fneg fcat: $fcat filter: $filter" - - cat <<-EOF - - -
    - - - of the items selected here: - - -
    - $(category_tabs $(list_categories) ) -
    -
    - EOF - done -} - -cat < - - Hide - Most recent - -

    Up to 10 filter boxes will appear as you start selecting tags. You can select multiple tags in each box by holding down the Ctrl-key. Click the "Filter!" button when you are ready.

    - $(filterbox {0..9}) - -
    - - - -
    - -EOF - -# vi:set filetype=html: diff --git a/templates/browse.html.sh b/templates/browse.html.sh deleted file mode 100755 index 6a86c3f..0000000 --- a/templates/browse.html.sh +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright 2017 Paul Hänsch -# -# This file is part of Serve0 -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0 If not, see . - -cat < - - - - $(. $_EXEC/templates/advfilter.html.sh) - - - $(. $_EXEC/templates/preferences.html.sh) - - - - -
    - - -
      -EOF - - thumblist - - pages="$( - seq 1 $(pagecount) \ - | while read pn; do - plink="$(($pn * $pagesize - $pagesize + 1))" - - case "$plink" in - ($(($page - $pagesize))) class=previous;; - ($page) class=current;; - ($(($page + $pagesize))) class=next;; - (*) class='';; - esac - - printf '%s\n' "$class" "$page_link" "$plink" "$pn" - done - )" - -cat < - $(. $_EXEC/templates/tagger.html.sh) - - - - -EOF - -# vi:set filetype=html: diff --git a/templates/download.html.sh b/templates/download.html.sh deleted file mode 100755 index 0bc4dbf..0000000 --- a/templates/download.html.sh +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright 2015 Paul Hänsch -# -# This file is part of Serve0 -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0 If not, see . - -cat <