Make hashtags in video titles clickable

This commit is contained in:
hibutwhy 2026-08-23 22:10:52 -07:00
parent f755969050
commit 1832a12d29
2 changed files with 17 additions and 1 deletions

View File

@ -386,6 +386,18 @@ def parse_link_endpoint(endpoint : JSON::Any, text : String, video_id : String)
return text
end
def linkify_hashtags(title : String) : String
String.build do |str|
pos = 0
title.scan(/#([a-zA-Z0-9_]+)/) do |match|
str << title[pos...match.begin(0)]
str << %(<a href="/hashtag/#{URI.encode_path(match[1])}">#{match[0]}</a>)
pos = match.end(0)
end
str << title[pos..]
end
end
def encrypt_ecb_without_salt(data, key)
cipher = OpenSSL::Cipher.new("aes-128-ecb")
cipher.encrypt

View File

@ -93,7 +93,11 @@ we're going to need to do it here in order to allow for translations.
<div class="h-box">
<h1>
<%= title %>
<% if video.title.matches?(/#\w/) %>
<%= linkify_hashtags(title) %>
<% else %>
<%= title %>
<% end %>
<% if params.listen %>
<a title="<%=I18n.translate(locale, "Video mode")%>" id="link-iv-listen" data-base-url="/watch?<%= env.params.query %>&listen=0" href="/watch?<%= env.params.query %>&listen=0">
<i class="icon ion-ios-videocam"></i>