Micropublisher plugin: Micropub for Kirby

Back in January, I only found the time to release my IndieAuth plugin, which was actually just an enabler for my true mission – this week, I finally got around to share the much more exciting plugin it enables:

Kirby3-Micropublisher is a Micropub endpoint for Kirby, enabling the use of Micropub clients to create content on a Kirby site. The backstory and details, including some use cases for inspiration, are on my blog: https://sebastiangreger.net/2020/04/designing-micropub-for-kirby (code and docs on Github).

As an Indieweb-inspired tool, this is primarily considered for use on personal (or single-admin) websites …and, needless to say, it may have all kind of quirks and loose ends. (BTW, this is not the first exploration on using Micropub on Kirby.)

If anyone is brave enough to play around with it, I’d be most excited to hear from you - here, on the blog or on Github. :bowing_man:

/ping @bastianallgeier :wave: #indieweb


Thanks for sharing! Interesting solution with the post-type matcher, it seems quite powerful…

You are motivating me to clean up my own endpoint code and put it on github… As you wrote in the docs, it’s rather hard to write this as a plug-and-play ‘plugin’, because every site is different. While I find it a good idea to have a very configurable plugin, I think it would be cool to modularize the implementation as strongly as possible, to join forces among us interested in developing IndieWeb stuff for Kirby.

In the implementation I currently run, I tried to take some ideas towards this from the “Indieweb Toolkit for Kirby 2” by @seb , so people would not have to reinvent the wheel all the time.

For example, it has a Request class which basically can be used like the Kirby Request Object in your endpoint, only it already converts JSON and form input by the client into a handy data array, downloads attachments sent via URL, and makes everything available Kirby-style:

$request = new MicropubRequest();

if($request->is('POST')) {

  // Makes it easy to implement 'create', 'update' or 'delete' in 
  // your endpoint 
  switch($request->action()) {
    case 'create':

      // All the properties of the post, already sanitized
      $content = $request->body()->toArray();

      // Access the attachments, already downloaded and ready 
      // as Kirby\Http\Request\Files Object
      $files = $request->files();

      // Supports extensions like 'post-status' for drafts
      $status = $request->status();

    case 'update':

      // Url of the page to update available via url()
      $updatePage = kirby()->pages()->find($request->url());
// and so on…

With this, development of any kind of endpoint is rather straightforward.

Similarly, my Endpoint class is rather minimal and agnostic towards your site’s content structure, you pass it a ‘create’, ‘update’ etc callback function which returns the url of the created post, the endpoint takes care of the rest (handling queries, responses, media-endpoint, etc).

I see the benefit of an approach like this especially in maintenance and support of new Micropub features… Anyways, I hope I get to it soon and can share some code, and would be nice to hear what you think!

@mof This sounds like an interesting approach (the MicropubRequest object in particular), and one I’d be curious to find out more about. Looking forward to peeking into your solution at some point :slight_smile: …diversity of solutions is always good, but I too see the benefit of not reinventing the wheel over and over.