Skip to content

Instantly share code, notes, and snippets.

@danneu
Created December 10, 2013 18:51
Show Gist options
  • Save danneu/7895990 to your computer and use it in GitHub Desktop.
Save danneu/7895990 to your computer and use it in GitHub Desktop.
(defroutes chapter-routes
;; Example story-slug: 42-my-first-story
;; Example chapter-slug: 99-introduction
;; (util/parse-uid "42-my-first-story") -> 42
;; (util/parse-uid "99-introduction") -> 99
(GET "/chapters/:chapter-slug" [story-slug chapter-slug]
(when-let [story-uid (util/parse-uid story-slug)]
(when-let [chapter-uid (util/parse-uid chapter-slug)]
(when-let [story (db/find-story-by-uid story-uid)]
(when-let [chapter (db/find-chapter-by-uid chapter-uid)]
(-> (zizkov.views/show-chapter story chapter)
layout))))))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment