Bernhard Scheirle


About Me

Hello, my name is Bernhard.
I'm a computer science student at Karlsruher Institute of Technology.

Contact Me



blogroll


Static comments via email


WHAT?!

Comments in a static generated site without an external service how is this even possible?

It is quite simple, the form below (only on the article page) generates a "mailto-link". In the resulting email is a valid markdown block which only must be copied in a special folder: comments/{slug}/ and the next time you build your site the comment appears. *magic*

Pelican plugin

You may or may not know the already existing static comment plugin for pelican. The problem with this plugin is that all comments for one article are stored in a single markdown file. Therefore it is difficult too style your comments. I created a new plugin so that each comment is now in it's own markdown file. Additionally I made all meta information of these files public to the theme.

For setup instructions and theme examples, please have a look at the documentation: pelican_comment_system

Auto import of comments

If you want to import new comments from your mailbox automatically have a look at the imap_importer plugin. It can import arbitrary text content (articles, pages, comments, ...) from an IMAP server.

Currently it doesn't work out of the box with the pelican_comment_system, because the imap_importer plugin requires the email to contain certain keywords. Adding these keywords to the pelican_comment_system is easy. I just haven't done it yet, as most users probably don't want to use the imap_importer plugin.

Comments


  • Avatar

    Posted on

    Example comment:

    Paragraphs are separated by a blank line.

    Text attributes italic, bold, monospace.

    A link.

    Shopping list:

    • apples
    • oranges
    • pears

    Numbered list:

    1. apples
    2. oranges
    3. pears

    • Avatar

      Posted on

      This is an awesome way to have comments on my page. I will try this out.

      Thanks a lot!


      • Avatar

        Posted on

        Comment unbelievable!

    • Avatar

      Posted on

      This looks good

  • Avatar

    Posted on

    Different authors a detected with the metadata, but you decide what is considered:

    1
    PELICAN_COMMENT_SYSTEM_IDENTICON_DATA = ('author', 'email')
    
  • Avatar

    Posted on

    A unknown author. Therefore an identicon is generated.

    The size of the identicon can be set with:

    1
    PELICAN_COMMENT_SYSTEM_IDENTICON_SIZE = 72
    

    PELICAN_COMMENT_SYSTEM_IDENTICON_SIZE has to be a multiple of 3.

  • Avatar

    Posted on

    I'm the same author as above, so I have the same identicon :)

  • Avatar

    Posted on

    A known author with a special avatar:

    1
    2
    3
    PELICAN_COMMENT_SYSTEM_AUTHORS = {
        ('Known Test Author', 'test@test.de'): "images/authors/testauthor.jpg"
    }
    

    Note: The tuple elements are arranged as in PELICAN_COMMENT_SYSTEM_IDENTICON_DATA

  • Avatar

    Posted on

    You should investigate hitting an IMAP server with credentials and parsing the inbox for new comments. Then you've got a pretty neat bit of code to contribute to Pelican.


    D


    • Avatar

      Posted on

      I already thought about that too. Here some thoughts I have:

      IMAP storage

      I first thought about using IMAP to store all comments, but this comes with a few disadvantages:

      • Storing all comments in one folder leads to a messy folder.
      • Storing the comments in different folders on a per article base isn't possible because many providers limit the amount of folders.
      • All comments have to be re-downloaded every build.
      • You can't edit the comments, because you can't edit emails. A workaround would be to delete the email and send yourself an edited version.
      Auto download

      A other approach would be to download (and remove?) comment emails and store them locally in the content directory.

      • We only have to download new comments which is faster.
      • You can edit comments easily.
      • There is no need to change the plugin. We only have to add a script which downloads and extract new comments from your IMAP folder.

      • Avatar

        Posted on

        I wrote a prove of concept plugin (imap_importer). It can import arbitrary text content (articles, pages, comments, ...) from an IMAP server.

  • Avatar

    Posted on

    Interesting approach. How do you validate the input? I didn't see any check_plain()/... functions invoked before sending the mail.

    Best regards
    Dirk


    • Avatar

      Posted on

      The script that generate the mail does currently not validate the input. But is a validation necessary?

      To answer this question we first have to know if there is invalid input and can we prevent it.

      1. Technically all input is valid as long as a pelican reader can process it.
        So there is invalid data, but in this case pelican displays an error and I can fix it manually (This is way less work than implementing an validator in javascript.).

        • What is with valid but unwanted data (like html)?
          If a user has a cool html snippet to improve the comment display, I don't want to hinder them sending it to me. I can always decide while proofreading if I want to include it or not.
      2. The user can always modify the e-mail directly before sending it and therefore can always enter invalid data.

      Only the link-generation uses an encoder to ensure a valid url independent of the user input. For this purpose I'm using the encodeURIComponent(...) function.

  • Avatar

    Posted on

    Moinmoin,

    in der avatars.md-Datei fehlten im Beispiel in den Zeilen 20 und 21 die Kommas, die das Tupel deklarieren. Bis ich das begriffen habe, hat's etwas gedauert ;)

    Pull request ist hier: https://github.com/getpelican/pelican-plugins/pull/579

    Danke! (auch für das Plugin :) )
    Viele Grüße,
    Moini

  • Avatar

    Posted on

    awesome

  • Avatar

    Posted on

    Hi!
    Tolles Plugin!

    Was mich interessieren jetzt würde, ist die Mail, die der Kommentator versendet, automatisch zu verarbeiten und als Kommentar zu publizieren.

    Ich denke da so an:

    • Mail aus Postfach abholen (fetchmail)
    • Den Kommentar inklusive Metadaten rausfiltern und validieren, ggfs. alles Unnötige löschen
    • Den Kommentar in die entsprechende Datei kopieren
    • Kommentar laden

    Hast Du schon mal über so etwas nachgedacht? Machbar wäre es sicherlich.


    • Avatar

      Posted on

      Tolles Plugin!

      Danke :)

      Hast Du schon mal über so etwas nachgedacht? Machbar wäre es sicherlich.

      Ja, habe auch schon an so etwas gedacht (Siehe Kommentar 9).

      Habe mal ein proof of concept Plugin geschrieben: imap_importer
      Das kann sogar nicht nur Kommentare sondern jegliche Art von Text (Artikel, Seiten, ...) importieren.


      • Avatar

        Posted on

        Danke, hab ich vollkommen übersehen. Werde ich bei Gelegenheit mal testen!

  • Avatar

    Posted on

    But do you have to check each email yourself?


    • Avatar

      Posted on

      Currently I check each email myself.

      But I started working on a plugin to automatically import comments.

      [I updated the article, so now it mentions the plugin.]

  • Avatar

    Posted on

    I came here via looking for Isso plugin for Pelican. Is your pelican_comment_system the same thing as Isso? Maybe it doesn't really matter, but I am curious.

    I am not a speaker of german but I can sort of understand it when I read it out loud. That is so odd and interesting. I guess it shows the germanic links in the english language. Of course when I run into a word like nachgedacht I don't probably pronounce it right so I stumble on it.

    I like the idea of forcing comments by email. The only problem is that not everyone has their browser setup for mailto:

    Thanks for this plugin, danke. I will try it out.


    • Avatar

      Posted on

      Is your pelican_comment_system the same thing as Isso?

      Nope.

      Isso is a commenting server (similar to Disqus, but self hosted) and therefore requires a server side component. The comments are live rendered on every page load. This allows you to add comment without rerunning pelican.

      The pelican_comment_system on the other hand is purely static (no server side component required). To add a comment you have to rerun pelican.

      The only problem is that not everyone has their browser setup for mailto:

      That is true. But I don't think that is a huge problem.

      1. The pelican_comment_system does not force you to use the mailto form.
        You can simply tell your visitors to send you an e-mail to post a comment.
        (e.g. https://aweirdimagination.net does it this way.)

      2. Setting up mailto is really easy:

        • Dedicated mail application => one click setup
        • Modern web mail services (e.g. gmail, owncloud-mail, ...) => one click setup
  • Avatar

    Posted on

    It's really special! I'm now using isso!

Add a Comment

You may format you comment with Markdown.

Comment Atom Feed