]> git.plutz.net Git - rawnet/commitdiff
control elements for channel editing
authorPaul Hänsch <paul@plutz.net>
Wed, 29 Sep 2021 11:08:17 +0000 (13:08 +0200)
committerPaul Hänsch <paul@plutz.net>
Wed, 29 Sep 2021 11:08:17 +0000 (13:08 +0200)
page_channel.sh
rawnet.css

index 223f88298794fd1a6319b6cb0bbbd5e11d07feae..d12f41719f3a70cd262ed532c4ccecadcf128494 100755 (executable)
@@ -26,7 +26,7 @@ if [ "$channel" -a -f "$chan_db" -a -r "$chan_db" ]; then
        $(grep "^${channel}     " "${chan_db}")
        EOF
   if [ "$CHANNEL_ID" ]; then
-           CHANNEL_NAME="$(UNSTRING "$CHANNEL_NAME")"
+           CHANNEL_NAME="$(UNSTRING "${CHANNEL_NAME}")"
     CHANNEL_DESCRIPTION="$(UNSTRING "$CHANNEL_DESCRIPTION")"
         CHANNEL_AUTHORS="$(UNSTRING "$CHANNEL_AUTHORS")"
     CHANNEL_DESCR_CACHE="$(UNSTRING "$CHANNEL_DESCR_CACHE")"
@@ -124,9 +124,10 @@ w_channel(){
   local ID NAME DESCRIPTION LOGO THEME AUTHORS DESCR_CACHE FUTUREUSE
   if read -r ID NAME DESCRIPTION LOGO THEME AUTHORS DESCR_CACHE FUTUREUSE; then
     vid_db="${_DATA}/${ID}/videos.db"
+    [ "$NAME" = \\ ] && NAME="(UNNAMED CHANNEL)"
     cat <<-EOF
        [div .channel
-         [h2 . $(UNSTRING "$NAME" |HTML)]
+         [h2 [a href="${_BASE}/channel/${ID}/" $(UNSTRING "${NAME}" |HTML)]]
          [div .description . $(UNSTRING "$DESCR_CACHE")]
          $( [ -f "$vid_db" -a -r "$vid_db" ] \
             && while w_video "$ID"; do :; done <"$vid_db"
@@ -153,16 +154,21 @@ w_channel_list(){
 if [ "$channel" -a "$video" ]; then
   . ${_EXEC}/page_video.sh
 elif [ "$channel" -a "$action" = edit ]; then
+  [ "$USER_ID" -a ! "${CHANNEL_AUTHORS##*${USER_ID}*}" ] \
+  || REDIRECT "${_BASE}/${channel}/#ERROR_EDIT_NOTALLOWED"
   yield_page "$CHANNEL_NAME - Edit" "channel edit" <<-EOF
        [form .channel .edit method=POST
          [input name="name" value="$(HTML "$CHANNEL_NAME")" placeholder="Channel Name"]
-         <textarea name="description" placeholder="Description">$(HTML "$CHANNEL_DESCRIPTION")</textarea>
+         [textarea name="description" placeholder="Description" . $(HTML "$CHANNEL_DESCRIPTION")]
          [submit "action" "update_channel" . Update]
        ]
        EOF
 elif [ "$channel" ]; then
   yield_page "$CHANNEL_NAME" "channel" <<-EOF
        [h1 .name $(HTML "$CHANNEL_NAME")]
+       $( [ "$USER_ID" -a ! "${CHANNEL_AUTHORS##*${USER_ID}*}" ] \
+           && printf '[a href="edit" edit]'
+        )
        [div .description . ${CHANNEL_DESCR_CACHE}]
        [div .videos
          $( [ -f "$vid_db" -a -r "$vid_db" ] \
index 68fa629c94e909f88a4b23b6f28af11a45c2a0ee..93de0dad5874882a0b964c6cc817bf9d05861a37 100644 (file)
@@ -36,11 +36,19 @@ main {
 body.channel main h1.name {
   text-align: center;
 }
-body.channel main .description {
+body.channel main .description,
+body.channel main form.edit.channel {
   max-width: 40em;
   margin: auto;
 }
 
+body.channel main form.edit.channel input[name=name],
+body.channel main form.edit.channel textarea[name=description] {
+  display: block;
+  width: 100%;
+  margin-bottom: .5em;
+}
+
 body.channels main .channel {
   border: 1pt solid;
   border-radius: 4pt;