Skip to content

Commit

Permalink
describe dev setup, fixes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
rksm committed Aug 27, 2019
1 parent 9c2ebcc commit 27f4d46
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 25 deletions.
26 changes: 20 additions & 6 deletions Makefile
@@ -1,3 +1,7 @@
.PHONY: nrepl chrome clean run-jar cljs cljs-prod http-server app-test test figwheel

# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

VERSION := 0.3.3

CLJ_FILES := $(shell find . -type f \
Expand All @@ -13,16 +17,19 @@ CLJS_FILES := $(shell find . -type f \
# repl / dev

nrepl:
clojure -R:deps:cljs:nrepl -C:cljs -C:nrepl -m org-analyzer.nrepl-server
clojure -Srepro -R:deps:cljs:nrepl:test -C:cljs:nrepl:test -m org-analyzer.nrepl-server

figwheel:
clj -R:cljs -C:dev -m figwheel.main -b dev -r

chrome:
chromium \
--remote-debugging-port=9222 \
--no-first-run \
--user-data-dir=chrome-user-profile

http-server:
clojure -A:http-server ~/org
http-server: cljs-prod
clojure -A:http-server

# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# cljs
Expand All @@ -31,7 +38,7 @@ JS_FILES := resources/public/cljs-out/dev/
JS_PROD_FILES := resources/public/cljs-out/prod/

$(JS_FILES): $(CLJS_FILES) deps.edn dev.cljs.edn
clojure -A:cljs
clojure -A:dev:cljs -C:test

$(JS_PROD_FILES): $(CLJS_FILES) deps.edn prod.cljs.edn
clojure -R:cljs -A:cljs-prod
Expand Down Expand Up @@ -117,10 +124,17 @@ emacs-package: $(EMACS_PACKAGE_DIR)

# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

# app-test:
# clojure -R:test:cljs -m figwheel.main -co test.cljs.edn -m org-analyzer.app-test

test:
clojure -A:test

# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

clean:
rm -rf target/$(EMACS_PACKAGE_NAME).tar.gz \
$(EMACS_PACKAGE_DIR) \
target .cpcache $(AOT) \
resources/public/cljs-out \
$(JAR) bin

.PHONY: nrepl chrome clean run-jar cljs cljs-prod http-server
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -88,6 +88,19 @@ For more info see https://github.com/rksm/cljs-org-analyzer.
```


## Hacking

To play around with the codebase you will need to have [Clojure](https://clojure.org/guides/getting_started) installed.

To just run the app from source do a `git clone https://github.com/rksm/clj-org-analyzer` and then `make http-server`. Then visit http://localhost:8090.

You can run the server-side tests via `make test`.

To work interactively, I would recommend an editor / IDE that uses [nREPL](https://nrepl.org/nrepl/0.6.0/index.html), I personally use Emacs with [cider](https://cider.mx). Start an nREPL server with `make nrepl` (this will also start an http-server) and then connect to localhost:7888 for a Clojure session and to localhost:7889 for a ClojureScript session.

If you don't use an nREPL enabled editor you can still run a figwheel repl via `make figwheel`.

Whe running with nREPL or figwheel you will get an additional page for UI experiments and tests: http://localhost:8090/expts.html

## License

Expand Down
19 changes: 16 additions & 3 deletions deps.edn
Expand Up @@ -5,7 +5,7 @@
compojure {:mvn/version "1.6.1"}
com.taoensso/tufte {:mvn/version "2.1.0-RC4"}}

:paths ["src" "test" "resources"]
:paths ["src" "resources"]

:aliases {:graal-prep
{:extra-paths ["dev"]
Expand All @@ -14,9 +14,22 @@
:http-server
{:main-opts ["-m" "org-analyzer.main"]}

:dev {:extra-paths ["dev"]}

:nrepl {:extra-paths ["dev"]
:extra-deps {nrepl {:mvn/version "RELEASE"}
vvvvalvalval/scope-capture {:mvn/version "RELEASE"}
cider/piggieback {:mvn/version "RELEASE"}
cider/cider-nrepl {:mvn/version "0.22.0-beta11"}
refactor-nrepl {:mvn/version "2.5.0-SNAPSHOT"}}}

:test {:extra-paths ["test"]
:extra-deps {com.cognitect/test-runner {:git/url "https://github.com/cognitect-labs/test-runner.git"
:sha "209b64504cb3bd3b99ecfec7937b358a879f55c1"}}
:main-opts ["-m" "cognitect.test-runner"]}

:cljs
{:extra-deps {cider/cider-nrepl {:mvn/version "0.22.0-beta10"}
org.clojure/clojurescript {:mvn/version "1.10.520"}
{:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.520"}
com.bhauman/figwheel-main {:mvn/version "RELEASE"}
cljs-http {:mvn/version "0.1.46"}
reagent {:mvn/version "0.8.1"}}
Expand Down
2 changes: 1 addition & 1 deletion dev.cljs.edn
@@ -1,4 +1,4 @@
^{:watch-dirs ["src"]
^{:watch-dirs ["src" "dev"]
:css-dirs ["resources/public/css"]
:hot-reload-cljs true
:open-url false
Expand Down
27 changes: 27 additions & 0 deletions dev/org_analyzer/view/expt_test_data.cljs
@@ -0,0 +1,27 @@
(ns org-analyzer.view.expt-test-data
(:require
[org-analyzer.view.app :as app]
[cljs.pprint :refer [pprint]]))

(def info {:clock-count 5, :org-files ["/foo/bar.org" "/foo/baz.org"]})

(def clocks [{:start "2019-08-25 14:12" :end "2019-08-26 15:10" :duration "0:58" :path ["bar.org"] :name "activity 1" :location "bar.org/activity 1" :tags #{"org" "tag1" "tag2"}}
{:start "2019-08-26 15:26" :end "2019-08-26 17:12" :duration "1:46" :path ["bar.org"] :name "activity 1" :location "bar.org/activity 1" :tags #{"org" "tag1" "tag2"}}
{:start "2019-08-23 17:15" :end "2019-08-26 17:50" :duration "0:35" :path ["baz.org" "zork"] :name "activity 2" :location "baz.org/zork/activity 2" :tags #{"org" "tag 3"}}
{:start "2019-08-26 19:17" :end "2019-08-26 19:27" :duration "0:10" :path ["baz.org" "zork"] :name "activity 2" :location "baz.org/zork/activity 2" :tags #{"org" "tag 3"}}
{:start "2019-08-27 19:38" :end false :duration false :path ["baz.org" "zork"] :name "activity 2" :location "baz.org/zork/activity 2" :tags #{"org" "tag 3"}}])

(def calendar (into (sorted-map-by <) {"2019-08-23" {:date "2019-08-23" :dow 5 :dow-name "Friday" :week 34 :month "August" :year 2019}
"2019-08-24" {:date "2019-08-24" :dow 6 :dow-name "Saturday" :week 34 :month "August" :year 2019}
"2019-08-25" {:date "2019-08-25" :dow 7 :dow-name "Sunday" :week 34 :month "August" :year 2019}
"2019-08-26" {:date "2019-08-26" :dow 1 :dow-name "Monday" :week 35 :month "August" :year 2019}
"2019-08-27" {:date "2019-08-27" :dow 2 :dow-name "Tuesday" :week 35 :month "August" :year 2019}}))

(defn test-data []
(let [app-state (app/empty-app-state)
dom-state (app/empty-dom-state)
event-handlers (app/event-handlers app-state dom-state)]
(swap! app-state merge (app/prepare-fetched-clocks info clocks calendar))
{:app-state app-state
:dom-state dom-state
:event-handlers event-handlers}))
Expand Up @@ -13,7 +13,7 @@
[clojure.set :refer [union]]
[cljs.pprint :refer [cl-format]]
[org-analyzer.view.expts-helper :as e :refer [expts defexpt]]
[org-analyzer.devcards-test-data :refer [test-data]]
[org-analyzer.view.expt-test-data :refer [test-data]]
[org-analyzer.view.selected-day :as selected-day]
[org-analyzer.view.day-by-minute-view :as day-by-minute-view]))

Expand Down
File renamed without changes.
Expand Up @@ -30,9 +30,9 @@
toggle (fn [bool] (swap! visible-expts assoc key bool))]
(if-not (key @visible-expts)
[:div.expt-toggle.collapsed
[:button.collapsible {:on-click #(toggle true)} (str "+ " comp-name)]]
[:button.material-button.collapsible {:on-click #(toggle true)} (str "+ " comp-name)]]
[:div.expt-toggle.uncollapsed
[:button.collapsible {:on-click #(toggle false)} (str "- " comp-name)]
[:button.material-button.collapsible {:on-click #(toggle false)} (str "- " comp-name)]
[component]])))

(defn purge-expt! [expt-id]
Expand All @@ -43,5 +43,10 @@

(defn expts []
[:div.expts
[:div.controls
[:button.material-button {:on-click #(if (empty? @visible-expts)
(swap! visible-expts merge (for [[key component] @expt-registry] [key true]))
(reset! visible-expts {}))} "toggle all"]]
(-> @expt-registry :calendar)
(doall (for [[key component] @expt-registry]
^{:key key} [expts-toggle key component]))])
8 changes: 8 additions & 0 deletions resources/public/css/expts.css
Expand Up @@ -14,9 +14,17 @@ h1 {
}
.expts .expt-toggle {
margin: 10px;
box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.2), 0px 0px 0px 0px rgba(0, 0, 0, 0.14), 0px 0px 0px 0px rgba(0, 0, 0, 0.12);
border-width: 1px;
border-style: solid;
border-color: #e0e0e0;
}
.expts .expt-toggle button {
width: 100%;
font-weight: bold;
}
.expts .expt-toggle.uncollapsed button {
background-color: #EEE;
}
.expt {
padding: 10px;
Expand Down
15 changes: 14 additions & 1 deletion resources/public/css/expts.less
Expand Up @@ -18,7 +18,20 @@ h1 {
.expt-toggle {
margin: 10px;

button {width: 100%;}
box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.2), 0px 0px 0px 0px rgba(0, 0, 0, 0.14), 0px 0px 0px 0px rgba(0,0,0,.12);
border-width: 1px;
border-style: solid;
border-color: #e0e0e0;

button {
width: 100%;
font-weight:bold;
}

&.uncollapsed button {
background-color: #EEE;
}

}
}

Expand Down
3 changes: 1 addition & 2 deletions src/org_analyzer/view/app.cljs
Expand Up @@ -14,8 +14,7 @@
[org-analyzer.view.tooltip :as tooltip]
[org-analyzer.view.search-view :as search-view]
[cljs.reader :as reader]
[org-analyzer.view.help-view :as help-view]
sc.api))
[org-analyzer.view.help-view :as help-view]))

;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;; data
Expand Down
18 changes: 9 additions & 9 deletions test/org_analyzer/parsing_test.clj
Expand Up @@ -172,18 +172,18 @@ CREATED: [2018-12-15 Sa 12:05]
(process/all-tags-for (last org-data) org-data)))))

(deftest non-linear-ested-sections
[test-content "* A
(let [test-content "* A
*** four below A
this should not show the elements from BBBB as children
* B"
expected [{:tags '() :index 0 :type :file :name "pseudo.org" :depth 0 :props '()}
{:index 1 :parent 0 :type :section :line 1 :depth 1 :name "A"}
{:index 2 :parent 1 :type :section :line 2 :depth 3 :name "four below A"}
{:index 3 :parent 0 :type :section :line 4 :depth 1 :name "B"}]
actual (process/parse-org-file
"pseudo.org"
(java.io.StringBufferInputStream. test-content))]
(is (= expected actual)))
expected [{:tags '() :index 0 :type :file :name "pseudo.org" :depth 0 :props '()}
{:index 1 :parent 0 :type :section :line 1 :depth 1 :name "A"}
{:index 2 :parent 1 :type :section :line 2 :depth 3 :name "four below A"}
{:index 3 :parent 0 :type :section :line 4 :depth 1 :name "B"}]
actual (process/parse-org-file
"pseudo.org"
(java.io.StringBufferInputStream. test-content))]
(is (= expected actual))))

;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Expand Down

0 comments on commit 27f4d46

Please sign in to comment.