X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;ds=inline;f=pages%2Flist.sh;h=89576f833fe2e04bdc6f9645fe71a07dfbe89511;hb=071111d9507b99cb70ac20b13c639fc53f9095ee;hp=2c4b1f18ee2dd6ecbf58aefd41b0496d2f3328cb;hpb=0205c3f02124d62c980ba0656babd544f2cb7d19;p=serve0
diff --git a/pages/list.sh b/pages/list.sh
index 2c4b1f1..89576f8 100755
--- a/pages/list.sh
+++ b/pages/list.sh
@@ -1,6 +1,6 @@
#!/bin/zsh
-# Copyright 2014 - 2016 Paul Hänsch
+# Copyright 2014 - 2017 Paul Hänsch
#
# This file is part of Serve0.
#
@@ -17,6 +17,8 @@
# 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='
@@ -44,7 +46,7 @@ category_selected(){
filter="$2"
[ "$cat" = "none:" ] && cat=''
- printf %s "$taglist" \
+ printf %s "$taglist_filter" \
| sed -r 's;^('"$filter"')$;1 &;;t;s;^;0 ;' \
| sed -rn 's;^(0|1) '"$cat"'([^:]+)$;\1 \2;p' \
| sed 's;^0 ;;'
@@ -73,38 +75,58 @@ _printVideo(){
thumb="$(urlsafe "thumbs/$info.jpg")"
linkinfo="$(urlsafe "$info")"
htmlinfo="$(htmlsafe "$info")"
-
- [ "$(($length % 60))" -lt 10 ] && minutes="$(($length / 60)):0$(($length % 60))" \
- || minutes="$(($length / 60)):$(($length % 60))"
-
- tee "$cache" <
-
-
-
- ${htmlinfo}
-
-
- ${minutes}min
- ${width}x${height}
- $(printf %s "$tags" |sed -r 's:\|*([^|]+)\|*: \1:g')
-
+ attrinfo="$(attribsafe "$info")"
+
+ minutes="$(printf "%d:%02d" $(($length / 60)) $(($length % 60)) )"
+
+ { tr -d '\n' |tee "$cache"; } <<-VIDEOend
+
+
+
+
+
+ ${minutes}min
+ ${width}x${height}
+ $(printf %s "$tags" |sed -r 's:\|*([^|]+)\|*: \1:g')
+
VIDEOend
fi
}
genlist(){
case "$order" in
- Date) ls -c "${_DATA}"/videos/ |egrep -i "$file_pattern";;
- Length) sed -sn 1p "${_DATA}"/meta/*.meta |sort -n |sed -r 's;^[0-9\t]+\t;;';;
- Name) printf '%s\n' "${_DATA}"/videos/* |sed -r 's;^.*/;;;';;
+ 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 [ "$cache" -nt ${_DATA}/videos -a "$cache" -nt ${_DATA}/meta ]; then
+ 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"
@@ -141,4 +163,6 @@ thumblist() {
done
}
-pagecount="$(( $(selectionlist | wc -l) / $pagesize + 1 ))"
+pagecount() {
+ printf "$(( $(selectionlist | wc -l) / $pagesize + 1 ))"
+}