Plugin system

new-features
writefreely
writeas

#1

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.


Post signatures
#2

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.


#3

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

#4

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.


#5

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.


#6

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?