X-Git-Url: https://git.plutz.net/?p=rawnet;a=blobdiff_plain;f=page_channel.sh;fp=page_channel.sh;h=6042f377cd2e1eeb25bdcc0f4380cdc2b37029c3;hp=36d9dcd777f963299fa7584865243786fc372ac2;hb=1f74ddce2fa9bfa09e486c350702ef7a4d7ed210;hpb=8b374fb64933f92041613b3eb625da593208d275 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 . $(