From ed901fda6f4aa593314bc34eed00f5563732d793 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Wed, 29 Sep 2021 13:08:17 +0200 Subject: [PATCH] control elements for channel editing --- page_channel.sh | 12 +++++++++--- rawnet.css | 10 +++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/page_channel.sh b/page_channel.sh index 223f882..d12f417 100755 --- a/page_channel.sh +++ b/page_channel.sh @@ -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")] [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" ] \ diff --git a/rawnet.css b/rawnet.css index 68fa629..93de0da 100644 --- a/rawnet.css +++ b/rawnet.css @@ -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; -- 2.39.2