From 579795d83fca209a7aa34f7f7eca2026ef0f4d5d Mon Sep 17 00:00:00 2001 From: "4 raccoons in a trenchcoat. / luna vivian" Date: Fri, 21 Apr 2023 15:40:11 +0200 Subject: [PATCH] =?UTF-8?q?fixed=20some=20stuff=E2=84=A2=20in=20/channel?= =?UTF-8?q?=20page=20-=20Subscribe=20links:=20/channel/{CHANNEL=5FID}=20li?= =?UTF-8?q?nks=20work=20now!=20-=20Channel=20name=20now=20gets=20hidden=20?= =?UTF-8?q?when=20it=20fails=20to=20fetch=20videos=20(-=20now=20also=20hid?= =?UTF-8?q?ing=20verbose=20error=20handling=20text!)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/themes/default-v2/channel.html | 2 +- webroot/channel.shs | 28 +++++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/templates/themes/default-v2/channel.html b/templates/themes/default-v2/channel.html index 165e962..23ce287 100644 --- a/templates/themes/default-v2/channel.html +++ b/templates/themes/default-v2/channel.html @@ -1,4 +1,4 @@ -

Channel "{{.subscribe}}"

+{{start ?cnnc}}

Channel "{{.subscribe}}"

{{end ?cnnc}} {{.err}} {{start ?sub}}Subscribe to {{.subscribe}}!

{{end ?sub}} {{start ?unsub}}Unsubscribe from {{.subscribe}}!

{{end ?unsub}} diff --git a/webroot/channel.shs b/webroot/channel.shs index 6a3a992..7565c63 100644 --- a/webroot/channel.shs +++ b/webroot/channel.shs @@ -29,11 +29,26 @@ if [[ "${get_data[id]}" ]]; then else strings[?login]=true #strings[login_r]=$(sed -s 's/?/___/' <<< "${r[url]}") - strings[login_r]="channel.shs___id=${get_data[id]}" + strings[login_r]="channel/${get_data[id]}" + fi +elif [[ "${params[id]}" ]]; then + if [[ "${cookies[sh_session]}" != '' ]]; then + if [[ $(grep $(session_get_username "${cookies[sh_session]}") storage/subscribed | grep "${strings[channel_id]}") == '' ]]; then + strings[?sub]=true + strings[channel_id]="${params[id]}" + else + strings[?unsub]=true + strings[channel_id]="${params[id]}" + fi + else + strings[?login]=true + #strings[login_r]=$(sed -s 's/?/___/' <<< "${r[url]}") + strings[login_r]="channel/${params[id]}" fi -else - strings[?suberror]=true fi +#else + #strings[?suberror]=true +#fi title=$(jq -r '.title' <<< $data) @@ -47,7 +62,10 @@ IFS=$'\n' video_title=($(jq -r 'if .entries[].channel_follower_count != null then .entries[].entries[] else .entries[] end | .title' <<< $data)) video_id=($(jq -r 'if .entries[].channel_follower_count != null then .entries[].entries[] else .entries[] end | .id' <<< $data)) -strings[subscribe]="$(html_encode "$title" | sed -E "s/ - Videos//g")" +if [[ $title != 'null' ]]; then + strings[?cnnc]=true + strings[subscribe]="$(html_encode "$title" | sed -E "s/ - Videos//g")" +fi nested_declare meow declare -A nyaa @@ -62,7 +80,7 @@ strings[_videos]+="meow" nested_get meow 0 strings[err]='' if [[ "${res[id]}" == '' ]]; then - strings[err]="Failed to fetch videos... :c" + strings[err]="Failed to fetch videos." fi render strings "${cfg[namespace]}/templates/themes/${cfg[template]}/channel.html"