Invidious is an alternative front-end to YouTube
Add links redirect inside channel description
Féry Mathieu (Mathius)c9594d46afb1
diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.crindex 8ae5034a..4f2df699 100644--- a/src/invidious/helpers/utils.cr+++ b/src/invidious/helpers/utils.cr@@ -391,3 +391,11 @@ def reduce_uri(uri : URI | String, max_length : Int32 = 50, suffix : String = "endreturn strend++def make_html_with_links(baseText : String) : String+ returnValue = baseText.dup+ returnValue.scan(/https?:\/\/[^ \n]*/).each do |match|+ returnValue = returnValue.sub(match[0], "<a href=\"#{match[0]}\">#{match[0]}</a>")+ end+ return returnValue+enddiff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.crindex cd2e3323..88c394c2 100644--- a/src/invidious/routes/channels.cr+++ b/src/invidious/routes/channels.cr@@ -10,7 +10,7 @@ module Invidious::Routes::Channelsif !data.is_a?(Tuple)return dataend- locale, user, subscriptions, continuation, ucid, channel = data+ locale, user, subscriptions, continuation, ucid, channel, description = datapage = env.params.query["page"]?.try &.to_i?page ||= 1@@ -201,6 +201,8 @@ module Invidious::Routes::Channelsreturn error_template(500, ex)end- return {locale, user, subscriptions, continuation, ucid, channel}+ description = make_html_with_links(channel.description_html)++ return {locale, user, subscriptions, continuation, ucid, channel, description}endenddiff --git a/src/invidious/views/channel.ecr b/src/invidious/views/channel.ecrindex 92f81ee4..b8a14afa 100644--- a/src/invidious/views/channel.ecr+++ b/src/invidious/views/channel.ecr@@ -32,7 +32,7 @@<div class="h-box"><div id="descriptionWrapper">- <p><span style="white-space:pre-wrap"><%= channel.description_html %></span></p>+ <p><span style="white-space:pre-wrap"><%= description %></span></p></div></div>