Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
convert js extra.js to google closure lib; setup tests; update readme
  • Loading branch information
andrew committed Jun 13, 2016
1 parent f44561f commit 4966fdb
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 93 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -8,3 +8,4 @@ out
/node_modules
/.lein-repl-history
/secrets.yml
/doo-index.html
5 changes: 4 additions & 1 deletion Makefile
Expand Up @@ -45,4 +45,7 @@ start:
@$(MAKE) sass-dev
@lein figwheel

.PHONY: help clean build-cljs install sass-dev sass-watch build start
test:
lein doo phantom test

.PHONY: help clean build-cljs install sass-dev sass-watch build start test
16 changes: 7 additions & 9 deletions README.md
Expand Up @@ -9,17 +9,17 @@ stack:

* language: [clojure](https://clojure.org/) / [clojurescript](https://github.com/clojure/clojurescript) [1]

* view: [reagent](http://reagent-project.github.io/) (react interface) / [hiccup](https://github.com/weavejester/hiccup)
* view: [reagent](http://reagent-project.github.io/) (react interface)

* rx / state: [re-frame](https://github.com/day8/re-frame)

* routing: [secretary](https://github.com/gf3/secretary)
* routing: [bidi](https://github.com/juxt/bidi)

* development environment: [figwheel](https://github.com/bhauman/lein-figwheel)

* css: [sass](http://sass-lang.com/)

* tests: [doo](https://github.com/bensu/doo)
* tests: [doo](https://github.com/bensu/doo) (runner) / [cljs.test](https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/test.cljs)

* ci: [drone](https://github.com/drone/drone) [2]

Expand Down Expand Up @@ -75,16 +75,14 @@ requires filewatcher, see above.
watches sass files, then uses sassc in an ephemeral docker container to
rebuild when a file changes. also builds sourcemaps.

<!--
### run tests:
## testing:

```sh
lein clean
lein doo phantom test once
# npm install -g phantomjs-prebuilt
make test
```

the above command assumes that you have [phantomjs](https://www.npmjs.com/package/phantomjs) installed. however, please note that [doo](https://github.com/bensu/doo) can be configured to run cljs.test in many other js environments (chrome, ie, safari, opera, slimer, node, rhino, or nashorn).
-->
the above command assumes that you have [phantomjs](https://www.npmjs.com/package/phantomjs) installed. however, please note that [doo](https://github.com/bensu/doo) can be configured to run cljs.test in many other js environments (phantom, chrome, ie, safari, opera, slimer, node, rhino, or nashorn).

## prod build

Expand Down
8 changes: 6 additions & 2 deletions project.clj
Expand Up @@ -48,14 +48,18 @@
:output-dir "resources/public/js/compiled/out"
:asset-path "js/compiled/out"
:source-map-timestamp true
:libs ["src/js"]
:foreign-libs [{:file "node_modules/autotrack/autotrack.js"
:provides ["autotrack"]}]}}

{:id "test"
:source-paths ["src/cljs" "test/cljs"]
:compiler {:output-to "resources/public/js/compiled/test.js"
:main ulysses.runner
:optimizations :none}}]}}
:optimizations :none
:libs ["src/js"]
:foreign-libs [{:file "node_modules/autotrack/autotrack.js"
:provides ["autotrack"]}]}}]}}

:prod
{:cljsbuild
Expand All @@ -66,7 +70,7 @@
:output-to "resources/public/js/compiled/app.js"
:optimizations :advanced
:closure-defines {goog.DEBUG false}
:externs ["src/externs/extra.externs.js"]
:libs ["src/js"]
:foreign-libs [{:file "node_modules/autotrack/autotrack.js"
:provides ["autotrack"]}]
:pretty-print false}}]}}})
1 change: 0 additions & 1 deletion resources/public/index.html
Expand Up @@ -7,7 +7,6 @@
</head>
<body>
<div id="app"></div>
<script src="js/extra.js"></script>
<script src="js/compiled/app.js"></script>
<script>ulysses.core.init();</script>

Expand Down
11 changes: 4 additions & 7 deletions src/cljs/ulysses/lib/packer.cljs
@@ -1,12 +1,11 @@
(ns ulysses.lib.packer
(:require [clojure.walk :refer [keywordize-keys]]
[ulysses.utils :refer [map-subels ptr]]))

(def jsPacker (.-Packer js/extra))
[ulysses.utils :refer [map-subels ptr]]
[ulysses.extra :refer [Packer textDimensions]]))

(defn fit
[w h blocks]
(let [p (new jsPacker w h)]
(let [p (new Packer w h)]
(->> blocks
(sort-by :h)
(reverse)
Expand All @@ -19,12 +18,10 @@
(update block :fit dissoc
:used :right :down :w :h))))))

(def jsTextDimensions (.-textDimensions js/extra))

(defn text-dimensions
[text options]
(-> text
(jsTextDimensions (clj->js options))
(textDimensions (clj->js options))
(js->clj)
(keywordize-keys)))

Expand Down
5 changes: 3 additions & 2 deletions src/cljs/ulysses/pages/builder.cljs
Expand Up @@ -14,7 +14,8 @@
[ulysses.lib.packer :as packer]
[reagent.core :as r]
[clojure.string :as string]
[cljs.pprint :as pprint]))
[cljs.pprint :as pprint]
[ulysses.extra :refer [select_values]]))

;; ----------------------------------------------------------------------------
; helpers
Expand All @@ -35,7 +36,7 @@
(dispatch [:builder-filter-faculty-years-uconn
(->> e
(.-target)
(.select_values js/extra)
(select_values)
(js->clj))]))}
(map-subels
(fn [t] [:option {:value t} (str t "+")])
Expand Down
67 changes: 0 additions & 67 deletions src/externs/extra.externs.js

This file was deleted.

6 changes: 2 additions & 4 deletions resources/public/js/extra.js → src/js/extra.js
@@ -1,10 +1,8 @@
// ulysses extra utility functions

//
// NOTE should be matched with externs in extra.externs.js
//
goog.provide('ulysses.extra')

var extra = (function() {
ulysses.extra = (function() {
"use strict";

/**
Expand Down

0 comments on commit 4966fdb

Please sign in to comment.