Last active
November 9, 2017 19:14
-
-
Save WorldsEndless/43c8efc6d4db1ff684d9260fe22ddfc7 to your computer and use it in GitHub Desktop.
Routing, trying to move to Accountant from default Luminus
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 isp.routes | |
(:require [reagent.core :as r] | |
[reagent.session :as session] | |
[secretary.core :as secretary :include-macros true] | |
[accountant.core :as accountant] | |
[goog.events :as events] | |
[goog.history.EventType :as HistoryEventType]) | |
(:import goog.History)) | |
;; ------------------------- | |
;; Routes | |
(secretary/set-config! :prefix "#") | |
(secretary/defroute "/" [] | |
(session/put! :page :home)) | |
(secretary/defroute applicant-route "/applicant" [] | |
(session/put! :page :app)) | |
(secretary/defroute reviews-dashboard-route "/reviews" [] | |
(session/put! :page :reviews-dashboard)) | |
(secretary/defroute review-route "/review/:application" [application] | |
(session/put! :application application) | |
(session/put! :page :review)) | |
(secretary/defroute about-route "/about" [] | |
(session/put! :page :about)) | |
(secretary/defroute register-route "/register" [] | |
(session/put! :page :register)) | |
(secretary/defroute contact-route "/contact" [] | |
(session/put! :page :contact)) | |
;; ------------------------- | |
;; History | |
;; must be called after routes have been defined | |
(accountant/configure-navigation! {:nav-handler (fn [path] (secretary/dispatch! path)) | |
:path-exists? (fn [path] (secretary/locate-route path))}) | |
;; (defn hook-browser-navigation! [] | |
;; (doto (History.) | |
;; (events/listen | |
;; HistoryEventType/NAVIGATE | |
;; (fn [event] | |
;; (secretary/dispatch! (.-token event)))) | |
;; (.setEnabled true))) | |
;; Default routing function that comes with Luminus (in a different namespace in my file) | |
;; (def pages | |
;; {:home #'home-page | |
;; :about #'about-page | |
;; :contact #'contact-page | |
;; :app #'app/app-page | |
;; :review #'review/review-page | |
;; :reviews-dashboard #'reviews/reviews-dashboard | |
;; }) | |
;; (defn page [] | |
;; [(pages (session/get :page))]) | |
;; ;; ------------------------- | |
;; ;; Initialize app | |
;; (defn mount-components [] | |
;; (r/render [#'nav/navbar] (.getElementById js/document "navbar")) | |
;; (r/render [#'page] (.getElementById js/document "app")) | |
;; (r/render [#'shared/footer] (.getElementById js/document "footer"))) | |
;; (defn init! [] | |
;; (load-interceptors!) | |
;; (routes/hook-browser-navigation!) | |
;; (mount-components)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment