Display likes
This commit is contained in:
@@ -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
|
||||
|
@@ -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 "
|
||||
|
@@ -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"
|
||||
|
@@ -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}"
|
||||
|
@@ -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
|
||||
|
@@ -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 = {
|
||||
|
Reference in New Issue
Block a user