Add replies to posts
This commit is contained in:
@@ -192,6 +192,17 @@ module Main
|
||||
.one!
|
||||
end
|
||||
|
||||
def fetch(slug)
|
||||
posts
|
||||
.published
|
||||
.combine(:tags, :trips, :webmentions)
|
||||
.node(:webmentions) { |webmention|
|
||||
webmention.published.where(type: "reply")
|
||||
}
|
||||
.where(slug: slug)
|
||||
.one
|
||||
end
|
||||
|
||||
def find!(id)
|
||||
posts
|
||||
.by_pk(id)
|
||||
|
@@ -17,6 +17,13 @@ article class="h-entry"
|
||||
h1 class="p-name mb-2"
|
||||
a class="u-url" href=post.permalink
|
||||
= post.display_title
|
||||
- if post.in_reply_to
|
||||
div class=""
|
||||
em = "In reply to: "
|
||||
- if reply_in_context
|
||||
a class="no-underline bg-pink-50 hover:bg-pink-100 dark:bg-pink-600 hover:dark:bg-pink-900 p-1 rounded" href=post.in_reply_to #{reply_in_context.display_title}
|
||||
- else
|
||||
a class="no-underline bg-pink-50 hover:bg-pink-100 dark:bg-pink-600 hover:dark:bg-pink-900 p-1 rounded" href=post.in_reply_to #{post.in_reply_to}
|
||||
nav class="space-x-1 text-sm md:text-sm md:block dark:text-gray-600"
|
||||
- if post.location || post.photos? || post.videos?
|
||||
span See more:
|
||||
|
@@ -4,7 +4,7 @@ module Main
|
||||
module Views
|
||||
module Posts
|
||||
class Show < Main::View
|
||||
include Deps["repos.post_repo", "repos.movie_repo"]
|
||||
include Deps["repos.post_repo", "repos.movie_repo", "settings"]
|
||||
|
||||
expose :post do |slug:|
|
||||
Decorators::Posts::Decorator.new(post_repo.fetch!(slug))
|
||||
@@ -35,6 +35,13 @@ module Main
|
||||
expose :trip do |post|
|
||||
post.trips.first
|
||||
end
|
||||
|
||||
expose :reply_in_context do |post|
|
||||
if post.in_reply_to&.match settings.micropub_site_url
|
||||
slug = post.in_reply_to.split("/").last
|
||||
Decorators::Posts::Decorator.new(post_repo.fetch(slug))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user