From ba23425f0e01d62612b425c2e7b96517df1c9fde Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Thu, 14 Oct 2021 15:08:02 +0200 Subject: [PATCH] delete function for video --- page_video.sh | 29 ++++++++++++++++++++++++++--- rawnet.css | 21 +++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/page_video.sh b/page_video.sh index 2961484..b7b9953 100644 --- a/page_video.sh +++ b/page_video.sh @@ -126,6 +126,25 @@ UPLOAD(){ update_video_cancel) REDIRECT "${_BASE}/channel/${channel}/${video}/#CANCELED" ;; + delete) + if [ ! "$USER_ID" ]; then + REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_NOTLOGGEDIN" + elif ! AUTHOR; then + REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPDATE_NOTALLOWED" + elif [ "$(POST delconfirm)" != confirm ]; then + REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_NOT_CONFIRMED" + elif LOCK "$vid_db"; then + while read -r id tail; do + [ "$id" != "$video" ] && printf '%s %s\n' "$id" "$tail" + done <"$vid_db" >"${vid_db}.$$" + mv -- "${vid_db}.$$" "$vid_db" + rm -- "${_DATA}/${channel}/${video}.mp4" "${_DATA}/${channel}/${video}_thumb.jpg" + RELEASE "$vid_db" + REDIRECT "${_BASE}/channel/${channel}/#DELETE_CONFIRM" + else + REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPDATE_NOLOCK" + fi + ;; esac if [ "$REQUEST_METHOD" = POST -a "$channel" -a "$video" ]; then @@ -158,6 +177,11 @@ if [ "$channel" -a "$video" -a "$action" = edit ]; then [textarea name="description" placeholder="Description" . $(HTML "$VIDEO_DESCRIPTION")] [submit "action" "update_video" . Update] [submit "action" "update_video_cancel" . Cancel] + [fieldset .delete + [checkbox "delconfirm" "confirm" id="delconfirm"] + [label for=delconfirm Delete Video] + [submit "action" "delete" Delete Video] + ] ] EOF @@ -219,9 +243,7 @@ elif [ "$channel" -a "$video" ]; then [ $VIDEO_STATUS = public -o $VIDEO_STATUS = hidden ] || AUTHOR || { . ${_EXEC}/page_404.sh; exit 0; } yield_page "$VIDEO_NAME" "video" <<-EOF - [nav [a href="../../" Channels] - [a href="../" $(HTML "${CHANNEL_NAME:-(Unnamed Channel)}")] - [span $(HTML "${VIDEO_NAME:-(Unnamed Video)}")] - $(AUTHOR && printf ' - [a href="edit" edit]') - ] + [nav [a href="../../" Channels] - [a href="../" $(HTML "${CHANNEL_NAME:-(Unnamed Channel)}")] - [span $(HTML "${VIDEO_NAME:-(Unnamed Video)}")]] $( AUTHOR && [ $VIDEO_STATUS = void ] && printf ' [iframe src="frameuploadprogress" width="100%%" height="50" [a href="freameuploadprogress" Iframe: Upload progress] @@ -237,6 +259,7 @@ elif [ "$channel" -a "$video" ]; then [source src="%s/video/%s/%s.mp4"] ]' "$_BASE" "$channel" "$video" ) + $(AUTHOR && printf '[a .button href="edit" edit]') [h1 .name $(HTML "$VIDEO_NAME")] [div .description . ${VIDEO_DESCR_CACHE}] EOF diff --git a/rawnet.css b/rawnet.css index 99bb014..aca0303 100644 --- a/rawnet.css +++ b/rawnet.css @@ -212,3 +212,24 @@ body.channels main .channel > .description h2 { .video.thumb .description:hover { max-height: 8em; } + +.video.edit form > .delete { + text-align: right; +} +.video.edit form #delconfirm + label:after { + content: '\0A'; + white-space: pre; +} +.video.edit form #delconfirm + label + button { + pointer-events: none; + color: #AAA; + border-color: #AAA; + left: -.75em; +} +.video.edit form #delconfirm:checked + label + button { + pointer-events: auto; + color: inherit; + border-color: inherit; + background-color: #FDD; +} + -- 2.39.2