hn-clojure icon indicating copy to clipboard operation
hn-clojure copied to clipboard

Hacker News in Clojure.

hn

Hacker News in Clojure

This is an implementation of the website Hacker News. It uses the official Hacker News API.

Features

  • Look at front page stories
  • View nested comments for each story
  • See a user's submitted stories
  • That's about it.

How is it done?

The Hacker News API is pretty simple, and it only takes about 50 lines to comprehensively access it.

HTML is generated via the Hiccup library, which translates Clojure data structures into HTML. If Hiccup sounds interesting to you, you might be interested in making it yourself. It's a fun problem.

I match routes to route handlers using Compojure. I thought Compojure was pretty cool, so I made that, too.

Finally, Ring ties everything togther with a very simple HTTP interface.

What's left?

At the moment, everything is done in Clojure. I plan to add some Clojurescript for collapsing comments, etc.

The website is a little slow because I am waiting for every item to come back before rendering the page. This can be faster by rendering items on the front end as they come in via Reagent.

Running it Yourself

  1. First, make sure that you have Java installed.

  2. Then, install Leiningen:

$ brew install leiningen
  1. Finally, start up the server:
$ cd hackernews
$ lein run

The website will be up on localhost:3000.