X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=pages%2Flist.sh;h=757d5418e95bebff8123b5859c13c89579e862c9;hb=9554fea689ec1519a572888aae9dc37ae140cd57;hp=fc4ff66ceab3d8508be5deabc876b4661f4773f2;hpb=ca0cde88cb003b41e62c2e08da8dd26b7b3b583e;p=serve0 diff --git a/pages/list.sh b/pages/list.sh index fc4ff66..757d541 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=' @@ -39,25 +41,12 @@ else TITLE="List by $order" fi -quicklinks(){ - output='' - tac ${_DATA}/meta/recent \ - | while [ "$(printf %s "$output" |wc -l)" -lt 30 ] && read line; do - printf %s "$output" |grep -qF "$line" || output="$output$line$LF" - done - printf %s "$output" |while read line; do - linef=$(printf %s "$line" |sed -r 's;^.*(\?|&)f=([^&]+)&?.*$;\2;g') - lineo=$(printf %s "$line" |sed -r 's;^.*(\?|&)o=([^&]+)&?.*$;\2;g') - printf 'by %s: %s' "$line" "${lineo}" "$(present_filter "$linef")" - done -} - category_selected(){ cat="${1}:" 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 ;;' @@ -86,16 +75,16 @@ _printVideo(){ thumb="$(urlsafe "thumbs/$info.jpg")" linkinfo="$(urlsafe "$info")" htmlinfo="$(htmlsafe "$info")" + attrinfo="$(attribsafe "$info")" - [ "$(($length % 60))" -lt 10 ] && minutes="$(($length / 60)):0$(($length % 60))" \ - || minutes="$(($length / 60)):$(($length % 60))" + minutes="$(printf "%d:%02d" $(($length / 60)) $(($length % 60)) )" tee "$cache" < - +
  • + +

    ${htmlinfo}

    ${minutes}min @@ -108,16 +97,16 @@ VIDEOend genlist(){ case "$order" in - Date) ls -c "${_DATA}"/videos/ |egrep -i "$file_pattern";; + 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) printf '%s\n' "${_DATA}"/videos/* |sed -r 's;^.*/;;;';; + 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}" - 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" @@ -154,4 +143,6 @@ thumblist() { done } -pagecount="$(( $(selectionlist | wc -l) / $pagesize + 1 ))" +pagecount() { + printf "$(( $(selectionlist | wc -l) / $pagesize + 1 ))" +}