]> git.plutz.net Git - rawnet/commitdiff
delete function for video
authorPaul Hänsch <paul@plutz.net>
Thu, 14 Oct 2021 13:08:02 +0000 (15:08 +0200)
committerPaul Hänsch <paul@plutz.net>
Thu, 14 Oct 2021 13:08:02 +0000 (15:08 +0200)
page_video.sh
rawnet.css

index 296148472cb430d26ad363ceb307824791f0eb79..b7b9953787d44effcf2913027ab5ab0b0a3f3ff5 100644 (file)
@@ -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
index 99bb014059b0fc81a1bb435bb48e12c0af442b2d..aca0303760fb05946b7d74017090d3612e131a22 100644 (file)
@@ -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;
+}
+