git ssb

0+

dust / spaceship-bridge



Commit 1c6860950766a4374f50d28c62707f3897061a41

first commit: reagent+sass+secretary+electron

dust committed on 4/23/2016, 6:44:27 AM
Parent: a728820a56f2ecf3bd0fad0b816488d0fe98a38c

Files changed

.gitignoreadded
README.mdadded
boot.propertiesadded
build.bootadded
sass/main.scssadded
src/app/main.cljsadded
src/app/renderer.cljsadded
.gitignoreView
@@ -1,0 +1,8 @@
1 +*~
2 +target/*
3 +*~
4 +resources/*
5 +.cljs_rhino_repl/*
6 +out/
7 +/.nrepl-history
8 +/.nrepl-port
README.mdView
@@ -1,0 +1,35 @@
1 +# spaceship-bridge
2 +
3 +## description
4 +
5 +this is a companion interface to
6 +[spaceship](https://github.com/du5t/spaceship/). the goal is to help
7 +contextualise the work there and enable graphical usage.
8 +
9 +## how to run
10 +
11 +### dev mode
12 +
13 +you'll need [lein](http://leiningen.org/#install) and
14 +[boot](https://github.com/boot-clj/boot) for a development environment, as well
15 +as [electron-prebuilt](https://github.com/mafintosh/electron-prebuilt) or
16 +something like it.
17 +
18 +once you've sorted those, run `boot watch dev-build` in the repo root directory,
19 +and while you've got that running, run `electron target/`.
20 +
21 +for console REPL access, run `boot repl -c` from the repo root directory, then
22 +eval `(start-repl)` once you've got a prompt.
23 +
24 +### production
25 +
26 +according to
27 +[martin klepsch](https://github.com/martinklepsch/electron-and-clojurescript) on
28 +whose system this project is based, the way to package up an electron app is
29 +with [`electron-packager`](https://github.com/maxogden/electron-packager):
30 +
31 +```
32 +electron-packager target/ spaceship-bridge --platform=darwin --arch=x64 --version=0.31.2
33 +```
34 +
35 +packaging up the whole ship, engines and all, is still in the works.
boot.propertiesView
@@ -1,0 +1,4 @@
1 +#https://github.com/boot-clj/boot
2 +#Fri Jul 31 00:07:27 CEST 2015
3 +BOOT_CLOJURE_VERSION=1.7.0
4 +BOOT_VERSION=2.2.0
build.bootView
@@ -1,0 +1,46 @@
1 +(set-env!
2 + :source-paths #{"sass" "src"}
3 + :resource-paths #{"resources"}
4 + :dependencies '[[adzerk/boot-cljs "1.7.48-3" :scope "test"]
5 + [org.clojure/clojurescript "1.7.107"]
6 + [adzerk/boot-cljs-repl "0.1.10-SNAPSHOT" :scope "test"]
7 + [adzerk/boot-reload "0.3.2-SNAPSHOT" :scope "test"]
8 + [com.cemerick/piggieback "0.2.1" :scope "test"]
9 + [weasel "0.7.0" :scope "test"]
10 + [org.clojure/tools.nrepl "0.2.12" :scope "test"]
11 + [reagent "0.5.1"]
12 + [mathias/boot-sassc "0.1.1" :scope "test"]
13 + [secretary "1.2.3"]])
14 +
15 +(require
16 + '[adzerk.boot-cljs :refer [cljs]]
17 + '[adzerk.boot-cljs-repl :refer [cljs-repl start-repl]]
18 + '[adzerk.boot-reload :refer [reload]]
19 + '[mathias.boot-sassc :refer [sass]])
20 +
21 +(deftask prod-build []
22 + (comp (cljs :ids #{"main"}
23 + :optimizations :simple)
24 + (cljs :ids #{"renderer"}
25 + :optimizations :advanced)
26 + (sass :output-dir "css")))
27 +
28 +(deftask dev-build []
29 + (comp ;; Audio feedback about warnings etc. =======================
30 + ;; (speak)
31 + ;; Inject REPL and reloading code into renderer build =======
32 + (cljs-repl :ids #{"renderer"})
33 + (reload :ids #{"renderer"}
34 + :on-jsload 'app.renderer/init)
35 + ;; Compile renderer =========================================
36 + (cljs :ids #{"renderer"})
37 + ;; Compile JS for main process ==============================
38 + ;; path.resolve(".") which is used in CLJS's node shim
39 + ;; returns the directory `electron` was invoked in and
40 + ;; not the directory our main.js file is in.
41 + ;; Because of this we need to override the compilers `:asset-path option`
42 + ;; See http://dev.clojure.org/jira/browse/CLJS-1444 for details.
43 + (cljs :ids #{"main"}
44 + :compiler-options {:asset-path "target/main.out"
45 + :closure-defines {'app.main/dev? true}})
46 + (sass :output-dir "target/css")))
sass/main.scssView
@@ -1,0 +1,5 @@
1 +body {
2 + font-family: sans-serif;
3 + background-color: #222;
4 + color: #ddd;
5 +}
src/app/main.cljsView
@@ -1,0 +1,37 @@
1 +(ns app.main
2 + (:require [reagent.core :as reagent]))
3 +
4 +(def app (js/require "app"))
5 +(def BrowserWindow (js/require "browser-window"))
6 +
7 +(goog-define dev? false)
8 +
9 +(defn load-page
10 + "When compiling with `:none` the compiled JS that calls .loadUrl is
11 + in a different place than it would be when compiling with optimizations
12 + that produce a single artifact (`:whitespace, :simple, :advanced`).
13 +
14 + Because of this we need to dispatch the loading based on the used
15 + optimizations, for this we defined `dev?` above that we can override
16 + at compile time using the `:clojure-defines` compiler option."
17 + [window]
18 + (if dev?
19 + (.loadUrl window (str "file://" js/__dirname "/../../index.html"))
20 + (.loadUrl window (str "file://" js/__dirname "/index.html"))))
21 +
22 +(def main-window (atom nil))
23 +
24 +(defn mk-window [w h frame? show?]
25 + (BrowserWindow. #js {:width w :height h :frame frame? :show show?}))
26 +
27 +(defn init-browser []
28 + (reset! main-window (mk-window 800 600 true true))
29 + (load-page @main-window)
30 + (if dev? (.openDevTools @main-window))
31 + (.on @main-window "closed" #(reset! main-window nil)))
32 +
33 +(defn init []
34 + (.on app "window-all-closed" #(when-not (= js/process.platform "darwin") (.quit app)))
35 + (.on app "ready" init-browser)
36 + (set! *main-cli-fn* (fn [] nil)))
37 +
src/app/renderer.cljsView
@@ -1,0 +1,19 @@
1 +(ns app.renderer
2 + (:require [reagent.core :as reagent]))
3 +
4 +;; -------------------------
5 +;; Views
6 +
7 +(defn main-page []
8 + [:div
9 + [:div.titlebar [:h1 "spaceship"]]])
10 +
11 +;; -------------------------
12 +;; Initialize app
13 +
14 +(defn mount-root []
15 + (reagent/render [main-page] (.getElementById js/document "container")))
16 +
17 +(defn init []
18 + (js/console.log "spaceship bridge now coming online...")
19 + (mount-root))

Built with git-ssb-web