From: Paul Hänsch Date: Wed, 27 Oct 2021 23:21:48 +0000 (+0200) Subject: add and remove channel authors X-Git-Url: https://git.plutz.net/?p=rawnet;a=commitdiff_plain;h=1f74ddce2fa9bfa09e486c350702ef7a4d7ed210 add and remove channel authors --- diff --git a/page_channel.sh b/page_channel.sh index 36d9dcd..6042f37 100755 --- a/page_channel.sh +++ b/page_channel.sh @@ -20,6 +20,21 @@ read_channel "$channel" fi ;; update_channel) + authors="${USER_ID}" + n="$(POST_COUNT author)" + while [ $n -gt 0 ]; do + newauthor="$(POST author $n |checkid)" + user_idmap "$newauthor" && authors="${authors}${BR}${newauthor}" >&- + n=$((n - 1)) + done + n="$(POST_COUNT newauthor)" + while [ $n -gt 0 ]; do + newauthor="$(POST newauthor $n)" + newauthor="$(user_idof "$newauthor")" \ + && authors="${authors}${BR}${newauthor}" + n=$((n - 1)) + done + if [ ! "$CHANNEL_ID" ]; then REDIRECT "${_BASE}/channel/#ERROR_NOCHANNEL" elif [ ! "$USER_ID" ]; then @@ -28,7 +43,7 @@ read_channel "$channel" REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_UPDATE_NOTALLOWED" elif update_channel "$CHANNEL_ID" "name=$(POST name)" \ "description=$(POST description)" \ - "authors=$USER_ID"; then + "authors=${authors}"; then REDIRECT "${_BASE}/channel/$CHANNEL_ID/" else REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_UPDATE_NOLOCK" @@ -63,9 +78,26 @@ esac if [ "$CHANNEL_ID" -a "$action" = edit ]; then AUTHOR || REDIRECT "${_BASE}/$CHANNEL_ID/#ERROR_EDIT_NOTALLOWED" yield_page "$CHANNEL_NAME - Edit" "channel edit" <<-EOF + [datalist #list_authors + $(user_idmap |cut -f2 |UNSTRING |while read name; do + printf '[option value="%s"]' "$(HTML "$name")" + done) + ] [form .channel .edit method=POST [input name="name" value="$(HTML "$CHANNEL_NAME")" placeholder="Channel Name" autocomplete=off] [textarea name="description" placeholder="Description" . $(HTML "$CHANNEL_DESCRIPTION")] + [div .authors [h3 Authors:] + $(for each in $CHANNEL_AUTHORS; do + printf '[checkbox "author" "%s" id="author_%s" %s %s][label for="author_%s" . %s]\n' \ + "$each" "$each" "checked=checked" "$([ "$each" = "$USER_ID" ] && printf 'disabled=disabled')" \ + "$each" "$(user_idmap "$each" |UNSTRING |HTML)" + done + for n in 0 1 2 3 4 5 6 7 8 9; do + printf '[checkbox "" "" #newauthor%i][label for=newauthor%i . +] + [input name=newauthor value="" placeholder="Author" list=list_authors]' \ + $n $n + done) + ] [submit "action" "update_channel" . Update] [submit "action" "update_channel_cancel" . Cancel] ] @@ -75,6 +107,11 @@ elif [ "$CHANNEL_ID" ]; then [nav [a href="../" Channels] - [span $(HTML "${CHANNEL_NAME:-(Unnamed Channel)}")]] [h1 .name $(HTML "$CHANNEL_NAME")] [div .description . ${CHANNEL_DESCR_CACHE}] + [div .authors [h3 Authors:] + $(for each in $CHANNEL_AUTHORS; do + printf '[span .author . %s]\n' "$(user_idmap "$each" |UNSTRING |HTML)" + done |sort |debug) + ] $(AUTHOR && printf '[a .button href="edit" edit]') [h1 .videos Videos] [div .videos . $( diff --git a/rawnet.css b/rawnet.css index 650da60..454e8a4 100644 --- a/rawnet.css +++ b/rawnet.css @@ -268,3 +268,70 @@ body.video video { left: 0; top: 0; right: 0; bottom: 0; line-height: 1.375em; } + +button, a.button { + margin-top: .375em; +} + +body.channel .authors h3 { + display: inline-block; +} +body.channel.edit .authors h3 { + margin-bottom: 0; + display: block; +} +body.channel .authors span:after { + content: ','; +} +body.channel .authors span:last-child:after { + content: ''; +} + +body.channel.edit .authors input[name=author] { + margin-left: .5em; +} +body.channel.edit .authors input[name=author] { + z-index: 1; +} +body.channel.edit .authors input[name=author] + label { + padding: .25em .5em .125em .25em; + margin: 0 0 .5em 0; + padding-left: 1.25em; + margin-left: -1.25em; + border: .5pt solid; + background-color: rgba(255, 255, 255, .75); +} +body.channel.edit .authors input[name=author], +body.channel.edit .authors input[name=author] + label { + display: none; +} +body.channel.edit .authors input[name=author]:checked, +body.channel.edit .authors input[name=author]:checked + label { + display: inline-block; +} +body.channel.edit .authors input[id^=newauthor] + label { + background-color: #FFF; + border: 1pt solid; + width: 1.5em; height: 1.5em; + text-align: center; +} + +body.channel.edit .authors input[id^=newauthor] + label + input { + vertical-align: middle; +} +body.channel.edit .authors input[id^=newauthor], +body.channel.edit .authors input[id^=newauthor] + label, +body.channel.edit .authors input[id^=newauthor] + label + input { + display: none; +} +body.channel.edit .authors input[id^=newauthor0] + label { + display: inline-block; +} +body.channel.edit .authors input[id^=newauthor]:checked + label + input, +body.channel.edit .authors input[id^=newauthor]:checked + label + input + input + label { + display: inline-block; +} +body.channel.edit .authors input[id^=newauthor]:checked + label, +body.channel.edit .authors input[id^=newauthor]:checked + label + input + input:checked + label { + display: none; +}