Show OG metadata for bookmarks
This commit is contained in:
13
app/actions/bookmarks/metadata.rb
Normal file
13
app/actions/bookmarks/metadata.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Adamantium
|
||||
module Actions
|
||||
module Bookmarks
|
||||
class Metadata < Action
|
||||
include Deps["views.bookmarks.metadata"]
|
||||
|
||||
def handle(req, res)
|
||||
res.render metadata, id: req.params[:id]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
7
app/templates/bookmarks/metadata.html.slim
Normal file
7
app/templates/bookmarks/metadata.html.slim
Normal file
@@ -0,0 +1,7 @@
|
||||
- if image
|
||||
div class="col-span-1"
|
||||
img class="rounded h-16" src=image
|
||||
|
||||
div class="#{image ? 'col-span-4' : 'col-span-5'}"
|
||||
h6= title
|
||||
small= description
|
@@ -8,6 +8,8 @@ div class="mb-12 prose max-w-prose mx-auto text-gray-800 dark:text-gray-200"
|
||||
|
||||
== bookmark.content
|
||||
|
||||
div class="prose max-w-prose mx-auto text-gray-800 dark:text-gray-200 grid grid-cols-5 gap-2" hx-get="/bookmarks/metadata/#{bookmark.id}" hx-trigger="load"
|
||||
|
||||
div class="mb-8 max-w-screen-md mx-auto border-t-4 border-solid border-gray-400 dark:border-gray-600"
|
||||
|
||||
div class="mb-2 max-w-prose mx-auto text-gray-800 dark:text-gray-200 flex"
|
||||
|
@@ -20,7 +20,7 @@ html
|
||||
|
||||
script data-domain="dnitza.com" src="https://stats.dnitza.com/js/script.js" defer="true"
|
||||
|
||||
/ script src="https://unpkg.com/htmx.org@1.8.4" integrity="sha384-wg5Y/JwF7VxGk4zLsJEcAojRtlVp1FKKdGy1qN+OMtdq72WRvX/EdRdqg/LOhYeV" crossorigin="anonymous"
|
||||
script src="https://unpkg.com/htmx.org@1.8.4" integrity="sha384-wg5Y/JwF7VxGk4zLsJEcAojRtlVp1FKKdGy1qN+OMtdq72WRvX/EdRdqg/LOhYeV" crossorigin="anonymous"
|
||||
|
||||
- if Hanami.app.settings.micropub_pub_key
|
||||
link rel="pgpkey" href="/key"
|
||||
|
30
app/views/bookmarks/metadata.rb
Normal file
30
app/views/bookmarks/metadata.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
require "ogpr"
|
||||
|
||||
module Adamantium
|
||||
module Views
|
||||
module Bookmarks
|
||||
class Metadata < View
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
config.layout = nil
|
||||
|
||||
expose :description do |og_data|
|
||||
og_data.description
|
||||
end
|
||||
|
||||
expose :title do |og_data|
|
||||
og_data.title
|
||||
end
|
||||
|
||||
expose :image do |og_data|
|
||||
og_data.image
|
||||
end
|
||||
|
||||
private_expose :og_data do |id:|
|
||||
url = post_repo.find!(id).url
|
||||
Ogpr.fetch(url)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user