X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=pages%2Fbrowse.sh;h=faf4e67a20977521290d3cf82d96d2ff58bdcf84;hb=d716f2ce1fe64cf87f777490315bc51906001c72;hp=9b3e866d5ef55a809e93648ae1938db0d639eb84;hpb=41bef4fb0a0858fb50a6906cbbcf2dda936d6d05;p=serve0
diff --git a/pages/browse.sh b/pages/browse.sh
index 9b3e866..faf4e67 100755
--- a/pages/browse.sh
+++ b/pages/browse.sh
@@ -17,12 +17,12 @@
# 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
-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"
@@ -55,9 +55,9 @@ category_selected(){
_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"
@@ -78,7 +78,7 @@ _printVideo(){
cat <
@@ -90,14 +90,6 @@ _printVideo(){
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}"
@@ -131,16 +123,56 @@ selectionlist() {
}
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 -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(){
@@ -154,15 +186,15 @@ thumblist(){
case $type in
directory)
printf '%s\n' \
- "$(urlsafe "${directory%/}/$name")" "$(htmlsafe "$name")"
+ "$(urlsafe "${directory%/}/${name##*/}")" "$(htmlsafe "${name##*/}")"
;;
video)
- $indexed && _printVideo "$name" \
+ $indexed && _printVideo "${name##*/}" \
|| printf '%s\n' \
- "$(urlsafe "${directory%/}/$name")" "$(htmlsafe "$name")"
+ "$(urlsafe "${directory%/}/${name##*/}")" "$(htmlsafe "${name##*/}")"
;;
plain)
- printf '%s\n' "$(htmlsafe "$name")"
+ printf '%s\n' "$(htmlsafe "${name##*/}")"
;;
esac
done