Browse files

Adding boilerplate for /:isbn url

  • Loading branch information...
1 parent 59711f0 commit 27aed25d80b48d8fc8a2ecce44a2e3779ec1303f @swaroopch committed Jul 27, 2013
Showing with 29 additions and 5 deletions.
  1. +14 −0 resources/book.mustache
  2. +7 −5 src/isbnnetinclj2/handler.clj
  3. +8 −0 src/isbnnetinclj2/store.clj
View
14 resources/book.mustache
@@ -0,0 +1,14 @@
+{{>header}}
+
+<div class="container-fluid">
+ <div class="row-fluid">
+ <div class="span8 offset2">
+ <dl>
+ <dt>ISBN</dt>
+ <dd>{{isbn}}</dd>
+ </dl>
+ </div>
+ </div>
+</div>
+
+{{>footer}}
View
12 src/isbnnetinclj2/handler.clj
@@ -3,19 +3,21 @@
[compojure.handler :as handler]
[compojure.route :as route]
[stencil.core :as mus]
- [ring.adapter.jetty :as jetty]))
+ [ring.adapter.jetty :as jetty]
+ [isbnnetinclj2.store :as store]))
-(defn front-page-content
+(defn front-page
[]
(mus/render-file "frontpage" {:title "isbn.net.in"}))
-(defn about-page-content
+(defn about-page
[]
(mus/render-file "about" {:title "About isbn.net.in"}))
(defroutes app-routes
- (GET "/" [] (front-page-content))
- (GET "/about/" [] (about-page-content))
+ (GET "/" [] (front-page))
+ (GET "/about/" [] (about-page))
+ (GET ["/:isbn" :isbn #"[\d-]+[xX]?"] [isbn] (store/book-page isbn))
(route/resources "/")
(route/not-found "Not Found"))
View
8 src/isbnnetinclj2/store.clj
@@ -0,0 +1,8 @@
+(ns isbnnetinclj2.store
+ (:require [stencil.core :as mus]))
+
+(defn book-page
+ [isbn]
+ (mus/render-file "book"
+ {:isbn isbn
+ :title isbn}))

0 comments on commit 27aed25

Please sign in to comment.