Simplify page handling in demo a little

This commit is contained in:
Dan Holmsand 2015-01-31 22:02:30 +01:00
parent 6d9bb35996
commit d57fbc8fd6
7 changed files with 17 additions and 20 deletions

View File

@ -22,11 +22,9 @@
(def index-page "index.html")
(def news-page "news/index.html")
(tools/register-page index-page
(fn [] [intro/main])
(tools/register-page index-page [#'intro/main]
"Reagent: Minimalistic React for ClojureScript")
(tools/register-page news-page
(fn [] [news/main])
(tools/register-page news-page [#'news/main]
"Reagent news")
(defn demo []
@ -43,6 +41,6 @@
(defn start! [{:keys [test-results]}]
(reset! test-results-comp test-results)
(tools/start! {:body (fn [] [demo])
(tools/start! {:body [#'demo]
:css-infiles ["site/public/css/examples.css"
"site/public/css/main.css"]}))

View File

@ -133,5 +133,5 @@
[demo-component {:comp geometry-example}]])]]))
(tools/register-page url (fn [] [main])
(tools/register-page url [main]
(str "Reagent 0.4.0: " title))

View File

@ -197,5 +197,5 @@
:ncolors-choose :color-plate
:palette :color-demo])]}]])]]))
(tools/register-page url (fn [] [main])
(tools/register-page url [main]
(str "Reagent: " title))

View File

@ -122,5 +122,5 @@
description that corresponds to those arguments, and leave it
to React to actually display that UI."]])]]))
(tools/register-page url (fn [] [main])
(tools/register-page url [main]
(str "Reagent: " title))

View File

@ -191,4 +191,4 @@
will cause the entire component tree to update (by-passing the
equality checks)."] ])]])
(tools/register-page url (fn [] [main]) title)
(tools/register-page url [#'main] title)

View File

@ -85,4 +85,4 @@
[undo-demo-cleanup]])]]))
(tools/register-page url (fn [] [main]) title)
(tools/register-page url [main] title)

View File

@ -17,10 +17,9 @@
;;; Configuration
(defonce config (atom {:page-map {"index.html"
(fn [] [:div "Empty"])}
(defonce config (atom {:page-map {"index.html" [:div "Empty"]}
:page-titles {}
:body (fn [] [:div (page-content)])
:body [page-content]
:site-dir "outsite/public"
:css-infiles ["site/public/css/main.css"]
:css-file "css/built.css"
@ -38,7 +37,8 @@
([pageurl comp title]
(assert (string? pageurl)
(str "expected string, not " pageurl))
(assert (fn? comp))
(assert (vector? comp)
(str "expected vector, not " (pr-str comp)))
(assert (or (nil? title)
(string? title)))
(swap! config update-in [:page-map] assoc pageurl comp)
@ -51,7 +51,7 @@
[props child]
(let [p (:href props)
f ((:page-map @config) p)]
(assert (ifn? f) (str "couldn't resolve ppage " p))
(assert (vector? f) (str "couldn't resolve page " p))
(assert (string? p))
[:a (assoc props
:href p
@ -66,9 +66,8 @@
child]))
(defn page-content []
[(get-in @config [:page-map @page]
(get-in @config [:page-map "index.html"]))])
(get-in @config [:page-map @page]
(get-in @config [:page-map "index.html"])))
@ -155,8 +154,8 @@
(defn body []
(let [b (:body @config)]
(assert (fn? b))
[b]))
(assert (vector? b) (str "body is not a vector: " b))
b))
(defn danger [t s]
[t {:dangerouslySetInnerHTML {:__html s}}])