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
+}
]
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")]
[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
body.channels main .channel > .description {
overflow: hidden;
+ margin-right: -.5%;
}
body.channels main .channel > .description h2 {
margin: 0;
}
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