]> git.plutz.net Git - rawnet/blobdiff - page_channel.sh
UI styling, breadcrumb navigation
[rawnet] / page_channel.sh
index 223f88298794fd1a6319b6cb0bbbd5e11d07feae..159c865e66ad1705128b1b3099bc01418024956b 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")"
@@ -96,6 +96,9 @@ update_channel(){
       REDIRECT "${_BASE}/channel/${channel}/#ERROR_UPDATE_NOLOCK"
     fi
     ;;
+  update_channel_cancel)
+    REDIRECT "${_BASE}/channel/${channel}/"
+    ;;
   newvideo)
     video="$(POST video |checkid)"
     # database video create
@@ -124,9 +127,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,15 +157,23 @@ 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]
+         [submit "action" "update_channel_cancel" . Cancel]
        ]
        EOF
 elif [ "$channel" ]; then
   yield_page "$CHANNEL_NAME" "channel" <<-EOF
+       [nav [a href="../" Channels] - [span $(HTML "${CHANNEL_NAME:-(Unnamed Channel)}")]
+         $( [ "$USER_ID" -a ! "${CHANNEL_AUTHORS##*${USER_ID}*}" ] \
+             && printf ' - [a href="edit" edit]'
+          )
+       ]
        [h1 .name $(HTML "$CHANNEL_NAME")]
        [div .description . ${CHANNEL_DESCR_CACHE}]
        [div .videos