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)
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:
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.
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?
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.