X-Git-Url: http://git.plutz.net/?p=serve0;a=blobdiff_plain;f=list.sh;h=a4bdbc797490d31e68700e559476dcc8d02e4319;hp=e9a98c0ecf8e75d8a338c8d06350d612568edaf9;hb=608e267413cf7f8399cacbbfc4269d3c3820a3aa;hpb=b3e752c8f50110859bc9e3aaf9d709e2006b3de6 diff --git a/list.sh b/list.sh index e9a98c0..a4bdbc7 100644 --- a/list.sh +++ b/list.sh @@ -87,13 +87,48 @@ list_filter(){ fi } +groupmatch(){ + a="${1%$CR}" b="${2%$CR}" +# if [ ${#a} -gt ${#b} ]; then +# long="$a" short="$b" +# else +# long="$b" short="$a" +# fi + # com="$(expr substr "$long" 1 $((${#long} * 3 / 4)))" + # com="$(expr substr "$long" 1 $((${#long} - 3)))" + ## Cut off youtube- and other site suffixes. Cut of last three characters + com="$(printf %s "$a" |sed -E 's;-([0-9a-zA-Z_-]{11}|ph[0-9a-f]{13}|[0-9]{8})$;;; s;...$;;;')" + cut="${b#$com}" + if [ "${cut}" != "${b}" ]; then + return 0 + else + return 1 + fi +} + list_order(){ - local fm fn fn + local fm fn fn al length ln h w t c name buffer l if [ $ORDER = Name ]; then sort -k6 |sed 's;^;metashort\t;;' + elif [ $ORDER = Group ]; then + { sort -k6; echo '0 0 0 tags= comment= _'; } \ + | while read -r length h w t c name; do + if groupmatch "$ln" "$name"; then + al=$((al + length)) + buffer="${buffer}${BR}$length $h $w $t $c $name" + else + printf %s\\n "$buffer" |while read -r l; do + [ "$l" ] && printf '%s %s\n' "$al" "$l" + done + al="$length" + buffer="$length $h $w $t $c $name" + fi + ln="$name" + done \ + | sort -sn -k1 |sed -r 's;^[0-9]+\t;metashort\t;;' elif [ $ORDER = Length ]; then - sort -n -k1 |sed 's;^;metashort\t;;' + sort -sn -k1 |sed 's;^;metashort\t;;' elif [ $ORDER = Date ]; then while read -r fm; do sn="${fm##* }" @@ -101,7 +136,7 @@ list_order(){ printf '%i %s %s\n' \ "$(stat -c %Y "$fn")" "${fm% *}" "$fn" done \ - | sort -rn -k1 |cut -f2- |sed 's;^;metalong\t;;' + | sort -srn -k1 |sed -r 's;^[0-9]+\t;metalong\t;;' fi } @@ -178,7 +213,10 @@ printf 'Content-Type: text/html;charset=utf-8\r\n\r\n' { printf ' [!DOCTYPE HTML] -[html [head [title Listing] +[html [head [title ' + w_bmname + printf ' by %s]' "$ORDER" + printf ' [meta name="viewport" content="width=device-width"] [link rel=stylesheet href="/style.css" ] ] [body