This episode is for subscribers only. Sign Up or Log in to watch it.

3. Introduction to Luminus, part 2

Published 19 May 16

We continue our journey through Luminus by building a wiki. In this episode you’ll learn how to create the form to edit pages, and handle creating new page revisions. We’ll also come across Cross Site Request Forgery, and learn how to prevent it.

Show notes

In the previous episode we created a new Luminus application, set up a PostgreSQL database, wrote queries to insert and retrieve pages, and added a route and template to tie it all together. In this episode we’ll finish our wiki, and with that conclude our grand tour of Luminus.

If you didn’t follow along you can grab the code from GitHub instead. Start from the part-1 branch, and follow the instructions in the README to set up your database.

I’m just going to start from where we left off. In Emacs, I’ll open a Clojure file within the project so I can jack in CIDER and get a REPL.

Let’s have another look of what we have so far. Start the app and open it in a browser (http://localhost:3000/).

;; Start a connected REPL. For Emacs/CIDER: M-x cider-jack-in
user> (start)

We got redirected to /home, but we can’t yet edit the page. We created this page last time from the REPL, but we can’t expect our users to do the same!

We’ll need two new routes, which we’ll add to home.clj. One that shows the form to edit a page, and one that handles the form submission. We haven’t used the POST function before, so don’t forget to refer to it in the namespace declaration.

Code

The code for this episode can be found on Github under lambdaisland/lambwiki.

Wikis

Wiki has become synonymous with Wikipedia, but the first Wiki was actually about patterns in software development. Wikimedia has a great video interview with the inventor of the wiki, Ward Cunningham.

Some example pages on Ward’s wiki

CSRF