-w_video(){
- local thumb
- local VIDEO_ID VIDEO_NAME VIDEO_DESCRIPTION VIDEO_RESX VIDEO_RESY \
- VIDEO_LENGTH VIDEO_COVER VIDEO_STATUS VIDEO_UPLOADER VIDEO_HITS \
- VIDEO_DESCR_CACHE VIDEO_FUTUREUSE
-
- if read -r VIDEO_ID VIDEO_NAME VIDEO_DESCRIPTION VIDEO_RESX VIDEO_RESY \
- VIDEO_LENGTH VIDEO_COVER VIDEO_STATUS VIDEO_UPLOADER VIDEO_HITS \
- VIDEO_DESCR_CACHE VIDEO_FUTUREUSE; then
- VIDEO_NAME="$(UNSTRING "$VIDEO_NAME")"
- VIDEO_DESCRIPTION="$(UNSTRING "$VIDEO_DESCRIPTION")"
- VIDEO_DESCR_CACHE="$(UNSTRING "$VIDEO_DESCR_CACHE")"
- VIDEO_LENGTH="$(printf %i "$VIDEO_LENGTH" 2>&-)"
-
- [ "${VIDEO_STATUS}" = public ] || AUTHOR || return 0
-
- thumb="${_BASE}/video/${CHANNEL_ID}/${VIDEO_ID}_thumb.jpg"
- [ "$NAME" = \\ ] && NAME="(Unnamed Video)"
- printf '[div .video .thumb
- [a href="%s/channel/%s/%s/"
- [h3 . %s]
- [figure [img src="%s" alt=""]]
- [span .duration . %i:%02i]
- [div .description . %s]
- ]
- ]' "$_BASE" "$CHANNEL_ID" "$VIDEO_ID" \
- "$(HTML "${VIDEO_NAME:-(Unnamed Video)}")" \
- "$thumb" \
- "$((VIDEO_LENGTH / 60))" "$((VIDEO_LENGTH % 60))" \
- "$(UNSTRING "$DESCR_CACHE")"
- else
- return 1
- fi
-}
-
-w_channel(){
- local vid_db
- local CHANNEL_ID CHANNEL_NAME CHANNEL_DESCRIPTION CHANNEL_LOGO \
- CHANNEL_THEME CHANNEL_AUTHORS CHANNEL_DESCR_CACHE CHANNEL_FUTUREUSE
-
- if read -r CHANNEL_ID CHANNEL_NAME CHANNEL_DESCRIPTION CHANNEL_LOGO \
- CHANNEL_THEME CHANNEL_AUTHORS CHANNEL_DESCR_CACHE \
- CHANNEL_FUTUREUSE; then
- CHANNEL_NAME="$(UNSTRING "$CHANNEL_NAME")"
- CHANNEL_DESCRIPTION="$(UNSTRING "$CHANNEL_DESCRIPTION")"
- CHANNEL_AUTHORS="$(UNSTRING "$CHANNEL_AUTHORS")"
- CHANNEL_DESCR_CACHE="$(UNSTRING "$CHANNEL_DESCR_CACHE")"
-
- 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"
- )
- ]
- EOF
- else
- return 1
- fi
-}
-
-w_channel_list(){
- if [ $USER_ID ]; then
- printf '
- [form .channel .newchannel method=POST
- [hidden "channel" "%s"]
- [submit "action" "newchannel" New Channel]
- ]' "$(timeid)"
- fi
- [ -f "$chan_db" -a -r "$chan_db" ] \
- && while w_channel; do :; done <"$chan_db"
-}
-
-if [ "$channel" -a "$video" ]; then
- . ${_EXEC}/page_video.sh
-elif [ "$channel" -a "$action" = edit ]; then
- AUTHOR || REDIRECT "${_BASE}/${channel}/#ERROR_EDIT_NOTALLOWED"