Fix admin entity decoration

This commit is contained in:
2024-03-29 13:48:24 +11:00
parent 1364d78f29
commit 59f42c235c
8 changed files with 370 additions and 6 deletions

View File

@@ -0,0 +1,56 @@
# frozen_string_literal: false
# auto_register: false
module Admin
module Decorators
module Bookmarks
class Decorator < SimpleDelegator
def display_published_at
published_at.strftime("%e %B, %Y")
end
def display_title
"🔖: #{name}"
end
def feed_content
content || ""
end
def permalink
"#{Hanami.app.settings.micropub_site_url}/bookmark/#{slug}"
end
def machine_published_at
published_at.rfc2822
end
def syndicated?
!syndication_sources.empty?
end
def template_type
:bookmark
end
def syndicated_to
syndication_sources.map do |source, url|
{
location: source,
url: url
}
end
end
def youtube_embed
pattern = /watch[?]v=(\w*)/i
code = url.scan(pattern).flatten.first
if code
"<div class='video-container'><iframe width='100%' src='https://www.youtube.com/embed/#{code}' title='YouTube video player' frameborder='0' allow='accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share' allowfullscreen></iframe></div>"
end
end
end
end
end
end