jekyll-webmention_io icon indicating copy to clipboard operation
jekyll-webmention_io copied to clipboard

Add syndication URLs to page front matter

Open fancypantalons opened this issue 5 years ago • 6 comments

This might be a bit too specialized, but I figured I'd raise your attention to a feature I threw together.

The issue I had is that, on my blog, I am syndicating posts to Twitter using brid.gy. This works great! However, on my on site, I wanted to include a link to the resulting Twitter post. This data is present in the response object that comes back from Brid.gy.

So I threw together this commit: 475b24db739ecc759d2d0d8a29c15f342ac1f689

The approach, here, is pretty simplistic:

  1. The first jekyll build gathers the webmentions and caches them.
  2. jekyll webmention sends out the webmentions and records the responses.
  3. The second jekyll build then reads the responses and stores the URLs in the page data so the information can be included in the layout.

To avoid doing this work unnecessarily, step 3 only happens for URLs included in the syndication_endpoints list.

There are a couple downsides to this first basic implementation:

  1. It's basically built around how brid.gy responds.
  2. It hard codes the key in the page data where the syndication URLs are stored.

If necessary this could be made more flexible in a couple of ways:

  1. Provide some control over how the URL is pulled from the response (e.g. assume it's a JSON response and then provide a setting to control which field is pulled).
    1. Ideally configurable based on each syndication endpoint.
  2. Make the front matter key configurable.

If we did that, I'd probably rework the syndication configuration settings to group them up, but that's a whole other thing...

fancypantalons avatar Nov 24 '19 19:11 fancypantalons

Brid.gy returns a json object of the tweet. I at one time would save that response to _data so I could pull the url & any other info I wanted to use.

My approach was a homegrown solution using Travis & a rake task, but was effective.

miklb avatar Nov 26 '19 01:11 miklb

Yup, we could definitely just suck in the entire response payload and stick it in the page data so it's available in the layout. I was definitely a bit more surgical in my first implementation.

The most flexible option would actually be to support making this configurable. i.e., something like:

syndication:
  endpoints:
    bridgy:
      url: https://brid.gy/publish/twitter
      front_matter:
        syndication: :url

In this design, the specific "syndication" key in the page front matter is populated with the value of the "url" key from the response payload.

The nice thing about this approach is it's adaptable to different syndication endpoints and isn't dependent on any given response layout (other than it being JSON with key-value pairs).

fancypantalons avatar Nov 26 '19 16:11 fancypantalons

Are you looking at syndication being a top-level config setting (not nested in the plugin's namespace)? If you are, which is fine, it may make more sense to break it out into its own plugin so as not to confuse folks implementing it.

If you do decide to bundle it under this plugin's config, do we need two levels of depth? Could it simply be something like

webmentions:
  syndicate_to:
    twitter:
      url: https://brid.gy/publish/twitter
      front_matter:
        syndication: :url

Also, it seems possible (or probably) that folks may only want to syndicate certain collections to specific endpoints. That config might require tapping into the collections config along the lines of

collections:
  microblog:
    output: true
    permalink: /microblog/:title/
    syndicate_to: twitter

The key used in the global syndication setting would need to match the key used in the collection config. Alternately, if we wanted it entirely front-matter driven (and mutable), it could be part of the defaults config.

Thoughts?

aarongustafson avatar Nov 26 '19 18:11 aarongustafson

Oh, no, to be clear, if I were to restructure the configuration layout for syndication, I would definitely want that "syndication" sub-tree to be nested under the "webmentions" root node. I just elided that so I could type less. ;)

Interesting point about collection-specific syndication! I love that idea! It could allow you to completely automate certain types of syndication without requiring page front matter at all.

Which... actually makes me think I should go modify my blog so notes are pulled into a collection (right now they're just another type of post). But that's a whole other thing...

fancypantalons avatar Nov 26 '19 19:11 fancypantalons

Alright, I've moved the syndication into a branch and implemented the first phase of the proposed change here:

https://github.com/fancypantalons/jekyll-webmention_io/commits/syndication

Obviously I can squash this before I generate a pull request, presuming that you're happy with how this looks!

This commit changes the syndication configuration layout as follows:

webmentions:
  syndication:
    twitter:
      endpoint: https://brid.gy/publish/twitter
      response_mapping:
        url: syndication

This does not yet include the proposed collection handling logic. I'll take a look at that next!

fancypantalons avatar Nov 28 '19 18:11 fancypantalons

I kept having Ruby/Jekyll issues when upgrading my Mac, so I have moved off of Jekyll and will not be working on this project anymore, going forward. I am going to flag this as won’t fix, but leave it open in case someone else wants to pick up the project from here.

aarongustafson avatar Jul 22 '21 21:07 aarongustafson

This has been merged into the main branch and will be included in the forthcoming 3.4.0 release!

fancypantalons avatar Feb 20 '23 21:02 fancypantalons