I started a project some time ago, where I develop a template for a wiki which
is statically compiled into a html page. As the template is more mature now, I
want to introduce you wiki.template and explain why I wrote it.
Once upon a time...
If you read this blog you know that I'm a member of the
NixOS community. The NixOS community has, of course,
a wiki. And the quality of this wiki is
bad. No really, it is just one large page (the landing page) linking to
sub-pages which are more or less maintained and contain only snippets of
information. Sure – there's a lot of content in there, but (especially
beginners) one has to search for it. You can't simply find it.
That's why I wanted to have a new wiki for the NixOS community. And because I
like git, I wanted the content to be stored in a git repository.
So I came up with the idea to recreate the NixOS wiki and start it from
scratch. Of course, the content of the original wiki has to be migrated to the
new wiki then, but this has to be done carefully and by hand to ensure that
things are ordered and easy to find afterwards.
The requirements
The requirements where rather simple, but nevertheless important to me. As
already said, I wanted to have the content version controlled with git. The
templates and markups for other data should be version controlled as well, if
possible. This way, the content (or whole wiki) can be distributed with git,
hosted on github or similar hosting platforms and so on.
I wanted to be able to customize the style of the wiki completely and I wanted
to be able to write snippets of markup which can be reused, such as a
warning-alert template where you can pass custom text and get a red alert box
in your wiki page. Pretty normal stuff for a wiki.
Syntax highlighting, TOC-generating, all these things should be integrated or
available through plugins (or there should be the possibility to write such
plugins).
So I searched for wiki software with git backends...
The state of git-backend-driven wiki software
The state of wiki software with git backend is bad. No, it is even worse.
There are actually two projects I had a look at and one which is written in
Perl (and I didn't have a look on this one, because Perl).
gitit
First of all, there is gitit. Gitit is a
wonderful piece of Haskell software. It works great and is fast. But it has
its issues:
- No Templates. Period.
- Content is checked in, but neither templates nor style information
- Haskell. So writing plugins – nah, not really.
- Just few plugins available
So it was pretty clear that gitit is not an option for me.
gollum
Gollum was the other alternative. Developed by github, ruby thing, sounds
well, right?
But. There's a big but.
- No templates
- No plugins
- No custom styling or at least no documentation about it
It was clear to me: No option!
The solution
Well, the solution? Just write it yourself! And that's what I did. I started
to work on a template for a wiki which is statically compiled with nanoc.
Later I switched to jekyll.
Compiling the wiki to a static site has several advantages. First of all,
hosting the site is cheap. A common web server can host thousands of pages
without even noticing. Of course, you are also protected against hacking and
all this stuff, as you do not have the problems dynamic websites have.
But these are common advantages of static compiled sites. An even bigger
advantage is, that contributions to the wiki must pass a review-process of
some kind. Of course, I will not grant push access to the repository to anyone
and of course nobody gets access to merge pull requests, besides myself. I
will protect myself against pushes to master as well, so each change to the
wiki has to be reviewed. And that's what matters when it comes to quality:
Changes must be reviewed.
Besides this big advantage, I do not have to care about updates (of the
compilersoftware). I can do them locally and roll back if they fail. I do not
have to keep track of spam bots, security updates, user account data, etc.
etc. etc.
So here's the story how I wrote the template:
wiki.template
I started the project with nanoc, the static site compiler
I love. The project is at version 4 these days and the compiler is really
really good. It is flexible, scales well, fast and a joy to work with.
I just failed integrating
foundation, the CSS framework I wanted to use.
I played around with Jekyll a bit, but wasn't able to get
Haml working. But at some point,
foundation seemd to be more important than Haml, so I switched to Jekyll.
I also thought of the option to build the site with Jekyll directly from the
github repository and build a github page with it, just because this way I can
save money for hosting. I still think of that option, but as I use Jekyll with
plugins I cannot build it on github directly. So I searched for tutorials on
how to build it with travis and deploy my github page from travis. This is
documented and a known as working.
Current state of wiki.template
To get my stuff working, I had to use some plugins. And these plugins
basically work for me, but the code was either a mess or lacked features I
wanted to have. So what did I do? Right, I forked them and send pull requests
to the maintainers.
At this very point in time, I have three pending pull requests to these
plugins, two of them just normal “cleanup codebase” PRs, one feature. I also
opened issues for other features I do not necessarily need but would like to
see implemented. I would implement them myself, but well... not enough time.
So what is the current state? Well, wiki.template is basically usable. I
want to integrate some more features and it completely lacks of documentation
on how to use it.
But these things will be done soon and I hope I can then create a fork of it
to start my NixOS Wiki.
The NixOS Wiki
I already announced the NixOS Wiki fork (semi) officially on the NixOS
mailinglist. Of course, as always in such communities, a discussion started on
whether to do such a thing or not, which software to use and whatever. I don't
care about this, I will simply do this and we will see whether it succeeds or
not. Discussion all over the place helps nobody.
tags: #git #linux #nix #nixos #open source #programming #software #wiki