Skip to content

Commit

Permalink
bump deps, remove cljs-time deps, reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
jacekschae committed Mar 4, 2020
1 parent 9132c34 commit 29d7520
Show file tree
Hide file tree
Showing 15 changed files with 1,545 additions and 951 deletions.
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/ClojureProjectResolveSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/conduit.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

566 changes: 566 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/watcherTasks.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ authentication, routing, pagination, and more.
For more information on how this works with other frontends/backends, head over to the
[RealWorld](https://github.com/gothinkster/realworld) repo.

> ### Application structure/style heavily inspired by [todomvc](https://github.com/Day8/re-frame/tree/master/examples/todomvc)
> #### Application structure/style heavily inspired by [todomvc](https://github.com/Day8/re-frame/tree/master/examples/todomvc)
## Learn how to build similar project with High Quality Video Tutorial [Learn re-frame](https://www.learnreframe.com/)


## Setup And Run

Expand Down
10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@
"clean-win": "rmdir /s /q public/js & rmdir /s /q target"
},
"dependencies": {
"create-react-class": "^15.6.3",
"react": "^16.5.2",
"react-dom": "^16.5.2"
"react": "16.9.0",
"react-dom": "16.9.0"
},
"devDependencies": {
"react-flip-move": "^3.0.2",
"react-highlight.js": "^1.0.7",
"highlight.js": "9.12.0",
"shadow-cljs": "^2.8.31"
"shadow-cljs": "^2.8.90"
}
}
18 changes: 6 additions & 12 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
{:source-paths ["src"]

:dependencies [[proto-repl "0.3.1"]
[reagent "0.8.1"]
[re-frame "0.10.6"]
[day8.re-frame/http-fx "0.1.6"]
[day8.re-frame/re-frame-10x "0.4.0"]
[day8.re-frame/tracing "0.5.1"]
:dependencies [[reagent "0.9.1"]
[re-frame "0.10.7"]
[day8.re-frame/http-fx "v0.2.0"]
[cljs-ajax "0.7.3"]
[com.andrewmcveigh/cljs-time "0.5.2"]
[bidi "2.1.5"]
[kibu/pushy "0.3.8"]
[binaryage/devtools "0.9.10"]]
Expand All @@ -20,9 +16,7 @@

:modules {:main {:init-fn conduit.core/init}}

:dev {:compiler-options {:closure-defines {re-frame.trace/trace-enabled? true
day8.re-frame.tracing/trace-enabled? true}}}

:compiler-options {:shadow-keywords true}

:devtools {:http-root "public"
:http-port 3000
:preloads [day8.re-frame-10x.preload]}}}}
:http-port 3000}}}}
820 changes: 409 additions & 411 deletions src/conduit/events.cljs

Large diffs are not rendered by default.

38 changes: 15 additions & 23 deletions src/conduit/router.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,24 @@
;; forward. For that we'll use pushy/pushy to which we need to provide dispatch
;; function: what happens on dispatch and match: what routes should we match
(def history
(let [dispatch #(dispatch
[:set-active-page {:page (:handler %)
:slug (get-in % [:route-params :slug])
:profile (get-in % [:route-params :user-id])
:favorited (get-in % [:route-params :user-id])}])
(let [dispatch #(dispatch [:set-active-page {:page (:handler %)
:slug (get-in % [:route-params :slug])
:profile (get-in % [:route-params :user-id])
:favorited (get-in % [:route-params :user-id])}])
match #(bidi/match-route routes %)]
(pushy/pushy dispatch match)))

;; -- parse-url ---------------------------------------------------------------
;; By using bidi/match-route we convert URL into a data structure and check if
;; a route exists in our routes.
(defn- parse-url
[url]
(bidi/match-route routes url))
(pushy/pushy dispatch match)))

;; -- Router Start ------------------------------------------------------------
;;
(defn start!
[]
;; pushy is here to take care of nice looking urls. Normally we would have to
;; deal with #. By using pushy we can have '/about' instead of '/#/about'.
;; pushy takes three arguments:
;; dispatch-fn - which dispatches when a match is found
;; match-fn - which checks if a route exist
;; identity-fn (optional) - extract the route from value returned by match-fn
(pushy/start! history))
[]
;; pushy is here to take care of nice looking urls. Normally we would have to
;; deal with #. By using pushy we can have '/about' instead of '/#/about'.
;; pushy takes three arguments:
;; dispatch-fn - which dispatches when a match is found
;; match-fn - which checks if a route exist
;; identity-fn (optional) - extract the route from value returned by match-fn
(pushy/start! history))

