Add links redirect inside channel description

pull/2968/head
Féry Mathieu (Mathius) 2022-03-13 22:46:45 +01:00
rodzic ca27e096f3
commit c9594d46af
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 935858CF779FB2CE
3 zmienionych plików z 13 dodań i 3 usunięć

Wyświetl plik

@ -391,3 +391,11 @@ def reduce_uri(uri : URI | String, max_length : Int32 = 50, suffix : String = "
end end
return str return str
end end
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
end

Wyświetl plik

@ -10,7 +10,7 @@ module Invidious::Routes::Channels
if !data.is_a?(Tuple) if !data.is_a?(Tuple)
return data return data
end 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 = env.params.query["page"]?.try &.to_i?
page ||= 1 page ||= 1
@ -201,6 +201,8 @@ module Invidious::Routes::Channels
return error_template(500, ex) return error_template(500, ex)
end 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
end end

Wyświetl plik

@ -32,7 +32,7 @@
<div class="h-box"> <div class="h-box">
<div id="descriptionWrapper"> <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>
</div> </div>