. $_EXEC/pages/common.sh
-LF='
-'
directory="$(invalidate "${_GET[d]}" '(.*/)?\.\.(/.*)?|' /)"
-[ -d "${treeroot}/${directory#/}/.index" ] && indexed=true || indexed=false
+[ -d "${treeroot%/}${directory%/}/.index" ] && indexed=true || indexed=false
filters="${_GET[f]}"
debug "FILTERS: $filters"
_printVideo(){
name="$1"
- video="${treeroot%/}/${directory%/}/${name}"
- thumb="${treeroot%/}/${directory%/}/.index/${name}.jpg"
- meta="${treeroot%/}/${directory%/}/.index/${name}.meta"
+ 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"
VIDEOend
}
-genlist(){
- case "$order" in
- Date) find "${_DATA}"/videos/ -maxdepth 1 -mindepth 1 -printf '%T@ %f\n' |sort -r |cut -d\ -f2- |egrep -i "$file_pattern";;
- Length) sed -sn 1p "${_DATA}"/meta/*.meta |sort -n |sed -r 's;^[0-9\t]+\t;;';;
- Name) find "${_DATA}"/videos/ -maxdepth 1 -mindepth 1 -printf '%f\n' |sort |egrep -i "$file_pattern";;
- esac
-}
-
selectionlist() {
cachebase="?o=${order}&s=${search//\//}&f=${filter//\//}"
cache="${_DATA}/cache/${cachebase}"
}
filelist(){
- dir="${treeroot%/}/${directory#/}"
-
- find -L "$dir" -mindepth 1 -maxdepth 1 -type d \! -name ".index" -printf "directory %P\n" \
- | sort
- find -L "$dir" -mindepth 1 -maxdepth 1 \! -type d -printf "video %P\n" \
- | grep -iE "$file_pattern" \
- | sort
- find -L "$dir" -mindepth 1 -maxdepth 1 \! -type d -printf "plain %P\n" \
- | grep -viE "$file_pattern" \
- | sort
+ dir="${treeroot%/}${directory%/}"
+
+ case "$order" in
+ Name)
+ find -L "$dir" -mindepth 1 -maxdepth 1 -type d \! -name ".index" -print0 \
+ | sort -z \
+ | xargs -0 printf 'directory %s\n'
+
+ find -L "$dir" -mindepth 1 -maxdepth 1 \! -type d -print0 \
+ | grep -ziE "$file_pattern" \
+ | sort -z \
+ | 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'
+ ;;
+ 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(){
case $type in
directory)
printf '<a class="file directory" href="?p=browse&d=%s">%s</a>\n' \
- "$(urlsafe "${directory%/}/$name")" "$(htmlsafe "$name")"
+ "$(urlsafe "${directory%/}/${name##*/}")" "$(htmlsafe "${name##*/}")"
;;
video)
- $indexed && _printVideo "$name" \
+ $indexed && _printVideo "${name##*/}" \
|| printf '<a class="file video" href="?action=watch&l=%s">%s</a>\n' \
- "$(urlsafe "${directory%/}/$name")" "$(htmlsafe "$name")"
+ "$(urlsafe "${directory%/}/${name##*/}")" "$(htmlsafe "${name##*/}")"
;;
plain)
- printf '<span class="file plain">%s</span>\n' "$(htmlsafe "$name")"
+ printf '<span class="file plain">%s</span>\n' "$(htmlsafe "${name##*/}")"
;;
esac
done