Webmention tweaks

,

Why

Webmentions were shown as “Peter mentioned this on ruk.ca”, but that does not provide context for a reader to decide if they want to click to go there. So I want to display a part of the linked item, as a teaser. Years ago pingbacks were presented like that on my site.

What

Find out how webmentions are stored, and how they are presented. Change the presentation by displaying an excerpt.

How

It turned out that webmentions are actually stored in full (so the text of the linked item is available in my wordpress database). It was just that the template for how it got presented needed tweaking. There is also a character count limit, below which a mention is indeed shown as I like it. All this however isn’t done in the theme, but in a plugin, called Semantic Linkbacks and in a specific file: class-linkbacks-handler.php. Once I localised that, I could change what I needed.
So I

  1. changed the character count limit to 500
    // Mentions with content less than this length will be rendered inline.
    define( 'MAX_INLINE_MENTION_LENGTH', 500 );
  2. changed the template for a webmention in public static function get_comment_type_excerpts()
    It was 'mention'=> __( '%1$s mentioned %2$s on href="%3$s">%4$s., 'semantic-linkbacks' )
    I changed it to
    'mention'=> __( '%1$s mentioned %2$s on href="%3$s">%4$s: %5$s', 'semantic-linkbacks' )
    This adds a 5th parameter at the end. This will hold the excerpt.
  3. Then filled that template in, in function public static function comment_text_excerpt
    • After it sets the length of the webmention, stored in $text in $text_len I evaluated that to see if it is longer then the limit. If so it sets a delimiter $text_delim to that maximum, or else sets it to the actual length.
    • Then I create a text snippet from the start of the text to that delimiter $text_snip = substr($text, 0, $text_delim) and add a few dots to the end $text_snip .=" ...."
    • That snippet is then added as 5th parameter to a call of the template mentioned above $text = sprintf( $comment_type_excerpts[ $semantic_linkbacks_type ], get_comment_author_link( $comment->comment_ID ), $post_type, $url, $host, $text_snip);

ToDo

  • This tweak is to a plugin, so the next update will overwrite my changes. Need to figure out how to post it back to the plugin source so it might get incorporated as an option
  • Still need to change how the excerpt is selected. Now it is some 500 characters from the start of a posting. I want it to be 500 characters around the actual link.
  • It seems I need to change webmentions for various types, as a reply to a comment I made is shown as ‘x mentioned y’ (I changed it to the text of the actual comment by hand in this case.)
  • 4 reactions on “Webmention tweaks

    ,

    1. A summary overview of changes I made to this site, to make it more fully a indieweb hub / my core online presence.
      Theme related tweaks

      Created child theme of Sempress, to be able to change appearance and functions
      Renamed comments to reactions (as they contain likes, reposts, mentions etc.)
      in the entry-footer template and the comments template
      Removed h-card microformats, and put in a generic link to my about page for the author in the Sempress function sempress_posted_on. Without a link to the author mentions show up as anonymous elsewhere.
      Removed the sharing buttons I used (although they were GDPR compliant using the Sharriff plugin, but they got in the way a lot I felt.
      Functionality related tweaks

      To show excerpts from webmentions I changed the template for a webmention in the Semantinc backlinks plugin, class-linkbacks-handler.php
      Added a plugin to display blogposts on the same date in previous years.

    2. For 2019’s Q1 I want to do a ‘weekly hack’. There are many small odd jobs around the house, on my computer, our network, or in my workflows. They often are in my todo lists, but never get done, simply because they never have any urgency attached to them and so the rest of my life goes first. Yet they often do hinder me, and keep nagging to be resolved. Either that or they are the small wished for fixes (I really should have a page for X / I really should make a template for Y).
      So 12 ‘hacks’, fixes or odd jobs in Q1 2019 it is. If it becomes a habit after that it will mean doing some 4 dozen small things to make life easier per year. That’s a lot of things done incrementally over time. A first braindump gave me some 20 things to choose from (and the one I ended up doing first wasn’t even on that original list, but came to me later ).

      19#01 Create and use a template for the first read through and note taking of a non-fiction book.I made it in Tinderbox, which is an outliner plus mapping tool by Mark Bernstein. The template is mostly based on this WikiHow page on reading non-fiction, with some added questions (e.g. concerning assumptions made by the author)(the template in map and in outline view). For each book I copy that template. Each element in the outline/map is also a note which can have text, images etc. Tinderbox then lets you export the whole thing as a document, in this case the summary of my reading notes of a book. Which can then be blogged or published in other ways. [Category: workflow, habits]

      19#02 Do an edit in Open Street Map. For a long time open data consultant and activist, I actually do very little with data. My focus is on helping government entities change, so that their data becomes available routinely and at high quality. So, while Open Street Map (OSM) is a re-users of large amounts of Dutch open government data I never actually edited something in it. Peter’s suggestion this week triggered me to change that. [Category: learning]

      19#03 Export notes from presentation deck. I regularly give presentations, and use the speaker notes to write out the story and to present. Writing up the presentation story afterwards I used to copy by hand the presenter notes to my text editor and then turn it into a blogpost. This is however time consuming (copy and pasting text from each slide). To make that easier I searched for an applescript online and adapted it to my use. Now copying the notes to the clipboard is just one click, and then it is stored in my ClipMenu tool to past into whatever editor or word processor I want to use it in. Available from github.

      19#04 Add an ‘on this day’ function. To show blogposts from earlier years on the current day. Added and fixed a plugin, that provides a shortcode.

      19#05 Automatically transform bank journal entries into procurement journal entries Made an Applescript that takes the bank journal entries from my double entry book keeping system as csv, and then for the entries that are marked as procurement, creates the correct entry for the procurement journal. Output is in CSV again, which I can directly import into my book keeping system. Script published on github

      19#06 I redid my changes to the Semantic Backlinks plugin to display webmentions differently on my site. After an update my earlier changes had been overwritten. So following my own earlier documentation, I fixed it again.

    Comments are closed.