Auto-install shortcodes?

I’m working on something that might use a Hugo shortcode, but it would be nice if I knew that it would work for everyone. It occurred to me that it could be helpful to automatically install plug-ins in some cases. This is what I’m thinking:

  • User writes a blog post that uses (for example) the {{< bookshelf >}} shortcode.
  • Micro.blog looks at its available plug-ins, finding one that contains the template layouts/shortcodes/bookshelf.
  • If the plug-in isn’t installed yet, install it right away and then continue publishing the blog.

Because missing shortcodes effectively break a blog, this would also make Micro.blog more resilient if posts were re-imported without setting up the required plug-ins first.

Potential downside: might get weird if there are multiple plug-ins that provides the same shortcode name. In that case, the user would need to manually install the plug-in they prefer.

Thoughts?

That’s a good idea. However, notifying the user that a plugin is available should be enough rather than installing the plugin.

I like the idea as well, but am afraid there might be some edge cases. For example, as a developer, I’m quite often in a state where my blog is broken temporarily because I uninstall a plug-in and suddenly is short a shortcode. :blush:

I think it could get quite frustrating if the plug-in reinstalled again immediately – maybe that’s not what I intended?

What @amit is proposing sound good to me. That’s how iOS work, for example when following an RSS feed link without having an RSS reader installed:

If you choose the automatic installation route, @manton, maybe there could at least be away to opt out in the settings?

Good points, thanks! I like the idea of notifying the user, but because there are so many places to post to Micro.blog, I don’t know if we could show a warning somewhere and have it be actually noticed. This is kind of a long running problem with theme errors, actually.

The nice thing about notifying the user, though, is that we could present a list of multiple plug-ins if there was more than 1 that provided the shortcode.

Maybe we start with automatic + preference and see how it goes.

I should explain more about why I was considering this: I’m working on a feature in Epilogue that could benefit from a shortcode. I don’t want to add shortcodes directly to Micro.blog. It’s more flexible and easier to maintain to always provide them with plug-ins. So if the user posts from Epilogue, it might be tricky to insert a prompt about plug-ins at that point. We’d need to extend the Micropub API to provide some mechanism for this.

Maybe the process of adding a plug in to the directory should include registering any short codes to avoid collisions.

My main worry is that I often don’t like someone else’s shortcode. So I don’t use the bookshelf plug-in but I do have a bookshelf short code just to make things tidy for myself.

1 Like

Does this new feature involve book covers? :grinning:

Here’s another idea I had… Apps could be responsible for letting users know that a plug-in is required and will be installed. See the message above the keyboard in this screenshot.