Invidious is an alternative front-end to YouTube
Increase size of links displayed in video description
Féry Mathieu (Mathius)78c447829a60
diff --git a/src/invidious/comments.cr b/src/invidious/comments.crindex ab9fcc8b..e2c7b3a0 100644--- a/src/invidious/comments.cr+++ b/src/invidious/comments.cr@@ -587,7 +587,7 @@ def content_to_comment_html(content)endend- text = %(<a href="#{url}">#{text}</a>)+ text = %(<a href="#{url}">#{reduce_uri(url)}</a>)elsif watch_endpoint = run["navigationEndpoint"]["watchEndpoint"]?length_seconds = watch_endpoint["startTimeSeconds"]?video_id = watch_endpoint["videoId"].as_s@@ -595,10 +595,10 @@ def content_to_comment_html(content)if length_seconds && length_seconds.as_i > 0text = %(<a href="javascript:void(0)" data-onclick="jump_to_time" data-jump-time="#{length_seconds}">#{text}</a>)else- text = %(<a href="/watch?v=#{video_id}">#{text}</a>)+ text = %(<a href="/watch?v=#{video_id}">#{reduce_uri("/watch?v=#{video_id}")}</a>)endelsif url = run.dig?("navigationEndpoint", "commandMetadata", "webCommandMetadata", "url").try &.as_s- text = %(<a href="#{url}">#{text}</a>)+ text = %(<a href="#{url}">#{reduce_uri(url)}</a>)endenddiff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.crindex a58a21b1..f8a7873d 100644--- a/src/invidious/helpers/utils.cr+++ b/src/invidious/helpers/utils.cr@@ -365,3 +365,14 @@ def fetch_random_instancereturn filtered_instance_list.sample(1)[0]end++def reduce_uri(uri : URI | String, max_length : Int32? = 50, suffix : String? = "...") : String+ str = uri.to_s.sub(/https?:\/\//, "")+ if !max_length.nil? && str.size > max_length+ str = str[0, max_length]+ if !suffix.nil?+ str = "#{str}#{suffix}"+ end+ end+ return str+end