From 3d2c4ea2666a1ea1dc20a50d832d1efc4cf61e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9ry=20Mathieu=20=28Mathius=29?= Date: Sun, 13 Mar 2022 22:46:45 +0100 Subject: [PATCH] Add links redirect inside channel description --- src/invidious/helpers/utils.cr | 8 ++++++++ src/invidious/routes/channels.cr | 6 ++++-- src/invidious/views/channel.ecr | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index c1dc17db..3f44a58a 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -383,3 +383,11 @@ def fetch_random_instance return filtered_instance_list.sample(1)[0] end + +def make_html_with_links(baseText : String) : String + returnValue = baseText.dup + returnValue.scan(/https?:\/\/[^ \n]*/).each do |match| + returnValue = returnValue.sub(match[0], "#{match[0]}") + end + return returnValue +end diff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.cr index cd2e3323..88c394c2 100644 --- a/src/invidious/routes/channels.cr +++ b/src/invidious/routes/channels.cr @@ -10,7 +10,7 @@ module Invidious::Routes::Channels if !data.is_a?(Tuple) return data end - locale, user, subscriptions, continuation, ucid, channel = data + locale, user, subscriptions, continuation, ucid, channel, description = data page = env.params.query["page"]?.try &.to_i? page ||= 1 @@ -201,6 +201,8 @@ module Invidious::Routes::Channels return 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} end end diff --git a/src/invidious/views/channel.ecr b/src/invidious/views/channel.ecr index 40b553a9..e25ad2f1 100644 --- a/src/invidious/views/channel.ecr +++ b/src/invidious/views/channel.ecr @@ -32,7 +32,7 @@
-

<%= channel.description_html %>

+

<%= description %>