Third Post; New Blog Engine
I got quickly annoyed by Wordpress' interface, and by the engine itself, and by those ugly themes, and … OK, let's stop bad-mouthing other people …
‘On n'est jamais mieux servi que par soi-même …’
I added a Blog module to Dibrawi's helper interface for Camlmix. Let's say Dibrawi is a Wiki engine under heavy development, based on the Bracetax syntax, bibliography management with Sebib, and other stuff (e.g. an address book). It has a wiki default running mode, which only converts the wiki pages, the bibliography, and the address book to HTML. The wiki mode is fast and seems secure(or at least it is more secure than any other wiki engine I know …). On the other hand, each page can be preprocessed separately (locally, on command line) while activating OCaml code (Camlmix). This code will be compiled and run to generate whatever the user wants (like a web site, or a PDF). In wiki mode, the OCaml code is just displayed as code or ignored.
Henceforth, this new blog engine is a nice occasion to start showing some of the ideas behind Dibrawi. With some OCaml code one can quickly and easily generate a static blog (which uses Disqus as comment system). The bunch of HTML files together with the RSS feeds can be uploaded to any hosting facility (like GitHub ;)).
The idea is to play with the Blog module's functions (and the rest of the dibrawi library) to generate a full blog. Here is a full example:
- The file Blog.brtx: We see the tags {mix:code}, {mix:ignore} and {mix:end} which are the main escape commands to put OCaml code within Dibrawi (replacing the “##” family in Camlmix).
- The wiki mode version displays the OCaml code which used {mix:code}.
- The blog (HTML and RSS files) is generated by the code at the end of the source.
Once the framework is set up, each new blog post is just some text enclosed between blog#new_post and blog#end_post calls, e.g.:
{mix:code} blog#new_post ~title:"Anyweb, Document Source Code The Way You Like" ~date:"Tue, 19 Apr 2011 21:26:42 +0200" ~tags:[ "hack_of_the_day"; "anyweb"; "coq"; "ocaml" ] "anyweb-document-source-code-the-way-you-like" {mix:end} I was playing with Adam Chlipala's {q|{link http://adam.chlipala.net/cpdt/ |CPDT}} book and I wanted to take notes on some notations. I also wanted to do it in a # Quite a lot of text ... {mix:code} blog#end_post {mix:end}
Each time, generating the blog is as simple as calling dbw with the run command:
dbw run path/to/Blog.brtxand that's all for today folks!