]> git.plutz.net Git - rawnet/commitdiff
list_videos function including sorting
authorPaul Hänsch <paul@plutz.net>
Mon, 25 Oct 2021 12:20:30 +0000 (14:20 +0200)
committerPaul Hänsch <paul@plutz.net>
Mon, 25 Oct 2021 12:20:30 +0000 (14:20 +0200)
db_video.sh
page_channel.sh
rawnet.css
widgets.sh

index 05fe1e2da97ab229936a206d2396ff6c9c330568..16bf43455f06d2b8ee66207707ccf05ffc06d384 100755 (executable)
@@ -161,3 +161,26 @@ delete_video() {
     return 1
   fi
 }
+
+list_videos(){
+  local order="${1:-newest}" vid_db="$_DATA/$CHANNEL_ID/videos.db"
+  [ "$CHANNEL_ID" ] || return 1
+
+  [ -f "$vid_db" -a -r "$vid_db" ] && case "$order" in
+    name)
+      sort -k2 "$vid_db"
+      ;;
+    shortest)
+      sort -n -k6 "$vid_db"
+      ;;
+    longest)
+      sort -rn -k6 "$vid_db"
+      ;;
+    oldest)
+      cat "$vid_db"
+      ;;
+    newest|*)
+      tac "$vid_db"
+      ;;
+  esac
+}
index f2d073843bc54c6dfbca78001ab53e0dcfd8949f..36d9dcd777f963299fa7584865243786fc372ac2 100755 (executable)
@@ -71,7 +71,6 @@ if [ "$CHANNEL_ID" -a "$action" = edit ]; then
        ]
        EOF
 elif [ "$CHANNEL_ID" ]; then
-  vid_db="$_DATA/$CHANNEL_ID/videos.db"
   yield_page "$CHANNEL_NAME" "channel" <<-EOF
        [nav [a href="../" Channels] - [span $(HTML "${CHANNEL_NAME:-(Unnamed Channel)}")]]
        [h1 .name $(HTML "$CHANNEL_NAME")]
@@ -84,8 +83,7 @@ elif [ "$CHANNEL_ID" ]; then
               [hidden "video" "%s"]
               [submit "action" "newvideo" New Video]
             ]' "$(timeid)"
-         [ -f "$vid_db" -a -r "$vid_db" ] \
-         && while w_video; do :; done <"$vid_db"
+         list_videos |while w_video; do :; done
        )]
        EOF
 else
index 5fa017b12fd6dadb14824cb9f3856e89395e622c..650da603b77da4d1779bd9b4bb66901c3ed6f2ce 100644 (file)
@@ -122,6 +122,7 @@ body.channels main .channel {
 
 body.channels main .channel > .description {
   overflow: hidden;
+  margin-right: -.5%;
 }
 body.channels main .channel > .description h2 {
   margin: 0;
index f844ba4db31b1032dc4d4aefaf2b0938db1941b3..b951216f64643134ed0add2e9650435e48a59c30 100755 (executable)
@@ -34,21 +34,16 @@ w_video(){
 }
 
 w_channel(){
-  local vid_db
   eval "$LOCAL_CHANNEL"
 
   if read_channel; then
-    vid_db="${_DATA}/${CHANNEL_ID}/videos.db"
-
     cat <<-EOF
        [div .channel
          [div .description
            [h2 [a href="${_BASE}/channel/${CHANNEL_ID}/" $(HTML "${CHANNEL_NAME:-(Unnamed Channel)}")]]
            ${CHANNEL_DESCR_CACHE}
-         ]$(
-            [ -f "$vid_db" -a -r "$vid_db" ] \
-           && while w_video; do :; done <"$vid_db"
-         )
+         ]
+         $( list_videos |while w_video; do :; done; )
        ]
        EOF
   else