Show OG metadata for bookmarks
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -30,6 +30,7 @@ gem "reverse_markdown"
|
||||
gem "rexml"
|
||||
gem "babosa"
|
||||
gem "pinboard", git: "https://github.com/dnitza/pinboard", branch: "master"
|
||||
gem "ogpr"
|
||||
|
||||
group :cli, :development do
|
||||
gem "hanami-reloader"
|
||||
|
21
Gemfile.lock
21
Gemfile.lock
@@ -52,6 +52,8 @@ GEM
|
||||
database_cleaner-core (~> 2.0.0)
|
||||
sequel
|
||||
diff-lcs (1.5.0)
|
||||
domain_name (0.5.20190701)
|
||||
unf (>= 0.0.5, < 1.0.0)
|
||||
dotenv (2.8.1)
|
||||
dry-auto_inject (1.0.0)
|
||||
dry-core (~> 1.0, < 2)
|
||||
@@ -178,6 +180,9 @@ GEM
|
||||
dry-validation (>= 1.10, < 2)
|
||||
zeitwerk (~> 2.6.0)
|
||||
hansi (0.2.1)
|
||||
http-accept (1.7.0)
|
||||
http-cookie (1.0.5)
|
||||
domain_name (~> 0.5)
|
||||
httparty (0.21.0)
|
||||
mini_mime (>= 1.0.0)
|
||||
multi_xml (>= 0.5.2)
|
||||
@@ -191,6 +196,9 @@ GEM
|
||||
rb-inotify (~> 0.9, >= 0.9.10)
|
||||
lumberjack (1.2.8)
|
||||
method_source (1.0.0)
|
||||
mime-types (3.4.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2022.0105)
|
||||
mini_mime (1.1.2)
|
||||
multi_xml (0.6.0)
|
||||
mustermann (3.0.0)
|
||||
@@ -202,6 +210,7 @@ GEM
|
||||
net-scp (4.0.0)
|
||||
net-ssh (>= 2.6.5, < 8.0.0)
|
||||
net-ssh (7.0.1)
|
||||
netrc (0.11.0)
|
||||
nio4r (2.5.8)
|
||||
nokogiri (1.14.1-x86_64-darwin)
|
||||
racc (~> 1.4)
|
||||
@@ -210,6 +219,9 @@ GEM
|
||||
notiffany (0.1.3)
|
||||
nenv (~> 0.1)
|
||||
shellany (~> 0.0)
|
||||
ogpr (1.1.0)
|
||||
nokogiri (~> 1.8)
|
||||
rest-client (~> 2.1.0)
|
||||
parallel (1.22.1)
|
||||
parser (3.2.0.0)
|
||||
ast (~> 2.4.1)
|
||||
@@ -230,6 +242,11 @@ GEM
|
||||
ffi (~> 1.0)
|
||||
redcarpet (3.6.0)
|
||||
regexp_parser (2.6.2)
|
||||
rest-client (2.1.0)
|
||||
http-accept (>= 1.7.0, < 2.0)
|
||||
http-cookie (>= 1.0.2, < 2.0)
|
||||
mime-types (>= 1.16, < 4.0)
|
||||
netrc (~> 0.8)
|
||||
reverse_markdown (2.1.1)
|
||||
nokogiri
|
||||
rexml (3.2.5)
|
||||
@@ -314,6 +331,9 @@ GEM
|
||||
tilt (2.0.11)
|
||||
timecop (0.9.6)
|
||||
transproc (1.1.1)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.8.2)
|
||||
unicode-display_width (2.4.2)
|
||||
zeitwerk (2.6.6)
|
||||
|
||||
@@ -342,6 +362,7 @@ DEPENDENCIES
|
||||
hanami-validations (~> 2.0.0)
|
||||
hanami-view!
|
||||
httparty
|
||||
ogpr
|
||||
pg
|
||||
pinboard!
|
||||
puma
|
||||
|
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
|
@@ -6,6 +6,7 @@ module Adamantium
|
||||
class App < Hanami::App
|
||||
config.actions.content_security_policy[:script_src] += " https://gist.github.com"
|
||||
config.actions.content_security_policy[:script_src] += " *.dnitza.com"
|
||||
config.actions.content_security_policy[:script_src] += " https://unpkg.com/htmx.org@1.8.4"
|
||||
config.actions.content_security_policy[:connect_src] += " https://stats.dnitza.com/api/event"
|
||||
|
||||
config.logger.level = :debug
|
||||
|
@@ -12,6 +12,6 @@ on_worker_boot do
|
||||
Hanami.shutdown
|
||||
end
|
||||
|
||||
pidfile ENV.fetch("PIDFILE") { "tmp/pids/puma.pid" }
|
||||
pidfile ENV.fetch("PIDFILE", "tmp/pids/puma.pid")
|
||||
|
||||
preload_app!
|
||||
|
@@ -20,6 +20,7 @@ module Adamantium
|
||||
get "/posts", to: "posts.index"
|
||||
|
||||
get "/bookmarks", to: "bookmarks.index"
|
||||
get "/bookmarks/metadata/:id", to: "bookmarks.metadata"
|
||||
get "/bookmark/:slug", to: "bookmarks.show"
|
||||
|
||||
get "/tagged/:slug", to: "tags.show"
|
||||
|
Reference in New Issue
Block a user