-[submodule "shcgi"]
- path = shcgi
- url = https://git.plutz.net/git/shcgi
[submodule "cgilite"]
path = cgilite
url = https://git.plutz.net/git/cgilite
+++ /dev/null
-#!/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 <http://www.gnu.org/licenses/>.
-
-directory="$(invalidate "${_GET[d]}" '(.*/)?\.\.(/.*)?|' /)"
-mkdir -p "${treeroot}/${directory#/}/.index"
-
-redirect "?p=browse&d=$(urlsafe "${directory%/}")"
+++ /dev/null
-#!/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 <http://www.gnu.org/licenses/>.
-
-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}"
+++ /dev/null
-#!/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 <http://www.gnu.org/licenses/>.
-
-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 <<EOF
-${length} ${width} ${height} ${info}
-${tagacc}|${tags}
-${description}
-EOF
- rm "${_DATA}/cache/$info.cache" 2>/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}}"
+++ /dev/null
-#!/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 <http://www.gnu.org/licenses/>.
-
-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 <<EOF >"$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"
+++ /dev/null
-#!/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 <http://www.gnu.org/licenses/>.
-
-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]}"
+++ /dev/null
-#!/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]"
+++ /dev/null
-#!/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 <http://www.gnu.org/licenses/>.
-
-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"
+++ /dev/null
-#!/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
-
-
-
+++ /dev/null
-#!/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 <http://www.gnu.org/licenses/>.
-
-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
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"
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(){
[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
+++ /dev/null
-#!/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 <http://www.gnu.org/licenses/>.
-
-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 ;<option>;;s;^1 ;<option selected>;;s;$;</option>;'
-}
-
-_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 <<VIDEOend
- <li id="${location}" class="thumb">
- <button class="watchlink" name="${location}" formaction="?action=watch&l=${location}">
- <img src="${thumblocation}" width="212" height="162" alt="Preview not yet available">
- </button>
- <h2><a href="?action=watch&l=${location}">${display}</a></h2>
-
- <input type="checkbox" name="tagsel" value="${location}">
- <span class="info property">${minutes}min</span>
- <span class="info property">${width}x${height}</span>
- $(printf %s "$tags" |sed -r 's:\|*([^|]+)\|*: <span class="info tag">\1</span>:g')
- </li>
-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 "<a class='file directory' href='?p=browse&d=$(urlsafe "${directory%/*}")'>..</a>"
-
- filelist \
- | sed -n "$page,$(($page + $pagesize - 1))p" \
- | while read -r type name; do
- case $type in
- directory)
- printf '<a class="file directory" href="?p=browse&d=%s">%s</a>\n' \
- "$(urlsafe "${directory%/}/${name##*/}")" "$(htmlsafe "${name##*/}")"
- ;;
- video)
- $indexed && _printVideo "${name##*/}" \
- || printf '<a class="file video" href="?action=watch&l=%s">%s</a>\n' \
- "$(urlsafe "${directory%/}/${name##*/}")" "$(htmlsafe "${name##*/}")"
- ;;
- plain)
- printf '<span class="file plain">%s</span>\n' "$(htmlsafe "${name##*/}")"
- ;;
- esac
- done
-}
-
-pagecount() {
- printf "$(( $(filelist | wc -l) / $pagesize + 1 ))"
-}
+++ /dev/null
-#!/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 <http://www.gnu.org/licenses/>.
-
-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
-}
+++ /dev/null
-#!/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 <http://www.gnu.org/licenses/>.
-
-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 ;<option>;;s;^1 ;<option selected>;;s;$;</option>;'
-}
-
-_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
- <li id="$attrinfo" class="thumb">
- <button class="watchlink" name="${linkinfo}" formaction="?action=watch&i=${linkinfo}">
- <img src="$thumb" width="212" height="162" alt="Preview not yet available">
- </button>
- <h2><a href="?action=watch&i=${linkinfo}">${htmlinfo}</a></h2>
-
- <input type="checkbox" name="tagsel" value="${htmlinfo}">
- <span class="info property">${minutes}min</span>
- <span class="info property">${width}x${height}</span>
- $(printf %s "$tags" |sed -r 's:\|*([^|]+)\|*: <span class="info tag">\1</span>:g')
- </li>
-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 ))"
-}
+++ /dev/null
-#!/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 <http://www.gnu.org/licenses/>.
-
-. $_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
-}
+++ /dev/null
-#!/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 <http://www.gnu.org/licenses/>.
-
-. $_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 '<input type="checkbox"><a target="blank" href="%s">%s</a>' \
- "$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 ;<option>;;s;^1 ;<option selected>;;s;$;</option>;'
-}
-
+++ /dev/null
-#!/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 <http://www.gnu.org/licenses/>.
-
-. $_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#/}"
+++ /dev/null
-#!/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 <http://www.gnu.org/licenses/>.
-
-. $_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#/}"
+++ /dev/null
-Subproject commit 8d60af41a80ea3760dd51c3bc34eab68d88b16ae
* {
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] {
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;
.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;}
+++ /dev/null
-# 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 <http://www.gnu.org/licenses/>.
-
-category_tabs(){
- for cat in "$@"; do
- cat <<EOF
- <div class="tab">
- <input class="tabhandle" type="radio" name="category$n" id="cat${n}_$cat" value="$cat" $([ "$cat" = "$fcat" ] && printf checked)>
- <label class="category tabhandle" for="cat${n}_$cat">$([ "$cat" = none ] && printf %s general || printf %s "$cat")</label>
- <select class="category tabcontent" class="input tagfilter" name="cfilter${n}_" size="12" multiple>
- $(category_selected "$cat" "$filter")
- </select>
- </div>
-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
- <input class="tabhandle" type="checkbox" id="filter$n" $([ $n = 0 -o -n "$filter" ] && printf checked) >
- <label class="tabhandle filter" for="filter$n">+ and</label>
- <fieldset class="tabcontent filter">
- <input type="radio" name="type$n" value="pos" id="pos$n" ${fneg:-checked} ><label for="pos$n" class="conjunction">Any</label>
- <input type="radio" name="type$n" value="neg" id="neg$n" ${fneg:+checked} ><label for="neg$n" class="conjunction">None</label>
- <span class="help">of the items selected here:</span>
-
- <label class="category">Category:</label>
- <div class="category tabcontainer">
- $(category_tabs $(list_categories) )
- </div>
- </fieldset>
- EOF
- done
-}
-
-cat <<EOF
- <form class="panel switchable top" id="advfilter"
- action="?action=filter" method="post" accept-charset="UTF-8">
-
- <a class="panel toggle" href="#">Hide</a>
- <a class="panel" href="?p=quicklinks">Most recent</a>
-
- <p class="help">Up to <strong>10</strong> filter boxes will appear as you start selecting tags. You can select <strong>multiple</strong> tags in each box by holding down the <strong>Ctrl</strong>-key. Click the "<strong>Filter!</strong>" button when you are ready.</p>
- $(filterbox {0..9})
-
- <fieldset class="filter final">
- <label for="o3" class="order">Order by:</label>
- <select class="edit order" size="1" name="o" id="o3">
- <option $([ "${_GET[o]}" = Name ] && printf selected) >Name</option>
- <option $([ "${_GET[o]}" = Date ] && printf selected) >Date</option>
- <option $([ "${_GET[o]}" = Length ] && printf selected) >Length</option>
- </select>
- <input type="submit" value="Filter!">
- </fieldset>
- </form>
-EOF
-
-# vi:set filetype=html:
+++ /dev/null
-# 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 <http://www.gnu.org/licenses/>.
-
-cat <<EOF
-
- <input type=radio name=topmenu id=btn_search checked><label for=btn_search>Search</label>
- <form class="panel" id="search" action="?" method="get" accept-charset="UTF-8">
- <input type="hidden" name="d" value="$(attribsafe "$directory")">
- <input type="text" name="s" value="$(attribsafe "$search")" placeholder="Search">
-
- <select class="order" size="1" name="o" id="o1">
- <option class="label" selected disabled>Order by</option>
- <option>Name</option>
- <option>Date</option>
- <option>Length</option>
- </select>
- <!-- input type="submit" name="submit" value="Find" -->
-
- <a class="panel clearsearch" href="?">Clear</a>
- </form>
-
- <input type=radio name=topmenu id=btn_advfilter><label for=btn_advfilter>Advanced</label>
- $(. $_EXEC/templates/advfilter.html.sh)
-
- <input type=radio name=topmenu id=btn_preferences><label for=btn_preferences>Preferences</label>
- $(. $_EXEC/templates/preferences.html.sh)
-
- <input type=radio name=topmenu id=btn_morelinks><label for=btn_morelinks>{+}</label>
- <div class="panel switchable top" id="morelinks">
- <a class="panel toggle" href="#">Hide</a>
-
- <a class="panel" href="?p=playctl">Player</a>
- </div>
-
- <form action="?action=multitag" method="post" accept-charset="UTF-8">
- <input type="hidden" name="page" value="?$(attribsafe "${page_this}")">
-
- <ul id="thumblist">
-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 '<a class="%s" href="?%spn=%s">%s</a>\n' "$class" "$page_link" "$plink" "$pn"
- done
- )"
-
-cat <<EOF
- </ul>
- $(. $_EXEC/templates/tagger.html.sh)
- </form>
-
- <div class="panel" id="foot">
- $( $indexed \
- && printf '<a class="panel toggle" href="#tagger">Add Tags</a>' \
- || printf '<a class="panel" href="?action=dirindex&d=%s">Spawn Index</a>' "$(urlsafe "$directory")"
- )
- <a class="panel toggle" href="#">⇧</a>
-
- <div class="pagination_nav">
- <label>Page:</label>
- ${pages}
- </div>
- </div>
-
-EOF
-
-# vi:set filetype=html:
+++ /dev/null
-# 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 <http://www.gnu.org/licenses/>.
-
-cat <<EOF
- <form class="panel" id="advfilter" style="display: none;"
- action="?action=filter" method="post" accept-charset="UTF-8">
- <input disabled type="text" name="s" value="$search" placeholder="Search">
- <label for="o2" class="order">Order by:</label>
- <select disabled class="order" size="1" name="o" id="o2">
- <option>Name</option>
- <option>Date</option>
- <option>Length</option>
- </select>
- <input disabled type="submit" name="submit" value="Find">
-
- <a class="panel clearsearch" href="?">Clear All</a>
- <a class="panel advanced hide" href="#"
- onclick="javascript:hide('advfilter');$(for n in {1..9}; do echo "hide('filter$n');"; done)show_block('search')"
- >Hide</a>
- <hr>
-
- <p class="help">Up to <strong>10</strong> filter boxes will appear as you start selecting tags. You can select <strong>multiple</strong> tags in each box by holding down the <strong>Ctrl</strong>-key. Click the "<strong>Filter!</strong>" button when you are ready.</p>
-
- <p class="filter final">
- <label for="o3" class="order">Order by:</label>
- <select class="edit order" size="1" name="o" id="o3">
- <option>Name</option>
- <option>Date</option>
- <option>Length</option>
- </select>
- <input type="submit" value="Filter!">
- </p>
-
- <p class="quicklinks">
- <label class="quicklinks">Most recent</label>
- $(output=''
- tac ${_DATA}/meta/recent |while [ "$(echo "$output" |wc -l)" -lt 10 ] && read line; do
- line="<a href="$line">$line</a>"
- echo "$output" |grep -qF "$line" || output="$output$line\n"
- done
- echo $output
- )
- </p>
- </form>
-
-
- <form action="?action=multitag&${page_this}" method="post" accept-charset="UTF-8">
- <ul id="thumblist">
- $(thumblist)
- </ul>
- $(tagger)
- </form>
-EOF
-
-# vi:set filetype=html:
+++ /dev/null
-# 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 <http://www.gnu.org/licenses/>.
-
-cat <<EOF
-<!Doctype HTML>
-
-<html><head>
- <meta name="viewport" content="width=device-width">
- <link rel="stylesheet" href="?static=common.css" />
- <title>${TITLE:-${PAGE}}</title>
-</head>
-EOF
-
-printf '<body class="%s">' "${PAGE}"
-
-[ -x "${BODY}" ] && . "${BODY}" || printf %s Error
-
-printf '</body></html>'
-
-# vi:set filetype=html:
+++ /dev/null
-# 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 <http://www.gnu.org/licenses/>.
-
-cat <<EOF
-
- <input type=radio name=topmenu id=btn_search checked><label for=btn_search>Search</label>
- <form class="panel" id="search" action="?" method="get" accept-charset="UTF-8">
- <input type="text" name="s" value="$search" placeholder="Search">
-
- <select class="order" size="1" name="o" id="o1">
- <option class="label" selected disabled>Order by</option>
- <option>Name</option>
- <option>Date</option>
- <option>Length</option>
- </select>
- <!-- input type="submit" name="submit" value="Find" -->
-
- <a class="panel clearsearch" href="?">Clear</a>
- </form>
-
- <input type=radio name=topmenu id=btn_advfilter><label for=btn_advfilter>Advanced</label>
- $(. $_EXEC/templates/advfilter.html.sh)
-
- <input type=radio name=topmenu id=btn_preferences><label for=btn_preferences>Preferences</label>
- $(. $_EXEC/templates/preferences.html.sh)
-
- <input type=radio name=topmenu id=btn_morelinks><label for=btn_morelinks>{+}</label>
- <div class="panel switchable top" id="morelinks">
- <a class="panel toggle" href="#">Hide</a>
-
- <a class="panel treeview" href="?p=browse">Browse Folders</a>
- <a class="panel" href="?p=playctl">Player</a>
- </div>
-
- <form action="?action=multitag" method="post" accept-charset="UTF-8">
- <input type="hidden" name="page" value="?$(attribsafe "${page_this}")">
-
- <ul id="thumblist">
-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 '<a class="%s" href="?%spn=%s">%s</a>\n' "$class" "$page_link" "$plink" "$pn"
- done
- )"
-
-cat <<EOF
- </ul>
- $(. $_EXEC/templates/tagger.html.sh)
- </form>
-
- <div class="panel" id="foot">
- <a class="panel toggle" href="#tagger">Add Tags</a>
- <a class="panel toggle" href="#">⇧</a>
-
- <div class="pagination_nav">
- <label>Page:</label>
- ${pages}
- </div>
- </div>
-
-EOF
-
-# vi:set filetype=html:
+++ /dev/null
-# 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 <http://www.gnu.org/licenses/>.
-
-cat <<EOF
-
-<input type=radio name=topmenu id=btn_search checked><label for=btn_search>Search</label>
-<form class="panel" id="search" action="?" method="get" accept-charset="UTF-8">
- <input type="text" name="s" value="$search" placeholder="Search">
-
- <select class="order" size="1" name="o" id="o1">
- <option class="label" selected disabled>Order by</option>
- <option>Name</option>
- <option>Date</option>
- <option>Length</option>
- </select>
- <!-- input type="submit" name="submit" value="Find" -->
-
- <a class="panel" href="${_GET[w]:-${info:+?p=list&${page_this}}${directory:+?p=browse&d=${directory}&${page_this}}#$(urlsafe $info)}">Dismiss</a>
-</form>
-
-<input type=radio name=topmenu id=btn_playctl><label for=btn_playctl>Audio</label>
-<form class="panel switchable top playctl" id="advctl" action="?action=playctl" method="post">
- <input type="hidden" name="referrer" value="$(attribsafe "${REQUEST_URI}")">
- <fieldset class="volume">
- <button type="submit" name="amp" value="off">Amp Off</button>
- <button type="submit" name="amp" value="on">Amp On</button>
- </fieldset>
- <fieldset class="pasink">
- $(pa_sinks |while read no name; do
- printf '<button type="submit" name="pasink" value="%s">%s</button>' "$no" "$name"
- done)
- </fieldset>
- <a class="panel toggle" href="#foot">Hide</a>
-</form>
-
-<input type=radio name=topmenu id=btn_preferences><label for=btn_preferences>Preferences</label>
- $(. $_EXEC/templates/preferences.html.sh)
-
-<input type=radio name=topmenu id=btn_morelinks><label for=btn_morelinks>{+}</label>
-<div class="panel switchable top" id="morelinks">
- <a class="panel toggle" href="#">Hide</a>
-
- <a class="panel listview" href="?p=list">Index view</a>
- <a class="panel treeview" href="?p=browse">Browse Folders</a>
-</div>
-
-
-<div id="playctl">
- <h1>$info</h1>
-
- <form action="${actionuri}" method="post" class="playctl">
- <input type="hidden" name="referrer" value="$(attribsafe "//${HTTP_HOST}${REQUEST_URI}")">
- <fieldset class="playback">
- <button type="submit" name="seek" value="-60"><<<</button>
- <button type="submit" name="seek" value="-10"><<</button>
- <button type="submit" name="ctl" value="stop">■</button>
- <button type="submit" name="ctl" value="pause">|| / ▶</button>
- <button type="submit" name="seek" value="+10">>></button>
- <button type="submit" name="seek" value="+60">>>></button>
- </fieldset>
- <fieldset class="volume">
- $(for n in $(seq 0 5 100); do
- printf '<button class="%s" type="submit" name="vol" value="%s"> </button>' \
- "$( [ "$n" = "$volume" ] && printf selected
- [ "$n" = "$((volume - 10))" ] && printf llselected
- [ "$n" = "$((volume - 5))" ] && printf lselected
- [ "$n" = "$((volume + 5))" ] && printf gselected
- [ "$n" = "$((volume + 10))" ] && printf ggselected
- )" "$n"
- done)
- </fieldset>
- </form>
-
- <span class="info length">$(printf "%d:%02d min" $(($length / 60)) $(($length % 60)) )</span>
- <span class="info width" >Width: $width</span>
- <span class="info height">Height: $height</span><br>
-
- $(printf %s\\n "$tags" |sed -r 's:\|*([^|]+)\|*:<span class="info tag">\1</span> :g')
- ${description:+<span class="info description">$(printf %s "$description" |_wiki)</span>}
-</div>
-
-<form class="panel switchable bottom" id="tagger" action="?action=meta&${page_this}" method="post" accept-charset="UTF-8">
- <input type="hidden" name="referrer" value="$(attribsafe "${REQUEST_URI}")">
- <input type="hidden" name="length" value="$length">
- <input type="hidden" name="width" value="$width">
- <input type="hidden" name="height" value="$height">
-
- $(
- for cat in $(list_categories); do
- printf '<fieldset class="newtag"><label class="category">%s:</label><select name="tag" size="12" multiple>' "${cat}"
- catt="${cat}:"
- [ "$catt" = "none:" ] && catt=''
-
- printf %s "$taglist_set" |egrep '^'"$catt"'[^:]+$' |while read line; do
- printf '<option %s value="%s">%s</option>' \
- "$(egrep -q "(^|.*\|)$line(\|.*|$)" "$meta" && printf selected)" \
- "$line" "${line#*:}"
- done
- printf '</select></fieldset>'
- done
- )
-
- <fieldset class="newtag additional">
- <label class="additional">Additional Tags (one per line):</label>
- <textarea name="tags" rows="4"></textarea>
- </fieldset>
- <fieldset class="newtag description">
- <label class="description">Description:</label>
- <textarea name="description" rows="4">$description</textarea>
- </fieldset>
- <input type="submit" value="Edit!">
- <input type="submit" name="trash" value="Delete Video">
-
- <a class="panel toggle" href="#foot">Hide</a>
-</form>
-
-<div class="panel footer" id="foot">
- <a class="panel toggle" href="#tagger">Edit Tags</a>
-</div>
-
-<span class="progress">
-EOF
-
-cnt=0
-progress \
-| while read p t; do
- printf '<span style="width: %d%%;">%d:%02d</span>\n' "${p}" "$(($t / 60))" "$(($t % 60))"
-done
-
-printf '</span>'
-
-# vi:set filetype=html:
+++ /dev/null
-# Copyright 2015, 2016, 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 <http://www.gnu.org/licenses/>.
-
-cat <<EOF
- <form class="panel switchable top" id="preferences"
- action="?action=preferences" method="post" accept-charset="UTF-8">
- <a class="panel toggle" href="#">Hide</a>
-
- <fieldset>
- <legend>Watch videos:</legend>
- $(form_radio watch 240p "${_COOKIE[watch]}" "as Download in 240p" )<br/>
- $(form_radio watch 480p "${_COOKIE[watch]}" "as Download in 480p" )<br/>
- $(form_radio watch download "${_COOKIE[watch]}" "as Download (original)")<br/>
- $(form_radio watch raspi "${_COOKIE[watch]}" "on playback device" )<br/>
- $(form_radio watch player "${_COOKIE[watch]}" "in embedded player" )<br/>
- $(form_radio watch server "${_COOKIE[watch]}" "on screen connected to server")<br/>
-
- $(form_check fakemp4 yes "${_COOKIE[fakemp4]}" "Fake .mp4 file ending, even if file is of different type")
- </fieldset>
-
- <fieldset>
- <legend>Display:</legend>
- <label for="n_pagesize">Number of items per page: </label>
- <input type="number" name="pagesize" value="${pagesize}" id="n_pagesize">
- </fieldset>
-
- <input type="hidden" name="referrer" value="$(attribsafe ${REQUEST_URI})">
- <input type="submit" value="Set Cookie!">
- </form>
-EOF
-
-# vi:set filetype=html:
+++ /dev/null
-# 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 <http://www.gnu.org/licenses/>.
-
-cat <<EOF
- <input type=radio name=topmenu id=btn_search checked><label for=btn_search>Search</label>
- <form class="panel" id="search" action="?" method="get" accept-charset="UTF-8">
- <input type="text" name="s" value="$search" placeholder="Search">
-
- <select class="order" size="1" name="o" id="o1">
- <option class="label" selected disabled>Order by</option>
- <option>Name</option>
- <option>Date</option>
- <option>Length</option>
- </select>
- <!-- input type="submit" name="submit" value="Find" -->
-
- <a class="panel clearsearch" href="?">Clear</a>
- </form>
-
- <input type=radio name=topmenu id=btn_advfilter><label for=btn_advfilter>Advanced</label>
- $(. $_EXEC/templates/advfilter.html.sh)
-
- <input type=radio name=topmenu id=btn_preferences><label for=btn_preferences>Preferences</label>
- $(. $_EXEC/templates/preferences.html.sh)
-
- <input type=radio name=topmenu id=btn_morelinks><label for=btn_morelinks>{+}</label>
- <div class="panel switchable top" id="morelinks">
- <a class="panel toggle" href="#">Hide</a>
-
- <a class="panel listview" href="?p=list">Index view</a>
- <a class="panel treeview" href="?p=browse">Browse Folders</a>
- <a class="panel" href="?p=playctl">Player</a>
- </div>
-
- <p class="quicklinks">
- <label class="quicklinks">Most recent</label>
- $(quicklinks)
- </p>
-
- <div class="panel" id="foot">
- <a class="panel toggle" href="#preferences">Preferences</a>
- <a class="panel treeview" href="?p=browse">Browse Folders</a>
- </div>
-
- $(. $_EXEC/templates/preferences.html.sh)
- $(. $_EXEC/templates/advfilter.html.sh)
-EOF
-
-# vi:set filetype=html:
+++ /dev/null
-# Copyright 2014, 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 <http://www.gnu.org/licenses/>.
-
-category_options(){
- cat="${1}:"
- [ "$cat" = "none:" ] && cat=''
-
- printf %s "$taglist_set" \
- | sed -rn 's;^('"$cat"')([^:]+)$;<option value="\1\2">\2</option>;p'
-}
-
-category_box(){
- for cat in "$@"; do
- cat <<EOF
- <fieldset class="newtag">
- <label class="category">${cat}:</label>
- <input type="hidden" name="category" value="$cat">
- <select name="ctag" size="12" multiple>
- $(category_options "$cat")
- </select>
- </fieldset>
-EOF
- done
-}
-
-cat <<EOF
- <div class="panel switchable bottom" id="tagger">
- <p class="help">Add selectetd tags to selected videos.</p>
- $(category_box $(list_categories))
- <fieldset class="newtag additional">
- <label class="additional">Additional Tags (one per line):</label>
- <textarea name="tags" rows="2"></textarea>
- </fieldset>
- <input type="submit" value="Add Tags!">
-
- <a class="panel toggle" href="#foot">Hide</a>
- </div>
-EOF
-
-# vi:set filetype=html:
+++ /dev/null
-# 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 <http://www.gnu.org/licenses/>.
-
-cat <<EOF
-<input type=radio name=topmenu id=btn_search checked><label for=btn_search>Search</label>
-<form class="panel" id="search" action="?" method="get" accept-charset="UTF-8">
- <input type="text" name="s" value="$search" placeholder="Search">
-
- <select class="order" size="1" name="o" id="o1">
- <option class="label" selected disabled>Order by</option>
- <option>Name</option>
- <option>Date</option>
- <option>Length</option>
- </select>
- <!-- input type="submit" name="submit" value="Find" -->
-
- <a class="panel" href="${info:+?p=list&${page_this}}${directory:+?p=browse&d=${directory}&${page_this}}#$(urlsafe $info)">Dismiss</a>
-</form>
-
-<input type=radio name=topmenu id=btn_preferences><label for=btn_preferences>Preferences</label>
- $(. $_EXEC/templates/preferences.html.sh)
-
-<input type=radio name=topmenu id=btn_morelinks><label for=btn_morelinks>{+}</label>
-<div class="panel switchable top" id="morelinks">
- <a class="panel toggle" href="#">Hide</a>
-
- <a class="panel listview" href="?p=list">Index view</a>
- <a class="panel treeview" href="?p=browse">Browse Folders</a>
-</div>
-
-
-<div id="videoview">
- <h1>$(htmlsafe "$info")</h1>
-
- <a href="$(urlsafe "$video")">Download</a>
- <a href="javascript:stereoview(180, document.getElementById('mainvideo'));">View 180º Steroscopic</a>
- <a href="javascript:stereoview(360, document.getElementById('mainvideo'));">View 360º Steroscopic</a>
- <video id="mainvideo" autoplay controls>
- <source src="$(urlsafe "$video")" type='video/mp4; codecs="avc1.4D401E, mp3"'>"
- </video>
-
- <span class="info length">$(printf "%d:%02d min" $(($length / 60)) $(($length % 60)) )</span>
- <span class="info width" >Width: $width</span>
- <span class="info height">Height: $height</span><br>
-
- $(printf %s\\n "$tags" |sed -r 's:\|*([^|]+)\|*:<span class="info tag">\1</span> :g')
- ${description:+<span class="info description">$(printf %s "$description" |_wiki)</span>}
-</div>
-
-<script type="text/javascript" src="?static=stereoview.js"></script>
-
-<form class="panel switchable bottom" id="tagger" action="?action=meta&${page_this}" method="post" accept-charset="UTF-8">
- <input type="hidden" name="referrer" value="$(attribsafe "${REQUEST_URI}")">
- <input type="hidden" name="length" value="$length">
- <input type="hidden" name="width" value="$width">
- <input type="hidden" name="height" value="$height">
-
- $(
- for cat in $(list_categories); do
- printf '<fieldset class="newtag"><label class="category">%s:</label><select name="tag" size="12" multiple>' "${cat}"
- catt="${cat}:"
- [ "$catt" = "none:" ] && catt=''
-
- printf %s "$taglist_set" |egrep '^'"$catt"'[^:]+$' |while read line; do
- printf '<option %s value="%s">%s</option>' \
- "$(egrep -q "(^|.*\|)$line(\|.*|$)" "$meta" && printf selected)" \
- "$line" "${line#*:}"
- done
- printf '</select></fieldset>'
- done
- )
-
- <fieldset class="newtag additional">
- <label class="additional">Additional Tags (one per line):</label>
- <textarea name="tags" rows="4"></textarea>
- </fieldset>
- <fieldset class="newtag description">
- <label class="description">Description:</label>
- <textarea name="description" rows="4">$description</textarea>
- </fieldset>
- <input type="submit" value="Edit!">
- <input type="submit" name="trash" value="Delete Video">
-
- <a class="panel toggle" href="#foot">Hide</a>
-</form>
-
-<div class="panel bottom" id="foot">
- <a class="panel toggle" href="#tagger">Edit Tags</a>
-</div>
-EOF
-
-# vi:set filetype=html:
mode="$(COOKIE mode)"
printf '
[form #prefs method="POST" action="?a=setprefs"
+ [a href="#" x]
[hidden "ref" "%s"]
[label for=prefs_ps Pagesize]
[input #prefs_ps type=number name=pagesize value="%s"][br]
"$([ "$mode" = index ] && printf checked)" \
"$([ "$fakemp4" = yes ] && printf checked)"
}
+
+w_index(){
+ [ -d "$_DATA/$ITEM/.index" ] || printf '
+ [form #index method="POST" action="?a=spawnindex"
+ [hidden "ref" "%s"]
+ [label Set up for Index view: ]
+ [checkbox "recursive" "yes" #spawn_recursive] [label for=spawn_recursive Include subdirectories]
+ [submit "spawn" "spawn" Set up]
+ ]
+ ' "$(HTML "$REQUEST_URI")"
+}