Created
March 8, 2012 06:23
-
-
Save rathwell/1999154 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns foo.views.image | |
(:use [noir.core :only (defpartial defpage)]) | |
(:require [hiccup.core :as hc] | |
[foo.views.imagemodel :as im]) | |
(:import [foo.views.imagemodel ImageRecord])) | |
(defpartial image-item [{:keys [alt src width height]}] | |
[:img {:src src :width width :height height}]) | |
(defpartial image-list [images] | |
[:div#gallery | |
(map image-item images)]) | |
(defn test-foo [] | |
(let [a (ImageRecord. "a" "b" "c" "d" "e") ;; this works in browser | |
b (read-string "#foo.views.imagemodel.ImageRecord{}")] ;; this breaks in browser | |
(str "foo[a]=>" a " foo[b]=>" b))) | |
(defpage "/photo/:area" {:keys [area]} | |
(hc/html | |
(list | |
[:h1 "Test!"] | |
(image-list (im/find-all))))) ;; this breaks in browser | |
(defpage "/photo" [] | |
(test-foo)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns foo.views.imagemodel) | |
(defrecord ImageRecord [area src width height caption]) | |
(defn new-image [data] | |
(map->ImageRecord data)) | |
(defn find-all [] | |
(vec | |
(map read-string | |
["#foo.views.imagemodel.ImageRecord{:area \"test\", :src \"/img/photos/test1_640.jpg\", :width 640, :height 427, :caption \"Test Caption #1\"}" | |
"#foo.views.imagemodel.ImageRecord{:area \"test\", :src \"/img/photos/test2_640.jpg\", :width 640, :height 427, :caption \"Test Caption #2\"}" | |
"#foo.views.imagemodel.ImageRecord{:area \"test\", :src \"/img/photos/test3_640.jpg\", :width 640, :height 427, :caption \"Test Caption #3\"}"]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment