diff --git a/slices/main/repos/post_repo.rb b/slices/main/repos/post_repo.rb index d24dbdf..bb09781 100644 --- a/slices/main/repos/post_repo.rb +++ b/slices/main/repos/post_repo.rb @@ -186,7 +186,7 @@ module Main .published .combine(:tags, :trips, :webmentions, :reactions, :highlights) .node(:webmentions) { |webmention| - webmention.published.where(type: "reply") + webmention.published.where(type: ["reply", "like"]) } .where(slug: slug) .one! @@ -197,7 +197,7 @@ module Main .published .combine(:tags, :trips, :webmentions) .node(:webmentions) { |webmention| - webmention.published.where(type: "reply") + webmention.published.where(type: ["reply", "like"]) } .where(slug: slug) .one diff --git a/slices/main/templates/posts/show.html.slim b/slices/main/templates/posts/show.html.slim index 5dc3487..0cb1d19 100644 --- a/slices/main/templates/posts/show.html.slim +++ b/slices/main/templates/posts/show.html.slim @@ -57,15 +57,15 @@ article class="h-entry" - if post.location img loading="lazy" class="shadow-solid shadow-pink-100 dark:shadow-pink-200 rounded mb-4" src=post.large_map div class="max-w-prose mx-auto text-gray-600 dark:text-gray-200 flex" - = render "shared/reactions", post: post - - if post.webmentions && post.webmentions.count > 0 + = render "shared/reactions", post: post, replies: replies, likes: likes + - if replies && replies.count > 0 div class="mt-12" h3 - = "#{post.webmentions.count} Comment#{post.webmentions.count != 1 ? "s" : ""}" + = "#{replies.count} Comment#{replies.count != 1 ? "s" : ""}" - if post.commentable == " · " a href="mailto:blog@dnitza.com?subject=About that post of yours&body=%0A%0A---%0A(In reply to #{post.permalink})" reply - - post.webmentions.each do |mention| + - replies.each do |mention| - if mention.source_url.match Hanami.app.settings.micropub_site_url div class="prose-p:m-1 mb-6 p-2 bg-orange-100 dark:bg-indigo-900 rounded" = "Mentioned in " diff --git a/slices/main/templates/shared/_reactions.html.slim b/slices/main/templates/shared/_reactions.html.slim index 438f167..0dc6bb9 100644 --- a/slices/main/templates/shared/_reactions.html.slim +++ b/slices/main/templates/shared/_reactions.html.slim @@ -3,9 +3,15 @@ button hx-post="/posts/#{post.slug}/react" hx-trigger="click" class="group no-un = "👍 " span = " #{post.reactions.count}" -- if post.webmentions && post.webmentions.count == 0 && post.commentable +- if replies && replies.count == 0 && post.commentable a class="group no-underline px-2 py-1 border rounded border-blue-100 hover:text-indigo-600 dark:border-indigo-900 hover:border-blue-200 hover:bg-blue-100 hover:dark:bg-indigo-900 hover:dark:border-indigo-400 text-gray-400 dark:text-indigo-200 mr-2 hover:scale-110 transition-all mr-2" href="mailto:blog@dnitza.com?subject=About that post of yours&body=%0A%0A---%0A(In reply to #{post.permalink})" span class="inline-block group-hover:-rotate-12 transition-all" = "💌 " span = " Reply " +- if likes && likes.count > 0 + span class="px-2 py-1" Liked by: + - likes.each do |like| + div class="float-left h-8 w-8 mr-1" + a class="inline-block py-1" href="#{like.source_url}" + img src="#{like.author_photo}" class="rounded m-0 p-0" diff --git a/slices/main/templates/shared/_tags.html.slim b/slices/main/templates/shared/_tags.html.slim index 12aaaeb..a5639a8 100644 --- a/slices/main/templates/shared/_tags.html.slim +++ b/slices/main/templates/shared/_tags.html.slim @@ -1,7 +1,7 @@ - if tags.count > 0 p class="mb-2 dark:text-gray-200" = "Tagged" - div class="mb-2 justify-end gap-x-1.5" + div class="mb-2 justify-end gap-x-1.5 grid grid-rows-2 grid-flow-col" - tags.each do |post_tag| span a class="p-category rounded mr-1 u-url text-pink-400 hover:text-pink-600 dark:text-pink-400 dark:hover:text-pink-100 text-gray-600" href="/tagged/#{post_tag.slug}" diff --git a/slices/main/views/posts/show.rb b/slices/main/views/posts/show.rb index fade162..f78d9a6 100644 --- a/slices/main/views/posts/show.rb +++ b/slices/main/views/posts/show.rb @@ -42,6 +42,14 @@ module Main Decorators::Posts::Decorator.new(post_repo.fetch(slug)) end end + + expose :replies do |post| + post.webmentions.select {|w| w[:type] == "reply" } + end + + expose :likes do |post| + post.webmentions.select {|w| w[:type] == "like" } + end end end end diff --git a/slices/micropub/actions/webmentions/create.rb b/slices/micropub/actions/webmentions/create.rb index 2e88c8f..6dcf6fa 100644 --- a/slices/micropub/actions/webmentions/create.rb +++ b/slices/micropub/actions/webmentions/create.rb @@ -27,7 +27,7 @@ module Micropub slug = req.params[:post][:"like-of"].split("/").last post = post_repo.fetch!(slug) - reply[:post_id] = post.id + like[:post_id] = post.id webmentions_repo.create(like) res.body = {