Add email comments to posts

This commit is contained in:
2024-03-10 13:21:06 +11:00
parent c52e7fe87f
commit 273be35a61
12 changed files with 129 additions and 32 deletions

View File

@@ -10,6 +10,7 @@ module Admin
def call(params:)
attrs_to_replace = {}
attrs_to_replace[:content] = markdown.call(content: params[:body]) if params[:body]
attrs_to_replace[:commentable] = params[:commentable]
tags = params[:tags].split(",").map(&:strip)

View File

@@ -3,6 +3,13 @@ module Admin
class WebmentionRepo < Adamantium::Repo[:webmentions]
commands update: :by_pk
def list_all_for_check
webmentions
.exclude(source_url: "email")
.order(:id)
.to_a
end
def list_all
webmentions
.order(:id)

View File

@@ -30,6 +30,9 @@ article class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 d
form action="/admin/post/#{post.id}/update" method="POST"
textarea name="body" class="text-gray-800 w-full border-blue-200 border-2 rounded p-2 mb-4" x-data="{ resize: () => { $el.style.height = '5px'; $el.style.height = $el.scrollHeight + 'px' } }" x-init="resize()" @input="resize()"
== markdown_body
fieldset class="mb-4 flex"
label for="commentable" class="mr-2" Commentable?
input class="mt-2" type="checkbox" value="true" id="commentable" name="commentable" switch="switch" checked=post.commentable
fieldset class="mb-4 flex"
label for="tags" class="mr-2" Tags:
input type="text" name="tags" id="tags" class="w-full px-1 border rounded" value="#{post.tags.map(&:label).join(", ")}"

View File

@@ -32,7 +32,10 @@ div class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:
span
== webmention.content_html
td
a href="#{webmention.source_url}" Source
- if webmention.source_url == "email"
= "email"
- else
a href="#{webmention.source_url}" Source
td
a href="#{webmention.target_url}" Target
td

View File

@@ -50,19 +50,32 @@ 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
-if post.webmentions && post.webmentions.count > 0
- if post.webmentions && post.webmentions.count == 0 && post.commentable
a href="mailto:blog@dnitza.com?subject=About that post of yours&body=%0A%0A---%0A(In reply to #{post.permalink})" Reply
- if post.webmentions && post.webmentions.count > 0
div class="mt-12"
h3 #{post.webmentions.count} Comment#{post.webmentions.count != 1 ? "s" : ""}
h3
= "#{post.webmentions.count} Comment#{post.webmentions.count != 1 ? "s" : ""}"
- if post.commentable
== " &middot; "
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|
div class="prose-p:m-1 mb-6 p-8 bg-orange-100 dark:bg-indigo-900 squircle"
div class="flex h-8"
img loading="lazy" class="w-8 rounded-full m-0 mr-2" src=mention.author_photo
a class="block text-orange-700 dark:text-violet-300 no-underline hover:underline" href=mention.author_url
= mention.author_name
- if mention.author_photo != ""
img loading="lazy" class="w-8 rounded-full m-0 mr-2" src=mention.author_photo
- if mention.author_url == ""
= "From #{mention.author_name}"
- else
a class="block text-orange-700 dark:text-violet-300 no-underline hover:underline" href=mention.author_url
= mention.author_name
div class="prose dark:prose-invert dark:text-indigo-250 prose-a:text-orange-700 dark:prose-a:text-violet-300 prose-a:no-underline hover:prose-a:underline"
== mention.content_html
div class="text-sm"
a class="no-underline hover:underline text-orange-900 dark:text-violet-400" href=mention.source_url
- if mention.source_url != "email"
a class="no-underline hover:underline text-orange-900 dark:text-violet-400" href=mention.source_url
= mention.published_at.strftime("%e %B, %Y")
- else
= mention.published_at.strftime("%e %B, %Y")
div class="mb-12"
- if trip