Navigation Menu

Skip to content

Commit

Permalink
got enlive working in appengine (local)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sridhar Ratnakumar committed Sep 12, 2011
1 parent e8a3ec0 commit 6c79b71
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 25 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/notaskinnerbox/routes.clj
Expand Up @@ -11,7 +11,7 @@


(defroutes app-handler
(GET "/" [] "hello")
(GET "/" [] (view-digest "stackoverflow.com" "" 7))
(route/resources "/")
(route/not-found "Page not found"))

Expand Down
47 changes: 23 additions & 24 deletions src/notaskinnerbox/views.clj
Expand Up @@ -19,27 +19,26 @@
(if (not (= tag "")) (str " [" tag "] "))
(if (> n 0) (str " (" n " days)"))))

(comment
(html/deftemplate layout "notaskinnerbox/views/layout.html" [{:keys [title]} content]
[:.page-title] (html/content title)
[:#content] (html/content content))

(html/defsnippet digest "notaskinnerbox/views/digest.html" [:body :> html/any-node]
[site posts]
[:article] (html/clone-for
[{:keys [title score question_id creation_date] :as item} posts]
[:span.title] (html/content
{:tag :a, :attrs {:href (item-url item site)},
:content [title]})
[:span.meta :span.score] (html/content (str score))
[:span.meta :time] (html/content (format-date creation_date))))

(defn view-digest
[site tag n]
(let [title (page-title site tag n)
posts (sx/top-posts site tag n)]
(fn [r]
(->> (digest site posts)
(layout {:title title})
response))))
)
(html/deftemplate layout "views/layout.html" [{:keys [title]} content]
[:.page-title] (html/content title)
[:#content] (html/content content))

(html/defsnippet digest "views/digest.html" [:body :> html/any-node]
[site posts]
[:article] (html/clone-for
[{:keys [title score question_id creation_date] :as item} posts]
[:span.title] (html/content
{:tag :a, :attrs {:href (item-url item site)},
:content [title]})
[:span.meta :span.score] (html/content (str score))
[:span.meta :time] (html/content (format-date creation_date))))

(defn view-digest
[site tag n]
(let [title (page-title site tag n)
posts (sx/top-posts site tag n)]
(fn [r]
(->> (digest site posts)
(layout {:title title})
response))))

0 comments on commit 6c79b71

Please sign in to comment.