diff --git a/slices/main/decorators/posts/decorator.rb b/slices/main/decorators/posts/decorator.rb
index 388f2ba..6dd2ecd 100644
--- a/slices/main/decorators/posts/decorator.rb
+++ b/slices/main/decorators/posts/decorator.rb
@@ -12,6 +12,8 @@ module Main
module Decorators
module Posts
class Decorator < SimpleDelegator
+ REGEXP = URI::DEFAULT_PARSER.make_regexp
+
def syndicated?
!syndication_sources.empty?
end
@@ -111,6 +113,14 @@ module Main
photos? ? "
#{photos.map { |p| "

" }.join("")} #{content}
" : content
end
+ def rendered_content
+ html_text = wrap_anchors_in_object_tags(replace_urls_with_anchors(content))
+ res = Sanitize.fragment(html_text,
+ elements: ["img", "p", "object", "a"],
+ attributes: {"img" => ["alt", "src", "title"], "a" => ["href"]})
+ res.gsub(prefix_emoji[0], "") if prefix_emoji
+ end
+
def raw_content
res = Sanitize.fragment(content)
res.gsub(prefix_emoji[0], "") if prefix_emoji
@@ -174,6 +184,24 @@ module Main
private
+ def replace_urls_with_anchors(text)
+ url_regex = %r{(?]*(|/>))}
+
+ text.gsub(url_regex) do |url|
+ %()
+ end
+ end
+
+ def wrap_anchors_in_object_tags(text)
+ # Regular expression to match tags
+ anchor_regex = /(]*>.*?<\/a>)/
+
+ # Replace the matched anchor tags with |/>))}
+
+ text.gsub(url_regex) do |url|
+ %(#{url})
+ end
+ end
+
+ def wrap_anchors_in_object_tags(text)
+ # Regular expression to match tags
+ anchor_regex = /(]*>.*?<\/a>)/
+
+ # Replace the matched anchor tags with wrapped anchor tags
+ text.gsub(anchor_regex) do |anchor_tag|
+ %(#{anchor_tag})
+ end
+ end
end
end
end
diff --git a/slices/main/templates/shared/_status.html.slim b/slices/main/templates/shared/_status.html.slim
index b57e431..ec0763e 100644
--- a/slices/main/templates/shared/_status.html.slim
+++ b/slices/main/templates/shared/_status.html.slim
@@ -42,7 +42,7 @@ div class="mb-8 h-entry border border-gray-200 m-2 p-4 bg-gray-50 hover:bg-gray-
video class="rounded w-max" autoplay=false loop=false muted=true controls=true
source type="video/mp4" src="#{video["value"]}"
div class="mb-8"
- p class="text-sm text-blue-400 dark:text-indigo-400"
+ p class="mt-4 text-sm text-blue-400 dark:text-indigo-400"
a class="u-url float-left mr-0 border-dotted border-b-2 border-blue-100 hover:border-blue-200 dark:border-indigo-900 dark:hover:border-indigo-800" href="#{post.permalink}"
time class="dt-published" datetime=post.machine_published_at
= post.display_published_at