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

Your comments are welcome

Last Updated: 2025 January 18 (2025 Jan 14 2025)

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 However, the oldest blogs won’t have a comments section because the topics are too far behind me to bring up again on my timeline.

You’re also welcome to use the filter.

Using the filter

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

TL;DR

  1. modify or create an html template to render variables exported by the script
  2. add to the manuscript’s YAML header pleroma-urls: [https://yourinstance.tld/notice/noticeID]
  3. invoke pandoc with --lua-filter=scripts/pleroma-comments/pleroma-comments.lua \

Here’s an example of how I invoke pandoc.

    pandoc \
    --template $(TEMPLATES)/simple_v4 \
    --lua-filter=scripts/pleroma-comments/pleroma-comments.lua \
    $(DRAFTS)/hanvon-linux.md \
    --toc -o $(RENDERS)/hanvon-linux.html

In hanvon-linux.md (my document), my YAML header has the variable pleroma-urls set like so.

    pleroma-urls: [https://stereophonic.space/notice/AoedWDb9GQhZnP5ylc]

This is a list, so multiple URLs can be included if separated by a comma.

The template should have the variables exported by the script. I have something like this at the bottom of the page template.

    $if(pleroma-urls)$
    <hr/>
    <h2 id="comments">Comments ($pleroma-comments-count$)</h2>
    <p>Reply to any of the bulleted links to leave a comment.</p>
    <ul>
        $for(pleroma)$
        <li><a href="$pleroma.link$">$pleroma.id$</a></li>
        $endfor$
    </ul>
    $pleroma-comments$
    $endif$

The README in the git repo has more detail on what the variables represent.

The resulting “comments” from invoking pandoc includes both the opening post and any replies.

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:

    pleroma_auth_token = "your_access_token"

Execute pandoc as described in using the filter

Commentary

I came across curveballs when writing the lua filter and posted about them on my timeline. I’m including them here as comments partly because I realize I could use the filter as a timeline of notes instead of a comments section.


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

Thanks for reading! Who doesn't love comments? Let me know what you think on my guestbook by e-mail or neocities.


Comments (4)

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.