Skip to content

Pelican plugin to fetch webmentions from webmention.io and display them to the static pages

License

Notifications You must be signed in to change notification settings

kappa-wingman/webmention_static_kappa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webmention static comment plugin for Pelican

This plugin is to be used or tested with webmention.io JF2 endpoint. The output from that endpint should be in JF2 format.

This plugin references multiple projects related to Webmentions and Pelican plugin:

Options

  • PLUGINS += ['webmention_static_kappa']

  • WEBMENTION_USERNAME = 'Update to your username in webmention.io'

  • WEBMENTION_FETCH_URL = 'https://webmention.io/'+WEBMENTION_USERNAME+'/webmention'

  • WEBMENTION_SITEURL = 'Usually same as SITEURL'

  • WEBMENTION_IO_JF2_URL = 'https://webmention.io/api/mentions.jf2'

  • MAX_ITEMS was effective for old version (non cache version)

    • New version of this plugin fetches all the Webmentions for the domain in one single file

      But this option also control the maximum items to display

    • WEBMENTION_IO_MAX_ITEMS = 50

  • You need to create the cache directory manually

    • WARNING, it would overwrite the file in below when static pages start to generate
    • WEBMENTION_IO_CACHE_FILENAME = './webmention-cache/cache.json'
  • WEBMENTION_IO_DOMAIN = 'Replace by the hostname of your website here, no need to put https://'

  • WEBMENTION_IO_OVERWRITE_INITIAL_CACHE = False - Overwrite initial cache file

  • WEBMENTION_IO_UPDATE_INITIAL_CACHE = True - Update initial cache file

  • WEBMENTION_IO_REPLIED_PAGINATION_SIZE - For paging replies, WIP

Sample template

You probably need a template to use display the output from the plugin. Below is just an example, you should add styling and change the layout. Repeat for other items like articles.webmentions.liked and etc.

{% if article.webmentions.mentioned %}
    <p> List of mentions: </p>
  {% for item_mentioned in article.webmentions.mentioned %}
     <a href="{{ item_mentioned['wm-source'] }}"
        rel="nofollow noopener noreferrer ugc"
        title="{{ item_mentioned['author_name'] }} {{ item_mentioned['reaction'] }}">
     {% if item_mentioned['author_photo'] %}
        <img src="{{ item_mentioned['author_photo'] }}">
     {% endif %}
     {{ item_mentioned['icon'] }}{{ item_mentioned['author_name'] }}
     </a> : {{ item_mentioned['name'] }}
  {% endfor %}
{% endif %}

Notes

This plugin is not perfect. There are areas for improvement:

  • Pagination. Useful if there are lots of Webmentions to display.

About

Pelican plugin to fetch webmentions from webmention.io and display them to the static pages

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages