From 3db8758b1bb7b6cfefedaa648b4846d4a4b13b5a Mon Sep 17 00:00:00 2001
From: chrisfarnham
Date: Sat, 23 Mar 2024 10:54:34 -0400
Subject: [PATCH 1/5] adding embed post and replies features
---
README.md | 24 ++++++++++++++++++++++++
index.html | 22 ++++++++++++++++++----
src/client.ts | 28 ++++++++++++++++++++++++++++
src/core.ts | 25 ++++++++++++++++++++++++-
4 files changed, 94 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index f2102e5..ee4a828 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,30 @@ Emfed sanitizes the HTML contents of toots using [DOMPurify][] to avoid maliciou
[eftm]: https://atp.fm/115
[DOMPurify]: https://github.com/cure53/DOMPurify
+Embedding single posts and replies
+----------------------------------
+
+You can also embed individual posts and its replies. There are options to exclude the post itself and just show replies. Or
+exclude the replies and show the just the post.
+
+This functionality was added to support embedding comments on static sites and was inspired by
+inspired by Carl Schwan's post here: https://carlschwan.eu/2020/12/29/adding-comments-to-your-static-blog-with-mastodon/
+
+To embed a single post and its responses put a special link where you want it to appear:
+
+ Post and replies from the Fediverse
+
+You can customize this link with `data-` attributes:
+
+* `data-exclude-replies`: "true" or "false" according to whether or not you'd like to exclude replies. The default behavior is that replies are included.
+* `data-exclude-post`:"true" or "false" according to whether or not you'd like to exclude the post itself. The default behavior is that the is included. Excluding the post supports behavior described in Carl Schwan's post mentioned above to add comments to a static web page.
+
+Note that `mastodon-post-and-replies` style links and behavior employ the exact styling mechanisms as the standard feed so all CSS
+stylings and links work the same.
+
Hacking
-------
diff --git a/index.html b/index.html
index 47dd096..85963f1 100644
--- a/index.html
+++ b/index.html
@@ -51,7 +51,7 @@
in-browser way to embed
Mastodon
feeds into webpages.
- To make a feed like the one on this page, you use simple markup like
+ To make a feed like the one on the top, right of this page, you use simple markup like
this:
<a class="mastodon-feed"
href="https://mastodon.social/@Mastodon"
@@ -63,6 +63,14 @@
it yourself, however you like):
<link rel="stylesheet" type="text/css"
href="https://esm.sh/emfed@1/toots.css">
+
+ To make embed a post and reply like the right of thie page you can use simple markup like this:
+
+ <a class="mastodon-post-and-replies"
+ href="https://mastodon.social/@Mastodon"
+ data-toot-id="112011697087209298"
+ >Replies to my toot</a>
+
One place you can see Emfed in action is at the
beets project.
The code is
@@ -71,11 +79,17 @@
README.