diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ef2717 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +*.log diff --git a/README.md b/README.md index 3794fe0..7fe7527 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,30 @@ metadata and passes it to sedit, attempting to redefine the function from the re the basic clojure 'all data is immutable' reason. But, when you invoke (use 'namespace :reload), it is able to redefine all the functions, so I must be able to work out how this is done. +## Development Mode + +### Run application: + +``` +lein clean +lein figwheel dev +``` + +Figwheel will automatically push cljs changes to the browser. + +Wait a bit, then browse to [http://localhost:3449](http://localhost:3449). + +## Production Build + + +To compile clojurescript to javascript: + +``` +lein clean +lein cljsbuild once min +``` + + ## License Copyright © 2013 Simon Brooke diff --git a/project.clj b/project.clj index f902587..2aab8b5 100644 --- a/project.clj +++ b/project.clj @@ -1,8 +1,54 @@ (defproject fedit "0.1.0-SNAPSHOT" :description "An attempt to reconstruct the Cambridge Lisp 'fedit' in core editor, as a precursor to attempting to reconstruct the InterLisp DEdit editor" - :url "http://example.com/FIXME" - :license {:name "Eclipse Public License" - :url "http://www.eclipse.org/legal/epl-v10.html"} + :url "https://github.com/simon-brooke/fedit" + :license {:name "GNU General Public License,version 2.0 or (at your option) any later version" + :url "https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html"} :dependencies [[org.clojure/clojure "1.8.0"] - [jline "2.11"]] - :clean-targets ["classes" "bin"]) + [jline "2.11"] + [org.clojure/clojurescript "1.9.908"] + [reagent "0.7.0"] + [re-frame "0.10.5"]] + + :plugins [[lein-cljsbuild "1.1.5"]] + + :min-lein-version "2.5.3" + + :source-paths ["src/clj"] + + :clean-targets ^{:protect false} ["resources/public/js/compiled" "target" "classes" "bin"] + + :figwheel {:css-dirs ["resources/public/css"]} + + :profiles + {:dev + {:dependencies [[binaryage/devtools "0.9.4"]] + + :plugins [[lein-figwheel "0.5.13"]]}} + + :cljsbuild + {:builds + [{:id "dev" + :source-paths ["src/cljs"] + :figwheel {:on-jsload "fedit.core/mount-root"} + :compiler {:main fedit.core + :output-to "resources/public/js/compiled/app.js" + :output-dir "resources/public/js/compiled/out" + :asset-path "js/compiled/out" + :source-map-timestamp true + :preloads [devtools.preload] + :external-config {:devtools/config {:features-to-install :all}} + }} + + {:id "min" + :source-paths ["src/cljs"] + :compiler {:main fedit.core + :output-to "resources/public/js/compiled/app.js" + :optimizations :advanced + :closure-defines {goog.DEBUG false} + :pretty-print false}} + + + ]} + + + ) diff --git a/resources/public/index.html b/resources/public/index.html new file mode 100644 index 0000000..d5a210e --- /dev/null +++ b/resources/public/index.html @@ -0,0 +1,13 @@ + + + + + + + + +
+ + + + diff --git a/src/clj/fedit/core.clj b/src/clj/fedit/core.clj new file mode 100644 index 0000000..6c2e2d0 --- /dev/null +++ b/src/clj/fedit/core.clj @@ -0,0 +1 @@ +(ns fedit.core) diff --git a/src/cljs/fedit/config.cljs b/src/cljs/fedit/config.cljs new file mode 100644 index 0000000..e587b2b --- /dev/null +++ b/src/cljs/fedit/config.cljs @@ -0,0 +1,4 @@ +(ns fedit.config) + +(def debug? + ^boolean goog.DEBUG) diff --git a/src/cljs/fedit/core.cljs b/src/cljs/fedit/core.cljs new file mode 100644 index 0000000..ae2debd --- /dev/null +++ b/src/cljs/fedit/core.cljs @@ -0,0 +1,22 @@ +(ns fedit.core + (:require [reagent.core :as reagent] + [re-frame.core :as re-frame] + [fedit.events :as events] + [fedit.views :as views] + [fedit.config :as config])) + + +(defn dev-setup [] + (when config/debug? + (enable-console-print!) + (println "dev mode"))) + +(defn mount-root [] + (re-frame/clear-subscription-cache!) + (reagent/render [views/main-panel] + (.getElementById js/document "app"))) + +(defn ^:export init [] + (re-frame/dispatch-sync [::events/initialize-db]) + (dev-setup) + (mount-root)) diff --git a/src/cljs/fedit/db.cljs b/src/cljs/fedit/db.cljs new file mode 100644 index 0000000..169927f --- /dev/null +++ b/src/cljs/fedit/db.cljs @@ -0,0 +1,4 @@ +(ns fedit.db) + +(def default-db + {:name "re-frame"}) diff --git a/src/cljs/fedit/events.cljs b/src/cljs/fedit/events.cljs new file mode 100644 index 0000000..9dd0da3 --- /dev/null +++ b/src/cljs/fedit/events.cljs @@ -0,0 +1,8 @@ +(ns fedit.events + (:require [re-frame.core :as re-frame] + [fedit.db :as db])) + +(re-frame/reg-event-db + ::initialize-db + (fn [_ _] + db/default-db)) diff --git a/src/cljs/fedit/subs.cljs b/src/cljs/fedit/subs.cljs new file mode 100644 index 0000000..03e4dfb --- /dev/null +++ b/src/cljs/fedit/subs.cljs @@ -0,0 +1,7 @@ +(ns fedit.subs + (:require [re-frame.core :as re-frame])) + +(re-frame/reg-sub + ::name + (fn [db] + (:name db))) diff --git a/src/cljs/fedit/views.cljs b/src/cljs/fedit/views.cljs new file mode 100644 index 0000000..40f20d3 --- /dev/null +++ b/src/cljs/fedit/views.cljs @@ -0,0 +1,8 @@ +(ns fedit.views + (:require [re-frame.core :as re-frame] + [fedit.subs :as subs] + )) + +(defn main-panel [] + (let [name (re-frame/subscribe [::subs/name])] + [:div "Hello from " @name]))