;; -- url-for -----------------------------------------------------------------
;; To dispatch routes in our UI (view) we will use url-for and then pass a
Expand All @@ -63,5 +55,5 @@
;; To change route after some actions we will need to set url and for that we
;; will use set-token! that needs history and the token
(defn set-token!
[token]
(pushy/set-token! history token))
[token]
(pushy/set-token! history token))
84 changes: 42 additions & 42 deletions src/conduit/subs.cljs
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
(ns conduit.subs
(:require [re-frame.core :refer [reg-sub subscribe]]))

(defn reverse-cmp ;; https://clojure.org/guides/comparators
[a b]
"Sort numbers in decreasing order, i.e.: calls compare with the arguments in the opposite order"
(compare b a))
(defn reverse-cmp ;; https://clojure.org/guides/comparators
[a b]
"Sort numbers in decreasing order, i.e.: calls compare with the arguments in the opposite order"
(compare b a))

(reg-sub
:active-page ;; usage: (subscribe [:active-page])
(fn [db _] ;; db is the (map) value stored in the app-db atom
(:active-page db))) ;; extract a value from the application state
:active-page ;; usage: (subscribe [:active-page])
(fn [db _] ;; db is the (map) value stored in the app-db atom
(:active-page db))) ;; extract a value from the application state

(reg-sub
:articles ;; usage: (subscribe [:articles])
(fn [db _] ;; db is the (map) value stored in the app-db atom
(->> (:articles db) ;; ->> is a thread last macro - pass atricles as last arg of:
(vals) ;; vals, just as we would write (vals articles), then pass the result to:
(sort-by :epoch reverse-cmp)))) ;; sort-by epoch in reverse order
:articles ;; usage: (subscribe [:articles])
(fn [db _] ;; db is the (map) value stored in the app-db atom
(->> (:articles db) ;; ->> is a thread last macro - pass atricles as last arg of:
(vals) ;; vals, just as we would write (vals articles), then pass the result to:
(sort-by :epoch reverse-cmp)))) ;; sort-by epoch in reverse order

(reg-sub
:articles-count ;; usage: (subscribe [:articles-count])
(fn [db _]
(:articles-count db)))
:articles-count ;; usage: (subscribe [:articles-count])
(fn [db _]
(:articles-count db)))

(reg-sub
:active-article ;; usage (subscribe [:active-article])
(fn [db _]
(let [active-article (:active-article db)]
(get-in db [:articles active-article]))))
:active-article ;; usage (subscribe [:active-article])
(fn [db _]
(let [active-article (:active-article db)]
(get-in db [:articles active-article]))))

(reg-sub
:tags ;; usage: (subscribe [:tags])
(fn [db _]
(:tags db)))
:tags ;; usage: (subscribe [:tags])
(fn [db _]
(:tags db)))

(reg-sub
:comments ;; usage: (subscribe [:comments])
(fn [db _]
(->> (:comments db)
(vals)
(sort-by :epoch reverse-cmp))))
:comments ;; usage: (subscribe [:comments])
(fn [db _]
(->> (:comments db)
(vals)
(sort-by :epoch reverse-cmp))))

(reg-sub
:profile ;; usage: (subscribe [:profile])
(fn [db _]
(:profile db)))
:profile ;; usage: (subscribe [:profile])
(fn [db _]
(:profile db)))

(reg-sub
:loading ;; usage: (subscribe [:loading])
(fn [db _]
(:loading db)))
:loading ;; usage: (subscribe [:loading])
(fn [db _]
(:loading db)))

(reg-sub
:filter ;; usage: (subscribe [:filter])
(fn [db _]
(:filter db)))
:filter ;; usage: (subscribe [:filter])
(fn [db _]
(:filter db)))

(reg-sub
:errors ;; usage: (subscribe [:errors])
(fn [db _]
(:errors db)))
:errors ;; usage: (subscribe [:errors])
(fn [db _]
(:errors db)))

(reg-sub
:user ;; usage: (subscribe [:user])
(fn [db _]
(:user db)))
:user ;; usage: (subscribe [:user])
(fn [db _]
(:user db)))
Loading

0 comments on commit 29d7520

Please sign in to comment.