Plugin system

I’ve been thinking about a way to start building a plugin system for WriteFreely. In this thread I want to open up a technical discussion, especially for anyone potentially interested in helping develop this.

Background

To keep our blogging platform simple (and not a CMS), the core product needs to stop growing (scope-wise) at some point. I’m all about modularization (if you couldn’t tell from all the planned products), so as WriteFreely grows and people ask for more features, I’d like to start putting some of them into small, optional plugins.

Goals

Ideally, we’d be able to support plugins that are:

  • Portable
  • Easy-to-install
  • Able to be loaded / installed without restarting the application

Maybe goals

Feasible? Unnecessary? I haven’t thought them through – I’m just dumping ideas:

  • Installable on user-by-user basis (for multi-user instances)
  • Can be built in any language (not just Go)

Implementation

Some options:

Let me know your thoughts, or if you’re interested in working on this.

3 Likes

I had a look at the two available implementations. Go plugins while native to Golang seems to only work with Linux builds while gRPC seems to work on multiple platforms. If you’re wanting to provide plugin support on more platforms than just linux then gRPC may be the path to go down.

Yeah, I think so too. The ability to potentially work with plugins written in any language via gRPC is also pretty appealing.

So at this point I think it’d help to come up with what some basic plugins would be, so we can figure out common patterns and what hooks we should build into the app. Some ideas:

  • Post signatures
    • Adds a new “Signature” editable section to blog’s Customize page
    • Saves any entered text to the db
    • Includes it as rendered Markdown on every blog post
  • Next / Previous Post links on blog posts
    • Adds a new “Navigation” section to blog’s Customize page, including a checkbox to enable next/previous links on all posts
    • Enabling it saves a boolean in the db
    • If enabled, blog post pages include a Next / Previous link in the footer
  • Social media icon links
    • Adds a new “Links” section to blog’s Customize page, including a list of boxes for entering a URL / social media handle and some preset icons
    • Saves each item to a new db table
    • Links render as icons on the blog’s home page, at the top
  • MathJax (move to a plugin)
    • Adds a new checkbox for MathJax under “Text Rendering” section on blog’s Customize page
    • Enabling it saves a boolean in the db
    • If enabled, MathJax javascript is included on all blog pages
  • Cross-post to Twitter / Tumblr / Medium / anything else.
    • Creates new db tables and generates new encryption keys for storing oauth information
    • Adds a new “Channels” section to user’s Blogs page, including links to connect accounts
    • Adds a new page with a list of all your published posts and whether or not they’ve been cross-posted, plus a button to cross-post to any connected channels
    • Connected accounts show up as publish options in the editor
5 Likes

Maybe I’m missing something but wouldn’t this actually require every plugin to compile and open a port to talk gRPC?

Don’t get me wrong the idea of gRPC is appealing. But if it meant having to run a mini web server for each… might as well just support sending webhooks on certain actions and let people write basic web servers which most would be able to do easier then gRPC.

Just a thought.

I guess it would require that, yeah. So that’s a good point, maybe it’s not the best solution.

After digging a bit more, it looks like Go plugins work on macOS, too. So maybe that’d be less of an issue / an okay trade-off – but I’m not sure what our Windows userbase looks like. I’m open to any input on that.

I would be surprised if anyone was deploying this in a Windows environment without it being within a VM or Docker.

Could be that you go down the route of 100% supporting plugins on Linux and within a Docker container on other platforms but not natively on those platforms?

1 Like

Hi Matt, any chance that there will be a possible Social Media icon thingy added soon? Or is there a way to diy with CSS? (still n00b re that, but willing to learn)

It could possibly get messy and complicated over time, but I’ve been messing around with the custom JavaScript section to make functions that launch when certain conditions are met. In a way they’re a bit like plugins. On mtkultra.com I wrote a block of code that generates a webcomic navigation div so long as the post is named the number of the page (i.e. 001, 002, 020, 756, etc.).

And on my personal blog, I wrote a couple of functions that look for an image inside of a specific div so it can overlay a set of numbers that are also links which can be referenced in the post itself. I used it to make a top 20 list for my personal greatest live albums of all-time. But I’m planning on doing a few more, and maybe even refining the code to be able to handle different row and column configurations.

Maybe there could be a way to utilize the custom JavaScript section so, even if the author isn’t a programmer, it’s easy enough to copy and paste code blocks that are formatted in a specific way. I haven’t tried combining the two blocks of code, but I don’t see why they wouldn’t work together just fine.

Obviously there are concerns once you start stuffing more than a few hundred lines of JavaScript code on to a page, surely there’s a point at which performance starts to suffer if a particular user has a bunch of “plugins” loaded, and there could be conflicts between code blocks written by different people… but maybe it’s a start?

Not sure how easy it is to set up multiple JavaScript code blocks that could be turned on or off and set in a particular order. I don’t really know anything about Golang. I don’t know where the /me/c/site-name page lives in the writefreely or writeas repos either.