Skip to main content

Ralsina.Me — Roberto Alsina's website

Nikola is Pluginificated.

Yes, I know that's not a re­al word.

So, the git mas­ter of Niko­la now has plug­ins. In fac­t, not on­ly does it have plu­g­in­s, but is ba­si­cal­ly made of plug­ins.

You see, the code used to most­ly be in­side a class (called Niko­la), and ... it had grown. That class had grown up to around 2000 lines of code. Which is com­plete­ly ridicu­lous.

So, us­ing Yap­sy I turned the code in­side out: al­most all the code that was in that mon­ster class was moved in­to plug­ins and the class turned in­to a smart plug­in load­er.

This has brought sev­er­al ad­van­tages:

  • Now you can ex­­tend Niko­la for your own pur­­pos­es. Just cre­ate a plug­in fold­er in your site, and put the ex­­tra func­­tion­al­i­­ty there.

  • Sup­­port for whole cat­e­­gories of things is now mod­­u­lar. Want to sup­­port a dif­fer­­ent markup? A dif­fer­­ent tem­­plate sys­tem? Just write a plug­in.

  • Want to add com­­plete­­ly new func­­tions to Niko­la? Like, say, a way to im­­port da­­ta from an­oth­er blog tool, or some­thing like plan­et soft­­ware? Well, just add a "com­­mand plug­in".

What has changed for the user?

  • You can delete do­do.py from your site.

  • Use niko­la build in­stead of doit

  • Use niko­la serve in­stead of doit serve

Some mi­nor things still need do­ing in this area (no­table, fix­ing the doc­s), but the main refac­tor­ing is there.

Fede Heinz / 2012-09-14 22:14:

Nikola does sound good...

The only thing I don't really like about it is doing comments with Disqus: what if the company ever goes belly-up (it happens), or suddenly decides that it wants more money to keep your comments than you are willing to pay for the service?

Comments are am important part of a blog's content, the prospect of losing them without recourse is kinda troubling, isn't it?

Roberto Alsina / 2012-09-14 23:15:

There is nothing intrinsically bound to disqus, it's just what I use so it got into the templates by default.

If you want to support alternative services (including self-hosted and/or community services) it's easy to add. Having said that, disuqs has a very clean exit strategy for your data, so if they go evil and/or dead, it's just the effort moving out, compared to the effort of setting up something else now and maintaining it forever.

Petri Savolainen / 2012-09-20 12:46:

Why not just refactor it into classes and/or functions etc. in additional modules? And why Yapsy instead of entry points? Just curious..

Roberto Alsina / 2012-09-20 12:51:

I used the tool I had in my toolbox: I used Yapsy because I know how to use it already, unlike entry points :-)

It is refactored into classes, the point of the plugin system is how to locate and load those classes. For example, this allows easy
extensibility, because the user only needs to drop extra or replacement plugins in a folder inside his project.


Contents © 2000-2023 Roberto Alsina