#!/bin/sh
+exec 2>/dev/null
for n in "$@"; do case ${n%%=*} in
data) _DATA="${n#data=}";;
exec) _exec="${n#exec=}";;
. "$_EXEC/multitag.sh"
REDIRECT "$(POST ref)"
;;
+ thumbnail) if [ -f "$_DATA/$PATH_INFO" ]; then
+ . "$_EXEC/cgilite/file.sh"
+ index="$_DATA/${PATH_INFO%/*}/.index"
+ thumb="$index/${PATH_INFO##*/}"; thumb="${thumb%.*}.jpg"
+ if [ -d "$index" -a ! -f "$thumb" ] && { printf %s "$PATH_INFO" |grep -qE -e "${file_pattern}" ;}; then
+ . "$_EXEC/thumbnail.sh"
+ gen_thumb "$_DATA/$PATH_INFO" "$thumb"
+ fi
+ FILE "$thumb"
+ return 0
+ fi;;
+ download) if [ -f "$_DATA/$PATH_INFO" ]; then
+ . "$_EXEC/cgilite/file.sh"
+ fakemp4="$(COOKIE fakemp4)"
+ downscale="$(COOKIE downscale)"
+ downfile="$_DATA/${PATH_INFO%/*}/.transcode/${PATH_INFO%.*}.480p.webm"
+ if [ "$downscale" = yes -a -f "$downfile" ]; then
+ FILE "$downfile" "$([ "$fakemp4" = yes ] && printf 'video/mp4')"
+ else
+ FILE "$_DATA/$PATH_INFO" "$([ "$fakemp4" = yes ] && printf 'video/mp4')"
+ fi
+ return 0
+ fi;;
+ delete) if [ -f "$_DATA/$PATH_INFO" ]; then
+ :
+ fi;;
+ advsearch) if [ -d "$_DATA/$PATH_INFO" ]; then
+ . "$_EXEC/advsearch.sh"
+ return 0
+ fi;;
+ spawnindex) if [ -d "$_DATA/$PATH_INFO" ]; then
+ if [ "$(POST recursive)" = yes ]; then
+ find "$_DATA/$PATH_INFO" -depth -type d \! -name .index \
+ -exec mkdir -p '{}'/.index \;
+ else
+ mkdir -p "$_DATA/$PATH_INFO/.index"
+ fi
+ REDIRECT "$(POST ref)"
+ fi;;
esac
-if [ "$PATH_INFO" = "/style.css" ]; then
- . "$_EXEC/cgilite/file.sh"
- [ -r "$_DATA/$PATH_INFO" ] && FILE "$_DATA/$PATH_INFO" \
- || FILE "$_EXEC/style.css"
-elif [ "$PATH_INFO" = "/stereoview.js" ]; then
- . "$_EXEC/cgilite/file.sh"
- FILE "$_EXEC/stereoview.js"
-elif [ -f "$_DATA/$PATH_INFO" ]; then
- case $ACTION in
- thumbnail)
- . "$_EXEC/cgilite/file.sh"
- . "$_EXEC/thumbnail.sh"
- index="$_DATA/${PATH_INFO%/*}/.index"
- thumb="$index/${PATH_INFO##*/}"; thumb="${thumb%.*}.jpg"
- [ -d "$index" -a ! -f "$thumb" ] \
- && { printf %s "$PATH_INFO" |grep -qE -e "${file_pattern}" ;} \
- && gen_thumb "$_DATA/$PATH_INFO" "$thumb"
- FILE "$thumb"
- ;;
- delete)
- ;;
- download)
- . "$_EXEC/cgilite/file.sh"
- fakemp4="$(COOKIE fakemp4)"
- downscale="$(COOKIE downscale)"
- downfile="$_DATA/${PATH_INFO%/*}/.transcode/${PATH_INFO%.*}.480p.webm"
- if [ "$downscale" = yes -a -f "$downfile" ]; then
- FILE "$downfile" "$([ "$fakemp4" = yes ] && printf 'video/mp4')"
- else
- FILE "$_DATA/$PATH_INFO" "$([ "$fakemp4" = yes ] && printf 'video/mp4')"
- fi
- ;;
- *) . "$_EXEC/view.sh"
- esac
+case $PATH_INFO in
+ /style.css)
+ . "$_EXEC/cgilite/file.sh"
+ [ -r "$_DATA/$PATH_INFO" ] \
+ && FILE "$_DATA/$PATH_INFO" \
+ || FILE "$_EXEC/style.css"
+ return 0
+ ;;
+ /stereoview.js)
+ . "$_EXEC/cgilite/file.sh"
+ FILE "$_EXEC/stereoview.js"
+ return 0
+ ;;
+esac
+
+if [ -f "$_DATA/$PATH_INFO" ]; then
+ . "$_EXEC/view.sh"
+ return 0
elif [ -d "$_DATA/$PATH_INFO" ]; then
- case $ACTION in
- advsearch)
- . "$_EXEC/advsearch.sh"
- ;;
- spawnindex)
- if [ "$(POST recursive)" = yes ]; then
- find "$_DATA/$PATH_INFO" -depth -type d \! -name .index \
- -exec mkdir -p '{}'/.index \;
- else
- mkdir -p "$_DATA/$PATH_INFO/.index"
- fi
- REDIRECT "$(POST ref)"
- ;;
- *) . "$_EXEC/list.sh"
- ;;
- esac
+ . "$_EXEC/list.sh"
+ return 0
else
printf 'Status: 404 Not Found\r\nContent-Length 0:\r\n\r\n'
fi