]> git.plutz.net Git - serve0/blobdiff - pages/list.sh
Page titles based on content, improved display of quicklinks
[serve0] / pages / list.sh
index 2d3cbf3bad443f2eb5c0aec98ee6c8afbc60dca9..deb8ce8518316311e29378f6512d3598f4496082 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/zsh
 
-# Copyright 2014, 2015 Paul Hänsch
+# Copyright 2014 - 2016 Paul Hänsch
 #
 # This file is part of Serve0.
 # 
 
 . $_EXEC/pages/common.sh
 
+LF='
+'
 filters="${_GET[f]}"
 debug "FILTERS: $filters"
 
+present_filter(){ printf %s "$*" |sed -r 's;(^|!|\^|\|)([^!\^\|:]+:);\1;g;s;\^; \&amp\; ;g' }
+
+if [ -n "$search" ]; then
+  TITLE="$search by $order"
+elif [ -n $filter ]; then
+  TITLE="$(present_filter "$filter") by $order"
+else
+  TITLE="List by $order"
+fi
+
 quicklinks(){
   output=''
-  tac ${_DATA}/meta/recent |while [ "$(echo "$output" |wc -l)" -lt 10 ] && read line; do
-    line="<a href="$line">$line</a>" 
-    echo "$output" |grep -qF "$line" || output="$output$line\n"
+  tac ${_DATA}/meta/recent \
+  | while [ "$(printf %s "$output" |wc -l)" -lt 10 ] && read line; do
+    printf %s "$output" |grep -qF "$line" || output="$output$line$LF"
   done 
-  echo $output
+  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 %s "<a href="$line">by ${lineo}: $(present_filter "$linef")</a>" 
+  done
 }
 
 category_selected(){
@@ -56,9 +72,9 @@ _printVideo(){
     [ -r "$meta"  ] || genmeta "$videofile" "$meta"
 
     head -n1 "$meta" |read length width height filename
-    [ -z "$length" ] && length=0
-    [ -z "$width"  ] && width=0
-    [ -z "$height" ] && height=0
+    length=$(validate "$length" '[0-9]+' 0)
+    width=$(validate "$width" '[0-9]+' 0)
+    height=$(validate "$height" '[0-9]+' 0)
 
     tags="$(sed -n 2p "$meta")"
     video="$(urlsafe "videos/$info")"