From Noir to Compojure
30 Apr 2012When I first got started with Clojure development I recognized that my blog (which I had handcoded using HTML frames in High School) was to be polite deserving of Geosites with all the baggage that implies. As I started looking for a Lisp on the JVM and found Clojure I also ran across Chris Granger’s site webnoir, which is a giant (and good looking) plug for the Noir framework which Chris built to make web devel in Clojure a little easier.
Well life was good, Noir looked alive so I built the 2nd edition of my
blog (and the first one to carry the name arrdem) atop Noir. Then
this happened. Raynes also had a good writeup
here
in the technical reasons for why Noir needed to die but the TL;DR for
me is that less than three months after “finishing” it, I found myself
needing to rebuild the entire thing again. These are my notes on
transitioning my (noir.core/defpage)
based site to a
(Clojure.core/defn)
and (compojure.core/defroutes)
based
equivalent structure I hope while retaining the same URL semantics.
noir.core/defpage
Defpage did some interesting stuff.. but most importantly for this
discussion it accumulated a huge atom representing all the pages and
routings in the site from which it then built an actual Compojure
routing structure which was used in the server. This make defining
pages nice, because you just kicked out a (defpage "/foo/bar"
[params].. )
.