Why did I reimplement Jekyll using NoFlo?
Why did I reimplement Jekyll using NoFlo?
Join the DZone community and get the full member experience.Join For Free
Learn how error monitoring with Sentry closes the gap between the product team and your customers. With Sentry, you can focus on what you do best: building and scaling software that makes your users’ lives better.
Jekyll is a delightful piece of software. It's a Ruby application that turns your Markdown and HTML files to a nicely constructed static website. Since the generated site is static, you can deploy and serve it from anywhere with no security or performance concerns. As a matter of fact, my site is built with Jekyll.
For websites that don't need to offer dynamic functionality, this is, in many, ways the culmination of Decoupled Content Management — you can write the post using whatever editor, use GitHub as the content repository and deploy the pages to any web server you want.
If you've been to our Kickstarter project, you probably know that I've reimplemented Jekyll using the NoFlo flow-based programming environment. If I'm so happy with Jekyll as it is, why would I do such a thing?
Before I get to the reasons, let me briefly introduce the project itself: NoFlo-Jekyll.
Just like any flow-based program, the NoFlo reimplementation of Jekyll is built out of a graph. Here is what the main graph of the application looks like when loaded via the NoFlo UI prototype:
In total, at the current version, the graphs contain 107 nodes--most of these running a component from the extensive NoFlo component libraries, but there are also four custom components built for this project. Put together, these components are fewer than 500 lines of code, and everything else is using 100 percent reusable code from existing libraries. Not bad compared to the size of the original Jekyll code base at over 16k LoC!
Where This is Coming From
When I started working with the rest of The Grid team last year, Jekyll development had practically stopped. It looked like nothing was happening in that community. Since Jekyll was something we very much wanted to utilize for various projects, the situation looked a little bit risky.
Since we're very much a NoFlo shop, it felt natural to take Jekyll as sort of a specification, and reimplement it using FBP techniques. Initially this was an internal effort but then we decided, very much in the nature of GitHub's "open source (nearly) everything" philosophy, that this should be opened as well.
I got NoFlo-Jekyll into a running state in about a week, and then moved my attention to other things we needed to build. And so the finishing touches and a public release were postponed for a better day.
As it happens, Jekyll development resumed pretty soon after that. But there are still many reasons why Noflo-Jekyll can be quite cool.
Benefits of the NoFlo Port
Here are some reasons why (especially Node.js) developers should care about this project:
- Other data sources: In NoFlo, everything is just a flow of data. You could easily plug in other data sources than the file system (for example, database query results).
- Different converters: Don't want to use Markdown? Just plug in your own mark-up processor component.
- Different template engines: Don't want to use Liquid? Just plug in your own template processor component.
- Use as a library or executable: This Jekyll implementation is just a NoFlo graph. You can use it in other NoFlo applications, as a Node.js module or as a command-line executable.
However, as with any reimplementation of an application being actively developed, there are also some potential caveats to observe.
A NoFlo Example
Most of the existing NoFlo applications out there deal with various business processes, so very little of that is available out in the open. As such, NoFlo-Jekyll can probably show how to build bigger systems out of flow-based graphs and also how to connect them with the rest of the Node.js ecosystem.
NoFlo-Jekyll is now available under the MIT license for your static site generation needs. But as it happens, it wasn't the only interesting NoFlo example to be released this week. You may want to also check out how to handle HTTP requests in NoFlo with the Woute module. There is even an example project available.
Keeping Up with Jekyll
To realize the benefits of flow-based static site generation, it is quite important to keep the NoFlo reimplementation up-to-speed with things changing in Jekyll-land.
Because of this, the most important part of our automated tests is comparing results between a site generated by the original Jekyll program and the NoFlo version. This means that when new features are added to Jekyll, we can follow the red-green-refactor style of test-driven development, and add these features to the test site.
I've been happily building my blog and the NoFlo site with this for a while, and except for some minor templating and Markdown handling differences between the Node.js and Ruby versions of those libraries, things are looking solid. If you find something that doesn't work with the site or templates you have, please let us know!
Published at DZone with permission of Henri Bergius , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.