* channel: move to the new templating engine

merge-requests/6/head
Dominique Liberda 2022-11-29 02:58:28 -05:00
parent 7e4e26f0f2
commit dda217195d
2 changed files with 21 additions and 11 deletions

View File

@ -1,2 +1,5 @@
{{.subscribe}}
{{.videos}}
<h1>{{.subscribe}}</h1>
{{.err}}
{{start _videos}}
<a href='/watch?v={{.id}}'><img src='http://i.ytimg.com/vi/{{.id}}/mqdefault.jpg'><br>{{.title}}</a><br>
{{end _videos}}

View File

@ -28,16 +28,23 @@ IFS=$'\n'
video_title=($(jq -r '.entries[].title' <<< $data))
video_id=($(jq -r '.entries[].id' <<< $data))
#strings[subscribe]="<h1>$title</h1><a href='subscribe.shs?id=$(html_encode "${get_data[id]}")'>Subscribe!</a><br>"
strings[subscribe]='<h1>'"$(html_encode "$title")'s channel"'</h1>'
echo uwu > /dev/stderr
for (( i=0; i<${#video_id[@]}; i++ )); do
strings[videos]+="<a href='/watch?v=${video_id[$i]}'><img src='http://i.ytimg.com/vi/${video_id[$i]}/mqdefault.jpg'><br>${video_title[$i]}</a><br>"
done
strings[subscribe]="$(html_encode "$title")"
if [[ ! ${strings[videos]} ]]; then
strings[videos]="Failed to fetch videos or channel does not have videos"
nested_declare meow
declare -A nyaa
for (( i=0; i<${#video_id[@]}; i++ )); do
nyaa[id]="${video_id[$i]}"
nyaa[title]="${video_title[$i]}"
nested_add meow nyaa
done
strings[_videos]+="meow"
nested_get meow 0
strings[err]=''
if [[ "${res[id]}" == '' ]]; then
strings[err]="Failed to fetch videos?"
fi
source "${cfg[namespace]}/templates/header.shs"
render_unsafe strings "${cfg[namespace]}/templates/themes/${cfg[template]}/channel.t"
render strings "${cfg[namespace]}/templates/themes/${cfg[template]}/channel.t"