From 64f49a3461f5e22bc3950bfa9e9e8bcf2f1e08ac Mon Sep 17 00:00:00 2001 From: "4 raccoons in a trenchcoat. / luna vivian" Date: Fri, 21 Apr 2023 15:07:20 +0200 Subject: [PATCH] redesigned and revised /channel page - added (un-)subscribe button (and error handling when no channel ID is given) - changed the view from a weird list to a 3-column grid on maximum width - fixed behaviour where it sometimes would attach " - Videos" to channel name --- templates/themes/default-v2/channel.html | 16 ++++++++++++---- webroot/channel.shs | 22 ++++++++++++++++++++-- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/templates/themes/default-v2/channel.html b/templates/themes/default-v2/channel.html index 32b66ee..165e962 100644 --- a/templates/themes/default-v2/channel.html +++ b/templates/themes/default-v2/channel.html @@ -1,7 +1,15 @@ -

{{.subscribe}}

+

Channel "{{.subscribe}}"

{{.err}} -{{start ?sub}}Subscribe to {{.uploader}}!
{{end ?sub}} -{{start ?unsub}}Unsubscribe from {{.uploader}}!
{{end ?unsub}} +{{start ?sub}}Subscribe to {{.subscribe}}!

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

{{end ?unsub}} +{{start ?login}}Log in to subscribe to this channel!

{{end ?login}} +{{start ?suberror}}Couldn't fetch Channel ID... :/ ((un-)subscribe buttons have been hidden for this reason)

{{end ?suberror}} +
{{start _videos}} -
{{.title}}

+
+ +
+ {{.title}}
+
{{end _videos}} +
diff --git a/webroot/channel.shs b/webroot/channel.shs index 3a2a88e..6a3a992 100644 --- a/webroot/channel.shs +++ b/webroot/channel.shs @@ -17,6 +17,24 @@ else return fi +if [[ "${get_data[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]="${get_data[id]}" + else + strings[?unsub]=true + strings[channel_id]="${get_data[id]}" + fi + else + strings[?login]=true + #strings[login_r]=$(sed -s 's/?/___/' <<< "${r[url]}") + strings[login_r]="channel.shs___id=${get_data[id]}" + fi +else + strings[?suberror]=true +fi + title=$(jq -r '.title' <<< $data) if [[ ${cfg[template]} != 'retro' ]]; then @@ -29,7 +47,7 @@ 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")" +strings[subscribe]="$(html_encode "$title" | sed -E "s/ - Videos//g")" nested_declare meow declare -A nyaa @@ -44,7 +62,7 @@ strings[_videos]+="meow" nested_get meow 0 strings[err]='' if [[ "${res[id]}" == '' ]]; then - strings[err]="Failed to fetch videos?" + strings[err]="Failed to fetch videos... :c" fi render strings "${cfg[namespace]}/templates/themes/${cfg[template]}/channel.html"