]> git.plutz.net Git - serve0/blobdiff - pages/list.sh
added licence headers, coding style improvements
[serve0] / pages / list.sh
index 2d3cbf3bad443f2eb5c0aec98ee6c8afbc60dca9..0870961fa124b7b498214dd66d2cef358a441406 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"
 
 quicklinks(){
   output=''
-  tac ${_DATA}/meta/recent |while [ "$(echo "$output" |wc -l)" -lt 10 ] && read line; do
+  tac ${_DATA}/meta/recent \
+  | while [ "$(printf %s "$output" |wc -l)" -lt 10 ] && read line; do
     line="<a href="$line">$line</a>" 
-    echo "$output" |grep -qF "$line" || output="$output$line\n"
+    printf %s "$output" |grep -qF "$line" || output="$output$line$LF"
   done 
-  echo $output
+  printf %s\\n "$output"
 }
 
 category_selected(){
@@ -56,9 +59,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")"