avatar
scuti
not quite a star in Stereophonic Space
https://scuti.neocities.org/

Your comments are welcome

2025 Jan 14 2025 (E: 2025 Nov 15)

View 4 comment(s).

You can comment on my blogs from the Fediverse by replying to specific statuses listed at the bottom of the page.1

If you want to use the filter your website, you’re also welcome too.

Comments for your own site

Here are minimum working examples.

Invocation:

   pandoc \
   --lua-filter=scripts/pleroma-comments/main.lua \
    mwe.md -o mwe.html

If your instance requires authorization for API access, there is an extra step.

Manuscript:

---
title:  Untitled
pleroma-urls: [https://stereophonic.space/notice/AqDLiXSazGKJpGZcPI]
...

Test.

HTML Template:

<!DOCTYPE html>
<html>
  <head>
    <title>$title$</title>
  </head>
  <body>

  $if(pleroma-has-comments)$
  <a href="#comments">View $pleroma-comments-count$ comment(s).</a>
  $endif$

  $body$

  $if(pleroma-urls)$
  <hr/>
  <h2 id="comments">Comments ($pleroma-comments-count$)</h2>
  <ul>
      $for(pleroma)$
      <li><a href="$pleroma.link$">$pleroma.id$</a></li>
      $endfor$
  </ul>
  $pleroma-comments$
  $endif$

</body>
</html>

If authorization is required

The following links describe how to authorize an application (this Lua filter) by acquiring an access token. This phase involves using curl and/or a web browser.

  1. Register the Lua filter (the “application” = the “client”) with the instance. https://docs.joinmastodon.org/client/token/#creating-our-application

  2. Authorize the client to access the account. https://docs.joinmastodon.org/client/authorized/#client

After following the aforementioned steps, the server should have returned an access token. Upon visiting yourinstance.tld in a web browser, if you open Settings > Security: OAuth Token, the change should be reflected there. You, the user, can always revoke the token if needed be.

In your local file system and the working directory where pandoc is executed, make or edit a file named config.lua:

-- don't include protocol:// or '/' at the end
pleroma_auth["yourinstance.tld"] = "your_access_token"

Execute pandoc as described previously.

Configuration

In config.lua …

Case: you want avatars on your own server either for archival purposes or to avoid hotlinking.

-- both variables must not be nil
-- don't forget to put a '/' at the end

-- this is the path to which the avatar is downloaded
pleroma_avatar_save_path = "path/to/folder/"
-- this is the path rendered on the page
pleroma_avatar_path = "path/to/folder/"

Case: your instance limits conversations to signed-in users; random visitors from the web can not load posts including the reply button. Therefore, provide the link of the reply button.

pleroma_reply_href = "/main/ostatus?status_id="

  1. This Lua filter is shared with: https://antares.neocities.org/blog/pandoc-filter-pleroma-comments. It’s also his idea.↩︎


Comments (4)

Your comments are welcome.

Reply to any of the bulleted links to leave a comment.

#4 Sat, January 18, 2025

avatar
tuxmain @tuxmain@toot.aquilenet.fr

@scuti Test comment

<b>test HTML injection</b>

#3 Sat, January 18, 2025

avatar
scuti🌱 @scuti
I got a @pandoc / #pandoc filter and a blog that needed a comments section. Read about the Lua filter on #neocities and comment by replying to this post.
Just for Stereophonic Space (how it's configured), I made a branch and added some tweaks.
#fediverse
https://scuti.neocities.org/pages/your-comments-are-welcome

Your comments are welcome

You can comment on some of my blogs because I’m pulling posts from the Fediverse by using a Pandoc filter written in Lua.

#2 Sun, December 08, 2024

avatar
scuti🌱 @scuti
TIL if I'm writing a lua filter for pandoc and going to run a command (curl or wget, with `-H` or `--header=`), just use `io:popen` instead of `pandoc.pipe()`.
#pandoc #lua

#1 Fri, December 06, 2024

avatar
scuti🌱 @scuti
Currently working on
https://git.projectsegfau.lt/scuti/pleroma-comments/src/branch/local-avatar
Found out that lua filters can't access variables set by flags in pandoc e.g `pandoc -V foo="bar"` even though chatgpt insists they can.
So I have to figure out something else even if its less than ideal.
#pandoc #lua

pleroma-comments

Pandoc filter that generates a comments section based on replies from Pleroma.