add back register-page

This commit is contained in:
Dan Holmsand 2015-09-08 20:18:27 +02:00
parent d728820191
commit ee2644836d
8 changed files with 43 additions and 69 deletions

View File

@ -43,7 +43,7 @@
[:ul.nav
[:li.brand [link {:href (main-page)} "Reagent:"]]
[:li [link {:href (main-page)} "Intro"]]
[:li [link {:href (news/path)} "News"]]
[:li [link {:href news/url} "News"]]
[:li [:a github "GitHub"]]]]
@test-results
[tools/page-content]

View File

@ -4,8 +4,7 @@
[reagentdemo.news.undodemo :as undodemo]
[reagentdemo.news.clockpost :as clock]
[reagentdemo.news.news050 :as news050]
[sitetools.core :as tools :refer [dispatch link]]
[secretary.core :as secretary :refer-macros [defroute]]))
[sitetools.core :as tools]))
(defn main []
[:div
@ -15,6 +14,5 @@
[async/main {:summary true}]
[undodemo/main {:summary true}]])
(defroute path "/news/index.html" []
(dispatch [:set-content [#'main] "News"]))
(tools/reg-page (path))
(def url "/news/index.html")
(tools/register-page url [#'main] "News")

View File

@ -3,20 +3,13 @@
[reagent.interop :refer-macros [.' .!]]
[reagent.debug :refer-macros [dbg println]]
[reagentdemo.syntax :as s]
[sitetools.core :as tools :refer [dispatch link]]
[secretary.core :as secretary :refer-macros [defroute]]
[sitetools.core :as tools :refer [link]]
[reagentdemo.common :as common :refer [demo-component]]
[geometry.core :as geometry]))
;; (def url "news/any-arguments.html")
(def url "/news/any-arguments.html")
(def title "All arguments allowed")
(declare main)
(defroute path "/news/any-arguments.html" []
(dispatch [:set-content [#'main] title]))
(tools/reg-page (path))
(def ns-src (s/syntaxed "(ns example
(:require [reagent.core :as r]))"))
@ -44,7 +37,7 @@
(let [geometry {:href "https://github.com/reagent-project/reagent/tree/master/examples/geometry"}
jonase {:href "https://github.com/jonase"}]
[:div.reagent-demo
[:h1 [link {:href (path)} title]]
[:h1 [link {:href url} title]]
[:div.demo-text
[:h2 "If it looks like a function…"]
@ -61,7 +54,7 @@
them."]
(if summary
[link {:href (path) :class 'news-read-more} "Read more"]
[link {:href url :class 'news-read-more} "Read more"]
[:div.demo-text
[:p "In other words, you can now do this:"]
@ -140,5 +133,4 @@
[demo-component {:comp geometry-example}]])]]))
;; (tools/register-page url [main]
;; (str "Reagent 0.4.0: " title))
(tools/register-page url [#'main] title)

View File

@ -3,19 +3,12 @@
[reagent.interop :refer-macros [.' .!]]
[reagent.debug :refer-macros [dbg println]]
[reagentdemo.syntax :as s]
[sitetools.core :as tools :refer [dispatch link]]
[secretary.core :as secretary :refer-macros [defroute]]
[sitetools.core :as tools :refer [link]]
[reagentdemo.common :as common :refer [demo-component]]))
;; (def url "news/reagent-is-async.html")
(def url "/news/reagent-is-async.html")
(def title "Faster by waiting")
(declare main)
(defroute path "/news/reagent-is-async.html" []
(dispatch [:set-content [#'main] title]))
(tools/reg-page (path))
(def ns-src (s/syntaxed "(ns example
(:require [reagent.core :as r]))"))
@ -100,7 +93,7 @@
(defn main [{:keys [summary]}]
(let [om-article {:href "http://swannodette.github.io/2013/12/17/the-future-of-javascript-mvcs/"}]
[:div.reagent-demo
[:h1 [link {:href (path)} title]]
[:h1 [link {:href url} title]]
[:div.demo-text
[:h2 "Reagent gets async rendering"]
@ -114,7 +107,7 @@
changes are rendered in one single go."]
(if summary
[link {:href (path)
[link {:href url
:class 'news-read-more} "Read more"]
[:div.demo-text
@ -204,5 +197,4 @@
:ncolors-choose :color-plate
:palette :color-demo])]}]])]]))
;; (tools/register-page url [main]
;; (str "Reagent: " title))
(tools/register-page url [#'main] title)

View File

@ -3,20 +3,13 @@
[reagent.interop :refer-macros [.' .!]]
[reagent.debug :refer-macros [dbg]]
[reagentdemo.syntax :as s]
[sitetools.core :as tools :refer [dispatch link]]
[secretary.core :as secretary :refer-macros [defroute]]
[sitetools.core :as tools :refer [link]]
[reagentdemo.common :as common :refer [demo-component]]
[reagentdemo.news.binaryclock :as binaryclock]))
;; (def url "news/binary-clock.html")
(def url "/news/binary-clock.html")
(def title "A binary clock")
(declare main)
(defroute path "/news/binary-clock.html" []
(dispatch [:set-content [#'main] title]))
(tools/reg-page (path))
(defn fn-src [src]
[demo-component {:src src :no-heading true}])
@ -28,7 +21,7 @@
clocksrc {:href "https://github.com/reagent-project/reagent/blob/master/demo/reagentdemo/news/binaryclock.cljs"}]
[:div.reagent-demo
[:h1 [link {:href (path)} title]]
[:h1 [link {:href url} title]]
[:div.demo-text
(when-not summary
@ -45,7 +38,7 @@
[:p "So, without further ado, here is a binary clock using Reagent."]
(if summary
[link {:href (path) :class 'news-read-mode} "Read more"]
[link {:href url :class 'news-read-mode} "Read more"]
[:div.demo-text
[fn-src (s/syntaxed "(ns example
@ -129,5 +122,4 @@
description that corresponds to those arguments, and leave it
to React to actually display that UI."]])]]))
;; (tools/register-page url [main]
;; (str "Reagent: " title))
(tools/register-page url [#'main] title)

View File

@ -3,19 +3,12 @@
[reagent.interop :refer-macros [.' .!]]
[reagent.debug :refer-macros [dbg println]]
[reagentdemo.syntax :as s]
[sitetools.core :as tools :refer [dispatch link]]
[secretary.core :as secretary :refer-macros [defroute]]
[sitetools.core :as tools :refer [link]]
[reagentdemo.common :as common :refer [demo-component]]))
;; (def url "news/news050.html")
(def url "/news/news050.html")
(def title "News in 0.5.0")
(declare main)
(defroute path "/news/news050.html" []
(dispatch [:set-content [#'main] title]))
(tools/reg-page (path))
(def new-in-alpha [:strong "New since 0.5.0-alpha: "])
(def ns-src (s/syntaxed "(ns example
@ -110,16 +103,17 @@
(defn could-be-jsx []
(r/create-element react-comp #js{:name "world"}))
(defn main [{:keys [summary]}]
[:div.reagent-demo
[:h1 [link {:href (path)} title]]
[:h1 [link {:href url} title]]
[:div.demo-text
[:p "Reagent 0.5.0 has automatic importing of React.js, two kinds
of cursors, better integration of native React components, better
performance, easier integration with e.g Figwheel, and more."]
(if summary
[link {:href (path)
[link {:href url
:class 'news-read-more} "Read more"]
[:div.demo-text
[:h2 "A new way of importing React"]
@ -343,3 +337,5 @@
[:p new-in-alpha "All the examples in the Reagent repo now uses
figwheel."]])]])
(tools/register-page url [#'main] title)

View File

@ -3,20 +3,13 @@
[reagent.interop :refer-macros [.' .!]]
[reagent.debug :refer-macros [dbg println]]
[reagentdemo.syntax :as s]
[sitetools.core :as tools :refer [dispatch link]]
[secretary.core :as secretary :refer-macros [defroute]]
[sitetools.core :as tools :refer [link]]
[reagentdemo.common :as common :refer [demo-component]]
[todomvc.core :as todomvc]))
;; (def url "news/cloact-reagent-undo-demo.html")
(def url "/news/cloact-reagent-undo-demo.html")
(def title "Cloact becomes Reagent: Undo is trivial")
(declare main)
(defroute path "/news/cloact-reagent-undo-demo.html" []
(dispatch [:set-content [#'main] title]))
(tools/reg-page (path))
(def ns-src (s/syntaxed "(ns example
(:require [reagent.core :as r]))"))
@ -59,7 +52,7 @@
(defn main [{:keys [summary]}]
(let [head title]
[:div.reagent-demo
[:h1 [link {:href (path)} head]]
[:h1 [link {:href url} head]]
[:div.demo-text
[:h2 "(reset! cloact-name \"Reagent\")"]
@ -75,7 +68,7 @@
search-and-replace should suffice."]
(if summary
[link {:href (path)
[link {:href url
:class 'news-read-more} "Read more"]
[:div.demo-text
@ -96,4 +89,4 @@
[undo-demo-cleanup]])]]))
;; (tools/register-page url [main] title)
(tools/register-page url [#'main] title)

View File

@ -50,12 +50,15 @@
:set-content (let [title (if v2
(str (:title-prefix state) v2)
(str (:default-title state)))]
(assert (vector? v1))
(when r/is-client
(r/next-tick #(set! js/document.title title)))
(assoc state :main-content v1 :title title))
:set-page (do (secretary/dispatch! v1)
:set-page (do (assert (string? v1))
(secretary/dispatch! v1)
(assoc state :page-name v1))
:goto-page (do
(assert (string? v1))
(when r/is-client
(.setToken history v1 false)
(r/next-tick #(set! js/document.body.scrollTop 0)))
@ -68,8 +71,16 @@
nil)
(defn reg-page [url]
{:pre [(string? url)]
:post [(map? %)]}
(swap! config update-in [:pages] conj url))
(defn register-page [url comp title]
{:pre [(re-matches #"/.*[.]html" url)
(vector? comp)]}
(secretary/add-route! url #(dispatch [:set-content comp title]))
(reg-page url))
;;; History