Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
|
2d8d9ea514 | ||
|
26d4889cff |
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
*.log
|
||||||
|
|
||||||
|
\.lein-repl-history
|
24
README.md
24
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
|
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.
|
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
|
## License
|
||||||
|
|
||||||
Copyright © 2013 Simon Brooke <stillyet-github@googlemail.com>
|
Copyright © 2013 Simon Brooke <stillyet-github@googlemail.com>
|
||||||
|
|
58
project.clj
58
project.clj
|
@ -1,8 +1,56 @@
|
||||||
(defproject fedit "0.1.0-SNAPSHOT"
|
(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"
|
: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"
|
:url "https://github.com/simon-brooke/fedit"
|
||||||
:license {:name "Eclipse Public License"
|
:license {:name "GNU General Public License,version 2.0 or (at your option) any later version"
|
||||||
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
:url "https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html"}
|
||||||
:dependencies [[org.clojure/clojure "1.8.0"]
|
:dependencies [[org.clojure/clojure "1.8.0"]
|
||||||
[jline "2.11"]]
|
[org.clojure/clojurescript "1.9.908"]
|
||||||
:clean-targets ["classes" "bin"])
|
[hiccup "1.0.5"]
|
||||||
|
[jline "2.11"]
|
||||||
|
[markdown-clj "1.0.2"]
|
||||||
|
[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" "src/cljc"]
|
||||||
|
|
||||||
|
: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" "src/cljc"]
|
||||||
|
: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" "src/cljc"]
|
||||||
|
:compiler {:main fedit.core
|
||||||
|
:output-to "resources/public/js/compiled/app.js"
|
||||||
|
:optimizations :advanced
|
||||||
|
:closure-defines {goog.DEBUG false}
|
||||||
|
:pretty-print false}}
|
||||||
|
|
||||||
|
|
||||||
|
]}
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
|
13
resources/public/index.html
Normal file
13
resources/public/index.html
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset='utf-8'>
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script src="js/compiled/app.js"></script>
|
||||||
|
<script>fedit.core.init();</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
1
src/clj/fedit/core.clj
Normal file
1
src/clj/fedit/core.clj
Normal file
|
@ -0,0 +1 @@
|
||||||
|
(ns fedit.core)
|
81
src/cljc/fedit/format.cljc
Normal file
81
src/cljc/fedit/format.cljc
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
(ns fedit.format
|
||||||
|
"Essentially, a pretty-printer which renders Clojure as HTML"
|
||||||
|
(:require [clojure.string :as s]
|
||||||
|
[hiccup.core :refer [html]]
|
||||||
|
[markdown.core :refer [md-to-html-string]]))
|
||||||
|
|
||||||
|
(declare format-object)
|
||||||
|
|
||||||
|
(defn format-inline
|
||||||
|
[o]
|
||||||
|
[:span {:class "clojure"} o])
|
||||||
|
|
||||||
|
(defn format-string
|
||||||
|
[o]
|
||||||
|
[:span (md-to-html-string o)])
|
||||||
|
|
||||||
|
(defn format-block
|
||||||
|
[o]
|
||||||
|
[:div {:class "clojure"} o])
|
||||||
|
|
||||||
|
(defn format-quoted
|
||||||
|
[q]
|
||||||
|
(format-inline (str "'" (nth q 1))))
|
||||||
|
|
||||||
|
|
||||||
|
(defn format-sequence
|
||||||
|
[s]
|
||||||
|
(let [lpar (if (vector? s) "[" "(")
|
||||||
|
rpar (if (vector? s) "]" ")")]
|
||||||
|
(conj
|
||||||
|
(vec
|
||||||
|
(cons
|
||||||
|
:div
|
||||||
|
(cons
|
||||||
|
{:class "clojure"}
|
||||||
|
(cons
|
||||||
|
lpar
|
||||||
|
(map format-object s)))))
|
||||||
|
rpar)))
|
||||||
|
|
||||||
|
(defn format-map
|
||||||
|
[m]
|
||||||
|
(let [c (count (keys m))]
|
||||||
|
(vec
|
||||||
|
(cons
|
||||||
|
:table
|
||||||
|
(for
|
||||||
|
[i (range c) k (keys m)]
|
||||||
|
[:tr
|
||||||
|
[:td (if (zero? i) "{")]
|
||||||
|
[:th (format-object k)]
|
||||||
|
[:td (format-object (m k))]
|
||||||
|
[:td (if (= (inc i) c) "}")]])))))
|
||||||
|
|
||||||
|
(defn format-object
|
||||||
|
[o]
|
||||||
|
(cond
|
||||||
|
(and
|
||||||
|
(list? o)
|
||||||
|
(= (first o) 'quote)
|
||||||
|
(not (seq? (nth o 1))))
|
||||||
|
(format-quoted o)
|
||||||
|
(or
|
||||||
|
(nil? o)
|
||||||
|
(true? o)
|
||||||
|
(number? o)
|
||||||
|
(symbol? o))
|
||||||
|
(format-inline o)
|
||||||
|
(keyword? o)
|
||||||
|
(format-inline (str ":" (name o)))
|
||||||
|
(string? o)
|
||||||
|
(format-string o)
|
||||||
|
(or
|
||||||
|
(vector? o)
|
||||||
|
(list? o))
|
||||||
|
(format-sequence o)
|
||||||
|
(map? o)
|
||||||
|
(format-map o)
|
||||||
|
true
|
||||||
|
(format-block o)))
|
||||||
|
|
4
src/cljs/fedit/config.cljs
Normal file
4
src/cljs/fedit/config.cljs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
(ns fedit.config)
|
||||||
|
|
||||||
|
(def debug?
|
||||||
|
^boolean goog.DEBUG)
|
22
src/cljs/fedit/core.cljs
Normal file
22
src/cljs/fedit/core.cljs
Normal file
|
@ -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))
|
4
src/cljs/fedit/db.cljs
Normal file
4
src/cljs/fedit/db.cljs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
(ns fedit.db)
|
||||||
|
|
||||||
|
(def default-db
|
||||||
|
{:name "re-frame"})
|
8
src/cljs/fedit/events.cljs
Normal file
8
src/cljs/fedit/events.cljs
Normal file
|
@ -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))
|
7
src/cljs/fedit/subs.cljs
Normal file
7
src/cljs/fedit/subs.cljs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
(ns fedit.subs
|
||||||
|
(:require [re-frame.core :as re-frame]))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
::name
|
||||||
|
(fn [db]
|
||||||
|
(:name db)))
|
8
src/cljs/fedit/views.cljs
Normal file
8
src/cljs/fedit/views.cljs
Normal file
|
@ -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]))
|
Loading…
Reference in a new issue