more info about failure

more info about failure

--- src/babel/english/writer.clj
+++ src/babel/english/writer.clj
@@ -46,8 +46,17 @@
                                    ;; of what the (process) command did.
                                    (log/debug (str "process result:" result)))
                                 (catch Exception e
-                                  true
-                                  (throw e)))))))))
+                                  (cond
+                                    true
+                                    (log/error (str "Could not translate source expression: "
+                                                    "'" (get source-expression :surface) "'"
+                                                    " from language: " source-language-short-name
+                                                    " with predicate: "
+                                                    (strip-refs (get-in source-expression [:structure :synsem :sem :pred]))
+                                                    " into English; subj: "
+                                                    (get-in source-expression [:structure :synsem :sem :subj :pred])))
+                                    false
+                                    (throw e))))))))))
                  source-expressions))))

 (defn all [ & [count]]


Move render method up closer to its state

--- src/bbloom/vdom/browser.cljs
+++ src/bbloom/vdom/browser.cljs
@@ -5,6 +5,14 @@
 (defonce state (atom {:vdom vdom/null :nodes {}}))

 (defmulti mutate (fn [vdom nodes [method & args]] method))
+
+(defn render [vdom]
+  (swap! state (fn [state]
+                 {:vdom vdom
+                  :nodes (reduce (fn [nodes [vdom op]]
+                                   (mutate vdom nodes op))
+                                 (:nodes state)
+                                 (trace-patch (:vdom state) vdom))})))

 (defmethod mutate :mount [vdom nodes [_ eid id]]
   (let [el (.getElementById js/document eid)]
@@ -63,11 +71,3 @@
      (let [nodes (dissoc nodes id)]
        (reduce rec nodes (:children (vdom/node vdom id)))))
    nodes id))
-
-(defn render [vdom]
-  (swap! state (fn [state]
-                 {:vdom vdom
-                  :nodes (reduce (fn [nodes [vdom op]]
-                                   (mutate vdom nodes op))
-                                 (:nodes state)
-                                 (trace-patch (:vdom state) vdom))})))


Now both works and makes sense

Now both works and makes sense

--- src/bejeweled_bot/solver.clj
+++ src/bejeweled_bot/solver.clj
@@ -21,23 +21,23 @@

 (defn check-matches
   "Check for matches from: 1. this left, 2. left to this, 3. this down, 4. down to this"
-  [x y gem-type gem-array]
+  [y x gem-type gem-array]
   (let
     [right-x (+ x 1)
      down-y (+ y 1)
-     right-gem-type (get-in gem-array [(+ x 1) y])
-     down-gem-type (get-in gem-array [x (+ y 1)])
+     right-gem-type (get-in gem-array [y right-x])
+     down-gem-type (get-in gem-array [down-y x])
      right-swap (assoc-in
-                     (assoc-in gem-array [(+ x 1) y] gem-type)
-                     [x y] right-gem-type)
+                     (assoc-in gem-array [y right-x] gem-type)
+                     [y x] right-gem-type)
      down-swap (assoc-in
-                     (assoc-in gem-array [x (+ y 1)] gem-type)
-                     [x y] down-gem-type)]
+                     (assoc-in gem-array [down-y x] gem-type)
+                     [y x] down-gem-type)]
     (cond
-      (would-match right-x y gem-type right-swap) {:x x :y y :dir "right" :debug 1 :gemtype gem-type}
-      (would-match x down-y gem-type down-swap) {:x x :y y :dir "down" :debug 2 :gemtype gem-type}
-      (would-match x y right-gem-type right-swap) {:x x :y y :dir "right" :debug 3 :gemtype right-gem-type}
-      (would-match x y down-gem-type down-swap) {:x x :y y :dir "down" :debug 4 :gemtype down-gem-type}
+      (would-match right-x y gem-type right-swap) {:x x :y y :dir "right" :gemtype gem-type}
+      (would-match x down-y gem-type down-swap) {:x x :y y :dir "down" :gemtype gem-type}
+      (would-match x y right-gem-type right-swap) {:x x :y y :dir "right" :gemtype right-gem-type}
+      (would-match x y down-gem-type down-swap) {:x x :y y :dir "down" :gemtype down-gem-type}
       :else nil)))

@@ -50,7 +50,7 @@
 (def down-swap swapd)
 (def gem-array swapd)
 (would-match x down-y gem-type down-swap) {:x x :y y :dir "down" :debug 2 :gemtype gem-type}
-(defn would-match [x y gem-type gem-array]
+(defn would-match [y x gem-type gem-array]
   (and (not (= gem-type nil))
   (or
     (=
@@ -79,11 +79,11 @@
       gem-type))))

 (def testArray
-  [[:ruby        :opal     :ruby       :ruby :topaz    :amethyst   :sapphire :sapphire]
+  [[:ruby        :opal     :ruby       :diamond    :topaz    :amethyst   :sapphire :sapphire]
    [:ruby        :diamond  :amethyst   :diamond    :opal     :smaragdine :sapphire :smaragdine]
    [:topaz       :diamond  :smaragdine :topaz      :opal     :diamond    :amethyst :ruby]
    [:sapphire    :opal     :sapphire   :topaz      :sapphire :smaragdine :ruby     :ruby]
-   [:amethyst    :opal     :diamond    :sapphire   :amethyst :ruby       :opal     :opal]
+   [:amethyst    :opal     :diamond    :smaragdine :amethyst :ruby       :opal     :opal]
    [:topaz       :amethyst :amethyst   :smaragdine :amethyst :topaz      :sapphire :amethyst]
    [:smaragdine  :topaz    :opal       :opal       :sapphire :ruby       :amethyst :sapphire]
    [:amethyst    :sapphire :diamond    :amethyst   :diamond  :topaz      :opal     :opal]])


Set up some channel stuff to route messages

--- src/tango/core.clj
+++ src/tango/core.clj
@@ -10,8 +10,15 @@
             [clojure.core.async
              :as a
              :refer [>! <! >!! <!! go chan buffer close! thread
-                     alts! alts!! timeout]]
-            ))
+                     alts! alts!! timeout go-loop]]))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Resources
+;http://www.core-async.info/tutorial/a-minimal-client
+;https://github.com/enterlab/rente
+
+; http://localhost:1337/admin
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (def memory-log (atom []))

@@ -21,25 +28,8 @@
 (defn import-file [{:keys [content]}]
   (imp/dance-perfect-xml->data (imp/read-xml-string content)))

-(def message-chan (chan))
-(def message-send-chan (chan))
-
-;; (go (println (<! test-chan)))
-;; (>!! test-chan "Duudde")
-
 (def message-log (atom []))
 (def message-send-log (atom []))
-
-(go (while true
-      (let [msg (<! message-chan)]
-        (swap! message-log conj msg)
-        (message-dispatch msg message-send-chan))))
-
-(go (while true
-      (let [msg (<! message-send-chan)]
-        (swap! message-send-log conj msg)
-        (chsk-send! (:id msg) (:message msg)))))
-

 (defn message-dispatch [{:keys [topic payload sender]} out-chan]
   (match [topic payload]
@@ -61,22 +51,17 @@
   (def connected-uids                connected-uids) ; Watchable, read-only atom
   )

-(defn event-msg-handler* [{:as ev-msg :keys [id ?data event ring-req]}]
-  (do
-    ;(logf (str "Event: " event))
-    (println (str "Id: " (:uid (:session ring-req))))
-    ;(println (str "Request : " ring-req))
-    ;(message-dispatch id ?data (:uid (:session ring-req)))
-    (>!! message-chan {:topic id :payload ?data :sender (:uid (:session ring-req))})))
+(defn event-msg-handler* [messages-receive-chan {:as ev-msg :keys [id ?data event ring-req]}]
+  (>!! messages-receive-chan {:topic id :payload ?data :sender (:uid (:session ring-req))}))

 (defonce router_ (atom nil))

 (defn stop-router! []
   (when-let [stop-f @router_] (stop-f)))

-(defn start-router! []
+(defn start-router! [messages-receive-chan]
   (stop-router!)
-  (reset! router_ (sente/start-chsk-router! ch-chsk event-msg-handler*)))
+  (reset! router_ (sente/start-chsk-router! ch-chsk (partial event-msg-handler* messages-receive-chan))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Http routing
@@ -107,16 +92,34 @@
     (stop-f :timeout 100)))
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Application
+(defonce messages-receive-chan (atom nil))
+(defonce messages-send-chan (atom (chan)))
+
+(defn start-message-loop [messages-receive-chan]
+  (go-loop []
+    (when-let [msg (<! messages-receive-chan)]
+      (println (str "message " msg))
+      (swap! message-log conj msg)
+      (message-dispatch msg @messages-send-chan)
+      (recur))))
+
+(go (while true
+      (let [msg (<! @messages-send-chan)]
+        (swap! message-send-log conj msg)
+        (chsk-send! (:id msg) (:message msg)))))

 (defn stop! []
   (do
+    (close! @messages-receive-chan)
     (stop-http-server!)
     (stop-router!)))

 (defn start! []
   (do
+    (reset! messages-receive-chan (chan))
+    (start-message-loop @messages-receive-chan)
     (start-http-server!)
-    (start-router!)))
+    (start-router! @messages-receive-chan)))

 (defn -main
   [& args]


[#9700] toolbar-title-container minor css fix

Signed-off-by: yenda <96f164ad4d9b2b0dacf8ebee2bb1eeb3aa69adf1@status.im>

--- src/status_im/ui/components/toolbar/styles.cljs
+++ src/status_im/ui/components/toolbar/styles.cljs
@@ -13,8 +13,7 @@
 (def toolbar-title-container
   {:justify-content :center
    :align-items     :center
-   :flex-direction  :column
-   :margin-left     6})
+   :flex-direction  :column})

 (def toolbar-title-text
   {:typography :title-bold


Specify outfile in argmap

Specify outfile in argmap

--- src/tailrecursion/boot/middleware/cljsbuild.clj
+++ src/tailrecursion/boot/middleware/cljsbuild.clj
@@ -17,18 +17,14 @@
    :foreign-libs  []
    :pretty-print  true})

-(defn tmpfile
-  [prefix postfix]
-  (doto (java.io.File/createTempFile prefix postfix) .deleteOnExit))
-
 (defn cljsbuild [handler]
-  (let [outf (mk ::js "_main.js")]
-    (fn [spec]
-      (let [cspec (merge dfl-opts (:cljsbuild spec))
-            outd  (or (:output-dir spec) (mkdir ::out))
-            srcs  (SourcePaths. (:source-paths cspec))
-            opts  (-> cspec
-                    (assoc :output-to (.getPath outf))
-                    (dissoc :source-paths))]
-        (cljs/build srcs opts)
-        (handler (assoc-in spec [:cljsbuild :output] outf))))))
+  (fn [spec]
+    (let [cspec (merge dfl-opts (:cljsbuild spec))
+          outf  (or (:output-to cspec) (mk ::js "main.js"))
+          outd  (or (:output-dir cspec) (mkdir ::out))
+          srcs  (SourcePaths. (:source-paths cspec))
+          opts  (-> cspec
+                  (assoc :output-to (.getPath outf))
+                  (dissoc :source-paths))]
+      (cljs/build srcs opts)
+      (handler (assoc-in spec [:cljsbuild :output] outf)))))


pass along the ns name to ensure-loaded

pass along the ns name to ensure-loaded

--- src/main/clojure/clojure/tools/analyzer/js.clj
+++ src/main/clojure/clojure/tools/analyzer/js.clj
@@ -292,7 +292,7 @@
 (def ^:private ^:dynamic *deps-map* {:path [] :deps #{}})
 (declare analyze-ns)

-(defn ensure-loaded [[ns {:keys [refer]}] env]
+(defn ensure-loaded [ns {:keys [refer]} env]
   (assert (not (contains? (:deps *deps-map*) ns))
           (str "Circular dependency detected :" (conj (:path *deps-map*) ns)))
   (binding [*deps-map* (-> *deps-map*
@@ -323,7 +323,7 @@
                                     (assoc m as ns)
                                     m)) {} require)
         require-mappings (reduce (fn [m [ns {:keys [refer] :as spec}]]
-                                   (ensure-loaded spec env)
+                                   (ensure-loaded ns spec env)
                                    ;; TODO: handle (:require [goog.lib :refer [things]]) ?
                                    (reduce #(assoc %1 %2 (get-in (env/deref-env)
                                                                  [:namespaces ns :mappings %2])) m refer))


Remove debug log

Remove debug log

--- src/main/clojure/pdok/featured/json_reader.clj
+++ src/main/clojure/pdok/featured/json_reader.clj
@@ -102,7 +102,6 @@
     (Integer. srid)))

 (defn create-geometry-atrribute [geometry]
-  (println "Geometry: " geometry)
   (if-let [type (get geometry "type")]
     (GeometryAttribute. type (get geometry type) (get-valid-srid geometry))))


lein-release plugin: bumped version from 0.1.4 to 0.1.5-SNAPSHOT for next development cycle

--- re-frame-simple/project.clj
+++ re-frame-simple/project.clj
@@ -1,4 +1,4 @@
-(defproject re-view/re-frame-simple "0.1.4"
+(defproject re-view/re-frame-simple "0.1.5-SNAPSHOT"

   :description "re-view syntax for re-frame"


Added log-simple!

Added log-simple!

--- src/clj/clongra/core/log.clj
+++ src/clj/clongra/core/log.clj
@@ -58,21 +58,17 @@
          level msg)))

-;; (defn- ^String log-message
-;;   [level msgs]
-;;   (let [now (.toString (joda) "Y-MM-d H:mm:ss,SSS")
-;;         ^StackTraceElement frame (current-stack-frame 3)
-;;         file (.getFileName frame)
-;;         line (.getLineNumber frame)
-;;         th (.. Thread currentThread getName)]
-
-;;     (str now
-;;          (when level (str " " level))
-;;          " [" th "] " file ":" line " " (apply tstr-spaced msgs))))
-
 (defn- ^String log-message
   [level msgs]
-  (str (when level (str level " ")) (apply tstr-spaced msgs)))
+  (let [now (.toString (joda) "Y-MM-d H:mm:ss,SSS")
+        ^StackTraceElement frame (current-stack-frame 3)
+        file (.getFileName frame)
+        line (.getLineNumber frame)
+        th (.. Thread currentThread getName)]
+
+    (str now
+         (when level (str " " level))
+         " [" th "] " file ":" line " " (apply tstr-spaced msgs))))

 ;; LOGGING LEVELS
@@ -112,6 +108,13 @@
                  (log-message "DEBUG" more))))

+(defn log-simple!
+  [& more]
+  (when (logged?)
+    (invoke-log! org.apache.logging.log4j.Level/DEBUG
+                 (apply tstr-spaced more))))
+
+
 (defn log-trace!
   [& more]
   (when (logged?)


slight reformat in hdf.

slight reformat in hdf.

--- src/clj/forma/source/hdf.clj
+++ src/clj/forma/source/hdf.clj
@@ -136,11 +136,14 @@
  and returns a 2-tuple consisting of the modis-subsets key (\"ndvi\")
   and a gdal.Dataset object representing the unpacked MODIS data."
   [path]
-  [(name (subdataset-key path)) (gdal/Open path)])
+  [(name (subdataset-key path))
+   (gdal/Open path)])

 ;; This is the first real "director" function; cascalog calls feeds
 ;; `BytesWritable` objects into `unpack-modis` and receives individual
 ;; datasets back.
+
+;; TODO: Update documentation with return value.

 (defmapcatop [unpack-modis [to-keep]]
   "Stateful approach to unpacking HDF files. Registers all gdal
@@ -176,9 +179,9 @@
         height (.GetYSize band)
         ret (int-array (* width height))]
     (.ReadRaster band 0 0 width height ret)
-    (->> ret
-         (partition chunk-size)
-         (map-indexed (fn [idx xs] [idx (vec xs)])))))
+    (map-indexed (fn [idx xs]
+                   [idx (vec xs)])
+                 (partition chunk-size ret))))

 ;; ### Metadata Parsing
 ;;
@@ -245,8 +248,8 @@
   (let [keys ["SHORTNAME" "TileID" "RANGEBEGINNINGDATE"]
         chunkifier (p/chunkify chunk-size)]
     (<- [?datachunk]
-        (source ?filename ?hdf)
-        (unpack-modis [datasets] ?hdf :> ?dataset ?freetile)
+        (source _ ?hdf)
+        (unpack-modis  [datasets] ?hdf :> ?dataset ?freetile)
         (raster-chunks [chunk-size] ?freetile :> ?chunkid ?chunk)
         (meta-values [keys] ?freetile :> ?productname ?tileid ?date)
         (split-id ?tileid :> ?mod-h ?mod-v)


adjust to geschichte middleware

adjust to geschichte middleware

--- src/clj/lesezeichen/core.clj
+++ src/clj/lesezeichen/core.clj
@@ -10,7 +10,9 @@
             [geschichte.meta :refer [update]]
             [geschichte.sync :refer [server-peer client-peer]]
             [geschichte.platform :refer [create-http-kit-handler!]]
-            [geschichte.auth :refer [auth]]
+            [geschichte.p2p.auth :refer [auth]]
+            [geschichte.p2p.fetch :refer [fetch]]
+            [geschichte.p2p.publish-on-request :refer [publish-on-request]]
             [konserve.store :refer [new-mem-store]]
             [konserve.platform :refer [new-couch-store]]
             [compojure.handler :refer [site api]]
@@ -73,7 +75,8 @@
                               "/geschichte/ws")
                          tag-table)
                         store
-                        (partial auth store auth-fn cred-fn (atom (or (:trusted-hosts @state) #{}))))))
+                        (comp (partial publish-on-request store)
+                              (partial fetch store)))))
   state)

 (defroutes handler


Added allowance from www.movementsession.com

--- src/clj/movement/handler.clj
+++ src/clj/movement/handler.clj
@@ -15,5 +15,6 @@

 (def app
   (let [handler (wrap-frame-options (wrap-defaults routes site-defaults)
-                                    {:allow-from "http://movementsession.com"})]
+                                    {:allow-from (or "http://movementsession.com"
+                                                     "http://www.movementsession.com")})]
     (if (env :dev?) (wrap-reload (wrap-exceptions handler)) handler)))


Use non minified versions when in debug

Use non minified versions when in debug

--- src/clj/subman/web/views.clj
+++ src/clj/subman/web/views.clj
@@ -6,27 +6,42 @@
 (defn index-page []
   (let [is-debug (env :is-debug)]
     (html5 [:head
-            [:link {:rel "icon"
+            [:link {:rel  "icon"
                     :type "image/png"
                     :href (first (make-static "favicon.png"))}]
             [:link {:type "application/opensearchdescription+xml"
-                    :rel "search"
+                    :rel  "search"
                     :href (first (make-static "opensearch.xml"))}]
             [:title "Subman - subtitle search service"]
-            (as-static include-css
-                       "components/bootstrap/dist/css/bootstrap.min.css"
-                       "components/bootstrap/dist/css/bootstrap-theme.min.css"
-                       "components/font-awesome/css/font-awesome.min.css"
-                       "components/typeahead.js-bootstrap3.less/typeahead.css"
-                       "main.css")
-            (as-static include-js
-                       "components/jquery/dist/jquery.min.js"
-                       "components/bootstrap/dist/js/bootstrap.min.js"
-                       "components/typeahead.js/dist/typeahead.jquery.min.js"
-                       "components/react/react.min.js")
+            (when-not is-debug
+              (as-static include-css
+                         "components/bootstrap/dist/css/bootstrap.min.css"
+                         "components/bootstrap/dist/css/bootstrap-theme.min.css"
+                         "components/font-awesome/css/font-awesome.min.css"
+                         "components/typeahead.js-bootstrap3.less/typeahead.css"
+                         "main.css"))
+            (when-not is-debug
+              (as-static include-js
+                         "components/jquery/dist/jquery.min.js"
+                         "components/bootstrap/dist/js/bootstrap.min.js"
+                         "components/typeahead.js/dist/typeahead.jquery.min.js"
+                         "components/react/react.min.js"
+                         "main.js"))
             (when is-debug
-              (as-static include-js "cljs-target/goog/base.js"))
-            (as-static include-js "main.js")
+              (as-static include-css
+                         "components/bootstrap/dist/css/bootstrap.css"
+                         "components/bootstrap/dist/css/bootstrap-theme.css"
+                         "components/font-awesome/css/font-awesome.css"
+                         "components/typeahead.js-bootstrap3.less/typeahead.css"
+                         ;"main.css"
+                         ))
             (when is-debug
-              [:script "goog.require('subman.core');"])]
+              (as-static include-js
+                         "components/jquery/dist/jquery.js"
+                         "components/bootstrap/dist/js/bootstrap.js"
+                         "components/typeahead.js/dist/typeahead.jquery.js"
+                         "components/react/react.js"
+                         "cljs-target/goog/base.js"
+                         "main.js"))
+            [:script "goog.require('subman.core');"]]
            [:body [:script "subman.core.run();"]])))


Interpolation working.

Interpolation working.

--- src/clj/triangulate/core.clj
+++ src/clj/triangulate/core.clj
@@ -20,8 +20,8 @@

 (defn haversine [a b]
   (let [lat1 (:lat a)
+        lon1 (:long a)
         lat2 (:lat b)
-        lon1 (:long a)
         lon2 (:long b)
         R 6372800
         dlat (Math/toRadians (- lat2 lat1))
@@ -33,32 +33,21 @@
                 (Math/cos lat1) (Math/cos lat2)))]
     (* R 2 (Math/asin (Math/sqrt a)))))

-(defn bearing [a b]
+(defn interpolate-coordinates [a b c d]
   (let [lat1 (:lat a)
+        lon1 (:long a)
         lat2 (:lat b)
-        lon1 (:long a)
         lon2 (:long b)
-        rlat-1 (Math/toRadians lat1)
-        rlat-2 (Math/toRadians lat2)
-        diff (Math/toRadians (- lon2 lon1))
-        y (* (Math/sin diff) (Math/cos rlat-2))
-        x (- (* (Math/cos rlat-1) (Math/sin rlat-2))
-             (* (Math/sin rlat-1) (Math/cos rlat-2) (Math/cos diff)))]
-    (mod (Math/toDegrees (+ (Math/atan2 y x) 360)) 360)))
-
-(defn interpolate-coordinates [a d bearing]
-  (let [lat-1 (:lat a)
-        long-1 (:long a)
-        r 6372800
-        lat-2 (Math/asin (+ (* (Math/sin lat-1)
-                               (Math/cos (/ d r)))
-                            (* (Math/cos lat-1)
-                               (Math/sin (/ d r))
-                               (Math/cos bearing))))
-        long-2 (+ long-1
-                  (Math/atan2 (* (Math/sin bearing) (Math/sin (/ d r)) (Math/cos lat-1))
-                              (- (Math/cos (/ d r)) (* (Math/sin lat-1) (Math/sin lat-2)))))]
-    {:lat lat-2 :long long-2}))
+        lat-diff (- lat2 lat1)
+        lon-diff (- lon2 lon1)
+        theta (Math/atan (/ lon-diff lat-diff))
+        x1 (* (Math/cos theta) d)
+        y1 (* (Math/sin theta) d)
+        x2 (* (Math/cos theta) c)
+        y2 (* (Math/sin theta) c)
+        x-ratio (* (/ x1 x2) lat-diff)
+        y-ratio (* (/ y1 y2) lon-diff)]
+    {:lat (+ lat1 x-ratio) :long (+ lon1 y-ratio)}))

 (defn take-segments
   ([segments distance] (take-segments segments distance 0 0))
@@ -87,13 +76,12 @@

 (def front-coordinate (nth coordinates front-segment))

-(def vehicle-bearing (bearing front-coordinate back-coordinate))
-
 (def distance-to-front-segment (- back-distance meters-away))

-;(pprint coordinates)
+(def target-to-front-segment (- meters-away front-distance))

-(interpolate-coordinates front-coordinate distance-to-front-segment vehicle-bearing)
+;;(pprint coordinates)
+

 (defroutes routes
   (POST "/rush-hour/api/triangulate/edn" {:keys [body]}


refine path building logic

refine path building logic

--- src/cljs/clj_money/data.cljs
+++ src/cljs/clj_money/data.cljs
@@ -14,9 +14,9 @@

 (defn- path
   [& segments]
-  (str "/api/" (->> segments
-                    (map stringify)
-                    (string/join "/"))))
+  (->> (concat [:api] segments)
+       (map stringify)
+       (string/join "/")))

 (defn get-entities
   [callback]


Add basic command stream input handling

Add basic command stream input handling

--- src/cljs/cljs_game/core.cljs
+++ src/cljs/cljs_game/core.cljs
@@ -4,6 +4,35 @@
 (enable-console-print!)

 (def world (atom {}))
+
+(def command-queue (atom cljs.core/PersistentQueue.EMPTY))
+
+(defn handle-input [event]
+  (let [key (.-key event)]
+    (swap! command-queue conj
+           (case key
+             "w" {:type :input :key :up}
+             "a" {:type :input :key :left}
+             "s" {:type :input :key :down}
+             "d" {:type :input :key :right}
+             "p" {:type :input :key :pause}))
+    (when (not (.-repeat event))
+      (print (.-repeat event)))))
+
+(defn process-input []
+  (loop [attempts 10]
+    (let [command (peek @command-queue)]
+      (if command
+        ;; change? What if somethign else pops between above and below
+        ;; have function check if peek and item are same item, yay! then do pop
+        ;; else, recur w/o doing anything to try again.
+        (do (swap! command-queue pop)
+            (print command)
+            (when (and (= (command :type) :input)
+                       (= (command :key) :pause))
+              (swap! world assoc :running
+                     (not (@world :running))))
+            (recur (dec attempts)))))))

 (defn update-world
   [delta-time]
@@ -18,14 +47,14 @@
         leftover-time (@world :accum-time)
         time-step 16.666666666666668]
     (swap! world assoc :prev-time now)
-    (swap! world assoc :leftover-time
-           (loop [accumulated (+ leftover-time (- now prev))]
-             (if (>= accumulated time-step)
-               (do (update-world time-step)
-                   (recur (- accumulated time-step)))
-               accumulated)))
-    (js/requestAnimationFrame game-loop)))
-
+    (process-input)
+    (when (@world :running)
+      (swap! world assoc :leftover-time
+             (loop [accumulated (+ leftover-time (- now prev))]
+               (if (>= accumulated time-step)
+                 (do (update-world time-step)
+                     (recur (- accumulated time-step)))
+                 accumulated))))))

 (defn ^:export init-game
   []
@@ -45,6 +74,7 @@
     (.add scene light2)
     (.setSize renderer js/window.innerWidth js/window.innerHeight)
     (js/document.body.appendChild (.-domElement renderer))
+    (js/document.addEventListener "keydown" handle-input)
     (swap! world assoc :prev js/Performance.now)
     (swap! world assoc :accum-time 0.0)
     (let [animate (fn animate [current-time]


Invalid spreadsheet columns modal

Invalid spreadsheet columns modal

--- src/cljs/db_quiz/modals.cljs
+++ src/cljs/db_quiz/modals.cljs
@@ -43,7 +43,7 @@
   (modal
     [:div
      [:h2 "Jak má tabulka vypadat?"]
-     [:p "Tabulka musí mít 2 sloupce, záhlaví a alespoň tolik řádků, kolik je hracích políček. Název prvního sloupce je 'Label', druhý sloupec je pojmenován 'Description'. V prvním sloupci jsou názvy hádaných věcí, zatímco v druhém sloupci je otázka popisující hádanou věc."]
+     [:p "Tabulka musí mít 2 sloupce, záhlaví a alespoň tolik řádků, kolik je hracích políček. Ve sloupci pojmenovaném 'Label' jsou názvy hádaných věcí, zatímco ve sloupci se jménem 'Description' jsou otázky popisující hádanou věc."]
      [:h2 "Jak tabulku publikovat?"]
      [:p "Zvolte 'File' \u2192 'Publish to the web...' \u2192 'Publish'."]]))

@@ -64,6 +64,9 @@
           [:ul (for [error errors]
                  [:li {:key error} error])]]))

+(def invalid-spreadsheet-columns
+  (modal [:div "Sloupce v tabulce nejsou správně pojmenovány. Sloupec s hádanou věcí musí nést jméno 'Label', zatímco sloupec s otázkou je pojmenován 'Description'."]))
+
 (defn invalid-spreadsheet-rows
   [actual]
   {:pre [(pos-number? actual)]}


The unwrapping of the stacktrace is not necessary anymore.

--- src/cljs/replumb/common.cljs
+++ src/cljs/replumb/common.cljs
@@ -35,7 +35,7 @@
             (string/join " - " strings)
             "Error"))
         (when print-stack?
-          (str "\n" (string/join "\n" (string/split-lines (.-stack err))))))))
+          (str "\n" (.-stack err))))))

 (defn echo-callback
   "Callback that just echoes the result map. It also asserts the correct


Remove magic number again.

Remove magic number again.

--- src/cljs/reversi/phaser.cljs
+++ src/cljs/reversi/phaser.cljs
@@ -7,8 +7,10 @@
 (def ^:dynamic *visible-possible-grids-pos* '())
 (def ^:dynamic *default-player-piece* rcore/*black-piece*)
 (def ^:dynamic *default-pc-piece* rcore/*white-piece*)
-(def ^:dynamic *phaser-width* 905)
-(def ^:dynamic *phaser-height* 605)
+(def ^:dynamic *phaser-width* 905)      ;; 300x605 let show piece count information
+(def ^:dynamic *phaser-height* 605)     ;; 605x605 is reversi border
+(def ^:dynamic *phaser-border-width* 605)
+(def ^:dynamic *phaser-border-height* 605)
 (def ^:dynamic *game* (js/Phaser.Game.
                        *phaser-width* *phaser-height*
                        js/Phaser.AUTO "game_div"))
@@ -202,7 +204,7 @@
     (set! (.-restartButton game) restart-button)))

 (def ^:dynamic *assets-table*
-   ;name    path
+  ;; name    path
   [["border"         "assets/reversi-border.png"]
    ["white-piece"    "assets/white-piece.png"]
    ["black-piece"    "assets/black-piece.png"]
@@ -225,7 +227,9 @@

 (defn create [game]
   (set! (.-backgroundColor (.-stage game)) "#ffffff")
-  (.tileSprite (.-add game) 0 0 605 605 "border")
+  (.tileSprite (.-add game) 0 0
+               *phaser-border-width*
+               *phaser-border-height* "border")
   (create-possible-grids "possible-grid" game)
   (create-all-pieces "white-piece" "black-piece" game)
   (create-text game)
@@ -234,11 +238,11 @@

 (defn ^export start [game]
   (init-phaser game)
-    (.add (.-state game) "main"
-          (clj->js {:preload preload
-                    :create create
-                    }))
-    (.start (.-state game) "main"))
+  (.add (.-state game) "main"
+        (clj->js {:preload preload
+                  :create create
+                  }))
+  (.start (.-state game) "main"))

 (defprotocol Functor
   (restart [this]))


ideas

ideas

--- src/cljs/triboard/ai/ai.cljs
+++ src/cljs/triboard/ai/ai.cljs
@@ -57,14 +57,11 @@
 ;; Public API
 ;; -----------------------------------------

-(s/fdef best-move
+(s/fdef play-best-move
   :args (s/tuple ::game ::player/player)
-  :ret ::board/coord)
+  :ret :game)

-(defn best-move
-  "[SIMPLISTIC] Return the best move for a player based on:
-   * The immediate gain
-   * The worse immediate lost afterwards"
+(defn- best-move                                            ;; TODO - Compute games directly...
   [game player]
   (let [game-state (game/current-state game)
         ai (make-ai (:board game-state) player)]
@@ -74,5 +71,8 @@
       )))

 (defn play-best-move
+  "[SIMPLISTIC] Play the best move for a player based on:
+   * The immediate gain
+   * The worse immediate lost afterwards"
   [game player]
   (game/play-move game (best-move game player)))


Simplify async socket constructo on nanomsg.impl ns.

--- src/clojure/nanomsg/impl.clj
+++ src/clojure/nanomsg/impl.clj
@@ -45,29 +45,30 @@
       (fail [_ throwable]))))

 (defn async-socket
-  [^Socket socket ^AsyncSocket asocket]
-  (reify
-    proto/IAsyncSocket
-    proto/ISocket
-    (bind [_ endpoint]
-      (.bind socket endpoint))
-    (connect [_ endpoint]
-      (.connect socket endpoint))
-    (subscribe [_ topic]
-      (.subscribe socket topic))
-    (unsubscribe [_ topic]
-      (.unsubscribe socket topic))
-    (send [_ data opt]
-      (let [cb (create-callback opt)
-            data (proto/get-byte-buffer data)]
-        (.send asocket data cb)))
-    (recv [_ opt]
-      (let [cb (create-callback opt)]
-        (.recv asocket cb)))
+  [^Socket socket]
+  (let [^AsyncSocket asocket (AsyncSocket. socket)]
+    (reify
+      proto/IAsyncSocket
+      proto/ISocket
+      (bind [_ endpoint]
+        (.bind socket endpoint))
+      (connect [_ endpoint]
+        (.connect socket endpoint))
+      (subscribe [_ topic]
+        (.subscribe socket topic))
+      (unsubscribe [_ topic]
+        (.unsubscribe socket topic))
+      (send [_ data opt]
+        (let [cb (create-callback opt)
+              data (proto/get-byte-buffer data)]
+          (.send asocket data cb)))
+      (recv [_ opt]
+        (let [cb (create-callback opt)]
+          (.recv asocket cb)))

-    java.io.Closeable
-    (close [_]
-      (.close socket))))
+      java.io.Closeable
+      (close [_]
+        (.close socket)))))

 (defn blocking-socket
   [^Socket socket]


event value

event value

--- src/clojure/nossal/data.cljc
+++ src/clojure/nossal/data.cljc
@@ -73,7 +73,7 @@
                                           :event_category "coupons"`
                                           :event_name "get-coupon"
                                           :event_label "${coupon}"
-                                          :event_value "${coupon-value}"
+                                          :value "${coupon-value}"
                                           :method "${coupon}"}}
               :trackClickOnPI {:on "click"
                                :selector "a#tnet"


every batch of 300, dump thread ids.

every batch of 300, dump thread ids.

--- src/clueweb_disqus/posts.clj
+++ src/clueweb_disqus/posts.clj
@@ -193,7 +193,9 @@

         deja-downloaded-file (string/replace thread-ids-file
                                              #".threads$"
-                                             ".downloaded")]
+                                             ".downloaded")
+
+        deja-downloaded-wrtr (io/writer deja-downloaded-file :append true)]
     (if-not (.exists
              (io/as-file file-to-write))

@@ -214,18 +216,14 @@
                                   file-to-write
                                   (get-api-key-for-start-epoch
                                    credentials
-                                   (Long/parseLong associated-epoch))))
+                                   (Long/parseLong associated-epoch)))
+                  (binding [*out* deja-downloaded-wrtr]
+                    (println thread-id)
+                    (flush)))

                 ;; rename back the file
                 (.rename (io/as-file file-to-write)
-                         (io/as-file final-file))
-
-                ;; now record the download thread-ids
-                (with-open [wrtr (io/writer deja-downloaded-file :append true)]
-                  (doall
-                   (doseq [thread-id thread-ids]
-                     (binding [*out* wrtr]
-                       (println thread-id))))))))
+                         (io/as-file final-file)))))

       (println :crawl-in-progress))))


updated transactional topology tests to new behavior


doplnil jsem testy pro akci scp-to-kramerius edeposit/edeposit#555

--- test/edeposit/amqp/kramerius/handlers_test.clj
+++ test/edeposit/amqp/kramerius/handlers_test.clj
@@ -5,11 +5,15 @@
             [clojure.java.io :as io]
             [clojure.pprint :as pp]
             [clojure.data.xml :as xml]
+            [clojure.xml :as x]
             [clojure.zip :as zip]
             [clojure.data.zip.xml :as zx]
             [clojure.java.shell :as shell]
             [edeposit.amqp.kramerius.xml.utils :as u]
             [clojurewerkz.serialism.core :as s]
+            [clj-time.local :as lt]
+            [clj-time.coerce :as tc]
+            [clj-time.core :as t]
             )
   )

@@ -36,53 +40,54 @@
           ]
       (is (.exists tmpdir))
       (is (= tmpdir result))
-      (is (.exists (io/file tmpdir "payload.bin")))
-      (is (.exists (io/file tmpdir "metadata.clj")))
-
-      (is (.exists (io/file tmpdir "payload")))
-      (is (.exists (io/file tmpdir "payload" "uuid")))
-      (is (.exists (io/file tmpdir "payload" "aleph_id")))
-      (is (.exists (io/file tmpdir "payload" "isbn")))
-      (is (.exists (io/file tmpdir "payload" "urnnbn")))
-      (is (.exists (io/file tmpdir "payload" "edeposit-url.txt")))
-      (is (.exists (io/file tmpdir "payload" "location-at-kramerius")))
-      (is (.exists (io/file tmpdir "payload" "is-private")))
-      (is (.exists (io/file tmpdir "payload" "oai_marc.xml")))
-      (is (.exists (io/file tmpdir "payload" "oai_marc.xml.b64")))
-
-      (is (.exists (io/file tmpdir "payload" "first-page")))
-      (is (.exists (io/file tmpdir "payload" "first-page" "robotandbaby_001.jp2")))
-      (is (.exists (io/file tmpdir "payload" "first-page" "mimetype")))
-      (is (.exists (io/file tmpdir "payload" "first-page" "filename")))
-
-      (is (.exists (io/file tmpdir "payload" "original")))
-      (is (.exists (io/file tmpdir "payload" "original" "storage_path")))
-      (is (.exists (io/file tmpdir "payload" "original" "mimetype")))
-      (is (.exists (io/file tmpdir "payload" "original" "filename")))
-
-      (is (= (fs/size (io/file tmpdir "payload" "oai_marc.xml"))
+      (is (.exists (io/file tmpdir "request")))
+      (is (.exists (io/file tmpdir "request" "payload.bin")))
+      (is (.exists (io/file tmpdir "request" "metadata.clj")))
+
+      (is (.exists (io/file tmpdir "request" "payload")))
+      (is (.exists (io/file tmpdir "request" "payload" "uuid")))
+      (is (.exists (io/file tmpdir "request" "payload" "aleph_id")))
+      (is (.exists (io/file tmpdir "request" "payload" "isbn")))
+      (is (.exists (io/file tmpdir "request" "payload" "urnnbn")))
+      (is (.exists (io/file tmpdir "request" "payload" "edeposit-url.txt")))
+      (is (.exists (io/file tmpdir "request" "payload" "location-at-kramerius")))
+      (is (.exists (io/file tmpdir "request" "payload" "is-private")))
+      (is (.exists (io/file tmpdir "request" "payload" "oai_marc.xml")))
+      (is (.exists (io/file tmpdir "request" "payload" "oai_marc.xml.b64")))
+
+      (is (.exists (io/file tmpdir "request" "payload" "first-page")))
+      (is (.exists (io/file tmpdir "request" "payload" "first-page" "robotandbaby_001.jp2")))
+      (is (.exists (io/file tmpdir "request" "payload" "first-page" "mimetype")))
+      (is (.exists (io/file tmpdir "request" "payload" "first-page" "filename")))
+
+      (is (.exists (io/file tmpdir "request" "payload" "original")))
+      (is (.exists (io/file tmpdir "request" "payload" "original" "storage_path")))
+      (is (.exists (io/file tmpdir "request" "payload" "original" "mimetype")))
+      (is (.exists (io/file tmpdir "request" "payload" "original" "filename")))
+
+      (is (= (fs/size (io/file tmpdir "request" "payload" "oai_marc.xml"))
              (fs/size (io/file "resources" "oai_marc.xml"))))

       (is (= "e65d9072-2c9b-11e5-99fd-b8763f0a3d61"
-             (slurp (io/file tmpdir "payload" "uuid"))))
+             (slurp (io/file tmpdir "request" "payload" "uuid"))))

       (is (= "urn:nbn:cz:mzk-0005ol"
-             (slurp (io/file tmpdir "payload" "urnnbn"))))
+             (slurp (io/file tmpdir "request" "payload" "urnnbn"))))

       (is (= "80-251-0225-4"
-             (slurp (io/file tmpdir "payload" "isbn"))))
+             (slurp (io/file tmpdir "request" "payload" "isbn"))))

       (is (= "cnb001492461"
-             (slurp (io/file tmpdir "payload" "aleph_id"))))
+             (slurp (io/file tmpdir "request" "payload" "aleph_id"))))

       (is (= "/monografie/2001/John McCarthy/Robot and Baby"
-             (slurp (io/file tmpdir "payload" "location-at-kramerius"))))
+             (slurp (io/file tmpdir "request" "payload" "location-at-kramerius"))))

       (is (= "robotandbaby_001.jp2"
-             (slurp (io/file tmpdir "payload" "first-page" "filename"))))
+             (slurp (io/file tmpdir "request" "payload" "first-page" "filename"))))

       (is (= "image/jp2"
-             (slurp (io/file tmpdir "payload" "first-page" "mimetype"))))
+             (slurp (io/file tmpdir "request" "payload" "first-page" "mimetype"))))
       (fs/delete-dir tmpdir)
       )
     )
@@ -114,10 +119,10 @@
        (h/save-request [[:no-metadata payload] tmpdir])
        (h/prepare-marcxml2mods-request tmpdir)

-       (let [ metadata (-> (slurp "resources/marcxml2mods-response-metadata.clj")
+       (let [ metadata (-> (slurp "resources/communication-with-marcxml2mods/response/metadata.clj")
                            read-string
                            (update-in [:headers] assoc "UUID" (.toString tmpdir)))
-             payload (slurp "resources/marcxml2mods-response-payload.json")
+             payload (slurp "resources/communication-with-marcxml2mods/response/payload.json")
              [mods_files response-dir] (-> [metadata payload]
                                            h/save-marcxml2mods-response)
              ]
@@ -140,10 +145,10 @@
            ]
       (h/save-request [[:no-metadata payload] tmpdir])
       (h/prepare-marcxml2mods-request tmpdir)
-      (let [ metadata (-> (slurp "resources/marcxml2mods-response-metadata.clj")
+      (let [ metadata (-> (slurp "resources/communication-with-marcxml2mods/response/metadata.clj")
                            read-string
                            (update-in [:headers] assoc "UUID" (.toString tmpdir)))
-             payload (slurp "resources/marcxml2mods-response-payload.json")
+             payload (slurp "resources/communication-with-marcxml2mods/response/payload.json")
              [mods response-dir] (-> [metadata payload]
                                            h/save-marcxml2mods-response
                                            h/parse-mods-files
@@ -183,10 +188,10 @@
            ]
       (h/save-request [[:no-metadata payload] tmpdir])
       (h/prepare-marcxml2mods-request tmpdir)
-      (let [ metadata (-> (slurp "resources/marcxml2mods-response-metadata.clj")
+      (let [ metadata (-> (slurp "resources/communication-with-marcxml2mods/response/metadata.clj")
                           read-string
                           (update-in [:headers] assoc "UUID" (.toString tmpdir)))
-            payload (slurp "resources/marcxml2mods-response-payload.json")
+            payload (slurp "resources/communication-with-marcxml2mods/response/payload.json")
             [mods response-dir] (-> [metadata payload]
                                     h/save-marcxml2mods-response
                                     h/parse-mods-files
@@ -213,8 +218,8 @@

      (h/save-request  [[nil payload] tmpdir])

-     (let [ metadata (read-string (slurp "resources/marcxml2mods-response-metadata.clj"))
-           payload (slurp "resources/marcxml2mods-response-payload.json")
+     (let [ metadata (read-string (slurp "resources/communication-with-marcxml2mods/response/metadata.clj"))
+           payload (slurp "resources/communication-with-marcxml2mods/response/payload.json")
            actual-metadata (-> metadata (assoc :headers
                                                (-> metadata :headers (assoc "UUID" (.toString tmpdir)))))

@@ -253,10 +258,10 @@
            tmpdir (fs/temp-dir "test-export-to-kramerius-request-")]
       (h/save-request [[:no-metadata payload] tmpdir])
       (h/prepare-marcxml2mods-request tmpdir)
-      (let [ metadata (-> (slurp "resources/marcxml2mods-response-metadata.clj")
+      (let [ metadata (-> (slurp "resources/communication-with-marcxml2mods/response/metadata.clj")
                           read-string
                           (update-in [:headers] assoc "UUID" (.toString tmpdir)))
-            payload (slurp "resources/marcxml2mods-response-payload.json")
+            payload (slurp "resources/communication-with-marcxml2mods/response/payload.json")
             [mods mods-tmpdir] (-> [metadata payload]
                                     h/save-marcxml2mods-response
                                     h/parse-mods-files
@@ -280,17 +285,17 @@

         (let [loc (-> (io/file result-dir (str uuid ".xml"))
                       io/input-stream
-                      xml/parse
+                      x/parse
                       zip/xml-zip
                       )]
-          (let [ref (zx/xml1-> loc :datastream [(zx/attr= :ID "IMG_FULL")]
-                               :datastreamVersion :contentLocation (zx/attr :REF))
-                storage_path (slurp (io/file tmpdir "payload" "original" "storage_path"))]
+          (let [ref (zx/xml1-> loc :foxml:datastream [(zx/attr= :ID "IMG_FULL")]
+                               :foxml:datastreamVersion :foxml:contentLocation (zx/attr :REF))
+                storage_path (slurp (io/file tmpdir "request" "payload" "original" "storage_path"))]
             (is (= ref (str "file:" storage_path))))
-          (let [ref (zx/xml1-> loc :datastream [(zx/attr= :ID "IMG_PREVIEW")]
-                               :datastreamVersion :contentLocation (zx/attr :REF))
-                filename (slurp (io/file tmpdir "payload" "first-page" "filename"))]
-            (is (=  ref (str "file:" filename)))
+          (let [ref (zx/xml1-> loc :foxml:datastream [(zx/attr= :ID "IMG_PREVIEW")]
+                               :foxml:datastreamVersion :foxml:contentLocation (zx/attr :REF))
+                filename (slurp (io/file tmpdir "request" "payload" "first-page" "filename"))]
+            (is (=  ref (str "file:first-page/" filename)))
             )
           )
         )
@@ -305,10 +310,10 @@
            tmpdir (fs/temp-dir "test-export-to-kramerius-request-")]
       (h/save-request [[:no-metadata payload] tmpdir])
       (h/prepare-marcxml2mods-request tmpdir)
-      (let [ metadata (-> (slurp "resources/marcxml2mods-response-metadata.clj")
+      (let [ metadata (-> (slurp "resources/communication-with-marcxml2mods/response/metadata.clj")
                           read-string
                           (update-in [:headers] assoc "UUID" (.toString tmpdir)))
-            payload (slurp "resources/marcxml2mods-response-payload.json")
+            payload (slurp "resources/communication-with-marcxml2mods/response/payload.json")
             [mods mods-tmpdir] (-> [metadata payload]
                                     h/save-marcxml2mods-response
                                     h/parse-mods-files
@@ -337,10 +342,10 @@
            tmpdir (fs/temp-dir "test-export-to-kramerius-request-")]
       (h/save-request [[:no-metadata payload] tmpdir])
       (h/prepare-marcxml2mods-request tmpdir)
-      (let [ metadata (-> (slurp "resources/marcxml2mods-response-metadata.clj")
+      (let [ metadata (-> (slurp "resources/communication-with-marcxml2mods/response/metadata.clj")
                           read-string
                           (update-in [:headers] assoc "UUID" (.toString tmpdir)))
-            payload (slurp "resources/marcxml2mods-response-payload.json")
+            payload (slurp "resources/communication-with-marcxml2mods/response/payload.json")
             [mods mods-tmpdir] (-> [metadata payload]
                                     h/save-marcxml2mods-response
                                     h/parse-mods-files
@@ -359,7 +364,7 @@
         (is (.isDirectory (io/file request-workdir "export-to-storage" "request")))

         (let [zip-file-b64 (io/file request-workdir
-                                    (str (slurp (io/file tmpdir "payload" "uuid")) ".zip" ".b64"))]
+                                    (str (slurp (io/file tmpdir "request" "payload" "uuid")) ".zip" ".b64"))]
           (is (.exists zip-file-b64))
           (let [request-dir (io/file request-workdir "export-to-storage" "request")
                 deserialized-metadata (s/deserialize (slurp (io/file request-dir "metadata.clj"))
@@ -380,3 +385,152 @@
       )
     )
   )
+
+(deftest save-response-from-storage-test
+  (testing "save response from storage test"
+    (let [workdir (fs/temp-dir "test-export-to-kramerius-storage-response-")
+          payload (.getBytes (slurp "resources/communication-with-storage/response/payload.bin"))
+          metadata (-> (slurp "resources/communication-with-storage/response/metadata.clj")
+                       read-string
+                       (update-in [:headers] assoc "UUID" (.toString workdir)))]
+      (let [ [msg response-workdir] (h/save-response-from-export-to-storage metadata payload)]
+        (is (= workdir response-workdir))
+        (is (.exists (io/file response-workdir)))
+        (is (.exists (io/file response-workdir "export-to-storage")))
+        (is (.exists (io/file response-workdir "export-to-storage" "response")))
+        (is (.exists (io/file response-workdir "export-to-storage" "response" "payload")))
+
+        (is (= "/monografie/01/02/aa-ofsdfasfs" (-> msg :dir_pointer)))
+        (is (= "e65d9072-2c9b-11e5-99fd-b8763f0a3d61" (-> msg :uuid)))
+        (is (= "cnb001492461" (-> msg :aleph_id)))
+        (is (= "80-251-0225-4" (-> msg :isbn)))
+        (is (= "" (-> msg :b64_data)))
+        )
+      (fs/delete-dir workdir)
+      )
+    )
+  )
+
+(deftest prepare-scp-to-kramerius-test
+  (testing "prepare scp to kramerius test"
+    (let     [payload (slurp "resources/export-request.json")
+              workdir (fs/temp-dir "test-export-to-kramerius-request-")]
+      (h/save-request [[:no-metadata payload] workdir])
+      (h/prepare-marcxml2mods-request workdir)
+      (let [ metadata (-> (slurp "resources/communication-with-marcxml2mods/response/metadata.clj")
+                          read-string
+                          (update-in [:headers] assoc "UUID" (.toString workdir)))
+            payload (slurp "resources/communication-with-marcxml2mods/response/payload.json")
+            [mods mods-tmpdir] (-> [metadata payload]
+                                   h/save-marcxml2mods-response
+                                   h/parse-mods-files
+                                   h/add-urnnbn-to-mods)
+            [oai_dcs oai-tmpdir] (-> [mods mods-tmpdir] h/mods->oai_dcs)
+            [_ _ request-workdir] (-> (h/make-package-with-foxml   [mods mods-tmpdir]
+                                                                   [oai_dcs oai-tmpdir]
+                                                                   workdir)
+                                      h/make-zip-package
+                                      h/prepare-request-for-export-to-storage)]
+        (let [payload (.getBytes (slurp "resources/communication-with-storage/response/payload.bin"))
+              metadata (-> (slurp "resources/communication-with-storage/response/metadata.clj")
+                           read-string
+                           (update-in [:headers] assoc "UUID" (.toString workdir)))]
+          (let [ [scp-workdir] (-> (h/save-response-from-export-to-storage metadata payload)
+                                   (h/prepare-scp-to-kramerius
+                                    :import-mount "/var/edeposit_import"
+                                    :archive-mount "/var/edeposit_archive"
+                                    :originals-mount "/var/edeposit_originals"))
+                 uuid (slurp (io/file workdir "request" "payload" "uuid"))]
+            (is (.exists (io/file scp-workdir)))
+            (is (.exists (io/file scp-workdir "scp-to-kramerius")))
+            (is (.exists (io/file scp-workdir "scp-to-kramerius" "dir_pointer")))
+            (is (.exists (io/file scp-workdir "scp-to-kramerius" "request")))
+            (is (.exists (io/file scp-workdir "scp-to-kramerius" "request" (str uuid ".xml"))))
+            (is (.exists (io/file scp-workdir "scp-to-kramerius" "request" "from")))
+            (is (= (.toString (io/file scp-workdir "scp-to-kramerius" "request" (str uuid ".xml")))
+                   (slurp  (io/file scp-workdir "scp-to-kramerius" "request" "from"))))
+
+            (is (.exists (io/file scp-workdir "scp-to-kramerius" "request" "to")))
+            (is (= (str "/var/edeposit_import/" uuid ".xml")
+                   (slurp (io/file scp-workdir "scp-to-kramerius" "request" "to"))))
+
+            (let [dir_pointer (slurp (io/file scp-workdir "scp-to-kramerius" "dir_pointer"))
+                  loc (-> (io/file scp-workdir "scp-to-kramerius" "request" (str uuid ".xml"))
+                          io/input-stream
+                          x/parse
+                          zip/xml-zip)]
+              (is (= "/monografie/01/02/aa-ofsdfasfs" dir_pointer))
+              (is (= (str "file:///var/edeposit_originals/monografie/01/01-robotandbaby.pdf")
+                     (zx/xml1-> loc :foxml:datastream [(zx/attr= :ID "IMG_FULL")]
+                                :foxml:datastreamVersion
+                                :foxml:contentLocation (zx/attr :REF))))
+              (is (= (str "file:///var/edeposit_archive" dir_pointer "/first-page/robotandbaby_001.jp2")
+                     (zx/xml1-> loc :foxml:datastream [(zx/attr= :ID "IMG_PREVIEW")]
+                                :foxml:datastreamVersion
+                                :foxml:contentLocation (zx/attr :REF))))
+              )
+            )
+          )
+        )
+      (fs/delete-dir workdir)
+      )
+    )
+  )
+
+(deftest scp-to-kramerius-test
+  (testing "scp to kramerius test"
+    (let     [local-now (lt/local-now)
+              payload (slurp "resources/export-request.json")
+              workdir (fs/temp-dir "test-export-to-kramerius-request-")]
+      (h/save-request [[:no-metadata payload] workdir])
+      (h/prepare-marcxml2mods-request workdir)
+      (let [ metadata (-> (slurp "resources/communication-with-marcxml2mods/response/metadata.clj")
+                          read-string
+                          (update-in [:headers] assoc "UUID" (.toString workdir)))
+            payload (slurp "resources/communication-with-marcxml2mods/response/payload.json")
+            [mods mods-tmpdir] (-> [metadata payload]
+                                   h/save-marcxml2mods-response
+                                   h/parse-mods-files
+                                   h/add-urnnbn-to-mods)
+            [oai_dcs oai-tmpdir] (-> [mods mods-tmpdir] h/mods->oai_dcs)
+            [_ _ request-workdir] (-> (h/make-package-with-foxml   [mods mods-tmpdir]
+                                                                   [oai_dcs oai-tmpdir]
+                                                                   workdir)
+                                      h/make-zip-package
+                                      h/prepare-request-for-export-to-storage)]
+        (let [payload (.getBytes (slurp "resources/communication-with-storage/response/payload.bin"))
+              metadata (-> (slurp "resources/communication-with-storage/response/metadata.clj")
+                           read-string
+                           (update-in [:headers] assoc "UUID" (.toString workdir)))]
+          (let [ [scp-workdir] (-> (h/save-response-from-export-to-storage metadata payload)
+                                   (h/prepare-scp-to-kramerius  :import-mount "/var/edeposit_import"
+                                                                :archive-mount "/var/edeposit_archive"
+                                                                :originals-mount "/var/edeposit_originals")
+                                   (h/scp-to-kramerius {:scp (fn [from-path to-path] (str from-path
+                                                                                "->"
+                                                                                to-path))})
+                                   )
+                 uuid (slurp (io/file workdir "request" "payload" "uuid"))]
+            (is (.exists (io/file scp-workdir)))
+            (let [response-dir (io/file scp-workdir "scp-to-kramerius" "response")]
+              (is (.exists response-dir))
+              (is (.exists (io/file response-dir "result")))
+              (is (.exists (io/file response-dir "sent")))
+              (let [result (slurp (io/file response-dir "result"))]
+                (is (re-find #"/var/edeposit_import" result ))
+                (is (re-find #"->" result))
+                (is (re-find #"scp-to-kramerius/request" result)))
+              (let [sent (tc/from-string (slurp (io/file response-dir "sent")))]
+                (is sent)
+                (is (t/before? local-now sent))
+                )
+              )
+            )
+          )
+        )
+      (fs/delete-dir workdir)
+      )
+    )
+  )
+
+


WIP: update series plots.

WIP: update series plots.

--- metlog-vault/src-client/metlog_client/metlog.cljs
+++ metlog-vault/src-client/metlog_client/metlog.cljs
@@ -42,7 +42,7 @@
   (let [ ctx (.getContext canvas "2d")]
     (tsplot/draw ctx (.-clientWidth canvas) (.-clientHeight canvas) series-data)))

-(defn series-tsplot [ series qws-arg]
+(defn series-tsplot [ series qws-arg ]
   (let [dom-node (reagent/atom nil)
         series-state (reagent/atom {})]
     (reagent/create-class
@@ -56,10 +56,11 @@
       (fn [ this ]
         (reset! dom-node (reagent/dom-node this))
         (go
-          (swap! series-state assoc :series-data (<! (<<< fetch-series-data series @query-window-secs)))))
+          (swap! series-state assoc :series-data
+                 (<! (<<< fetch-series-data series @query-window-secs)))))

       :reagent-render
-      (fn [ ]
+      (fn [ & rest ]
         @window-width
         @series-state
         [:div
@@ -67,23 +68,24 @@
                     {:width (.-clientWidth node)
                      :height (.-clientHeight node)})]])})))

-(defn series-pane [ series-name ]
+(defn series-pane [ series-name query-window-secs ]
   [:div.series-pane
    [:div.series-pane-header
     [:span.series-name series-name]]
-   [series-tsplot series-name @query-window-secs]])
+   [series-tsplot series-name query-window-secs]])

 (defn series-list [ ]
-  [:div
-   (for [ series (:series @dashboard-state) ]
-     ^{ :key series } [series-pane series])])
+  (let [ query-window-secs @query-window-secs]
+    [:div
+     (for [ series (:series @dashboard-state) ]
+       ^{ :key series } [series-pane series query-window-secs])]))

 (defn end-edit [ text state ]
   (let [ qws (js/parseInt text) ]
     (reset! query-window-secs qws)))

-(defn input-field [ on-enter ]
-  (let [ state (reagent/atom { :text "" }) ]
+(defn input-field [ initial-text on-enter ]
+  (let [ state (reagent/atom { :text initial-text }) ]
     (fn []
       [:input {:value (:text @state)
                :onChange #(swap! state assoc :text (.. % -target -value))
@@ -94,7 +96,7 @@
   [:div.header
    [:span#app-name
     "Metlog"]
-   [input-field #(end-edit % dashboard-state)]])
+   [input-field @query-window-secs #(end-edit % dashboard-state)]])

 (defn dashboard [ ]
   [:div


Fixed bug when initializing button states for move/zoom

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/graphics/draw.clj
+++ src/conexp/graphics/draw.clj
@@ -90,8 +90,8 @@
 			    (.. scn getWindow (startInteraction (move-interaction scn)))
 			    (.setEnabled zoom-button true)
 			    (.setEnabled move-button false))))
-    (.setEnabled zoom-button false)
-    (.setEnabled move-button true)))
+    (.setEnabled zoom-button true)
+    (.setEnabled move-button false)))

 ;;


Minor refactoring in parallel fetcher

Minor refactoring in parallel fetcher

--- src/cyanite_fetcher/core.clj
+++ src/cyanite_fetcher/core.clj
@@ -102,7 +102,8 @@
                                              (int period)
                                              from to]
                                     :fetch-size Integer/MAX_VALUE})]
-                         (->> (doall (map detect-aggregate data))
+                         (->> (doall data)
+                              (map detect-aggregate)
                               (seq))))
                     paths))]
     (map deref futures)))


parinfer formatting

parinfer formatting

--- src-cljs/cuttle/exec.cljs
+++ src-cljs/cuttle/exec.cljs
@@ -65,9 +65,8 @@
         callback-fn
         (fn [error stdout stderr]
           (if error
-            (do
-              (log-info "couldn't run java -version:" (.toString error))
-              (put! out-chan false))
+            (do (log-info "couldn't run java -version:" (.toString error))
+                (put! out-chan false))
             (let [version (parse-java-version stderr)
                   valid? (>= version 7)]
               (log-info "found java version:" version "from" stderr)
@@ -187,9 +186,9 @@
   "Returns the file that has the error (or nil) from error lines."
   [lines]
   (reduce (fn [v l]
-    (if (has-file-info? l)
-      (extract-file-from-error-line l)
-      v))
+            (if (has-file-info? l)
+              (extract-file-from-error-line l)
+              v))
     nil lines))

 (defn- extract-human-error* [s]
@@ -201,9 +200,9 @@
   "Returns a human-readable error message (or nil) from error lines."
   [lines]
   (reduce (fn [v l]
-    (if (caused-by-line? l)
-      (extract-human-error* l)
-      v))
+            (if (caused-by-line? l)
+              (extract-human-error* l)
+              v))
     nil lines))

 (defn- has-line-info? [s]
@@ -220,10 +219,10 @@

 (defn- extract-line-number [lines]
   (reduce (fn [v l]
-    (if (and (has-line-info? l)
-             (nil? v))
-      (extract-line-number* l)
-      v))
+            (if (and (has-line-info? l)
+                     (nil? v))
+              (extract-line-number* l)
+              v))
     nil lines))

 (defn- extract-error-info
@@ -232,7 +231,7 @@
   {:file (extract-error-file lines)
    :line (extract-line-number lines)
    :human-msg (extract-human-error lines)
-   :raw-lines lines })
+   :raw-lines lines})

 (defn- clean-line
   "Clean bash escape characters from a console output line."
@@ -407,17 +406,15 @@

 (defn stop-auto!
   "Kill an auto-compile process."
-  ([prj-key]
-    (stop-auto! prj-key (fn [] nil)))
+  ([prj-key] (stop-auto! prj-key (constantly nil)))
   ([prj-key callback-fn]
-    (let [main-pid (get @auto-pids prj-key)]
-      (log-info "trying to stop auto-compile for" prj-key "at pid" main-pid)
-      (if on-windows?
-        (js-exec (str "taskkill /pid " main-pid " /T /F") callback-fn)
-        (kill-auto-on-unix main-pid callback-fn))
-
+   (let [main-pid (get @auto-pids prj-key)]
+     (log-info "trying to stop auto-compile for" prj-key "at pid" main-pid)
+     (if on-windows?
+       (js-exec (str "taskkill /pid " main-pid " /T /F") callback-fn)
+       (kill-auto-on-unix main-pid callback-fn))
       ;; remove the pid from the atom
-      (swap! auto-pids dissoc prj-key))))
+     (swap! auto-pids dissoc prj-key))))

 (defn kill-all-leiningen-instances! []
   (let [currently-running-prj-keys (keys @auto-pids)
@@ -479,12 +476,12 @@
   (let [lein-cmd (lein (str "new mies " project-name))]
     (js-exec lein-cmd (js-obj "cwd" folder-name) callback-fn)))

-(def cuttle-icon (str
-  (aget js/global "__dirname")
-  path-separator
-  "img"
-  path-separator
-  "cuttle-logo.png"))
+(def cuttle-icon
+  (str (aget js/global "__dirname")
+       path-separator
+       "img"
+       path-separator
+       "cuttle-logo.png"))

 (defn linux-notify! [title message]
   (log-info "trying to notify linux" title "-" message)


test hook

test hook

--- src/main/cawala/api/read.clj
+++ src/main/cawala/api/read.clj
@@ -6,7 +6,7 @@
                      :person/relation :friend}
                  2  {:db/id 2 :person/name "Sally" :person/age 22
                      :person/relation :friend}
-                 3  {:db/id 3 :person/name "Allie" :person/age 52
+                 3  {:db/id 3 :person/name "Allie" :person/age 53
                      :person/relation :enemy}
                  4  {:db/id 4 :person/name "Zoe" :person/age 32
                      :person/relation :friend}


Remove straggler console logs (#1838)

Remove straggler console logs (#1838)

--- src-cljs/frontend/controllers/navigation.cljs
+++ src-cljs/frontend/controllers/navigation.cljs
@@ -26,14 +26,12 @@

 (defn- maybe-add-workflow-response-data [state]
-  (js/console.log "maybe-add-workflow-response-data")
   (let [{:keys [workflow-id]} (get-in state state/navigation-data-path)]
     (cond-> state
       (= workflow-id "mock-workflow-id")
       (assoc-in state/workflow-path workflow/fake-progress-response))))

 (defn- maybe-fetch-workflow-response-data! [state api-ch]
-  (js/console.log "maybe-fetch-workflow-response-data!" (clj->js (get-in state state/navigation-data-path)))
   (let [{:keys [workflow-id]} (get-in state state/navigation-data-path)]
     (when (= workflow-id "mock-workflow-id")
       (ajax/ajax :post


Fix fn name

Fix fn name

--- src-shared/cljs/cljs_webrepl/repl_thread.cljs
+++ src-shared/cljs/cljs_webrepl/repl_thread.cljs
@@ -68,7 +68,7 @@
     (go
       (loop []
         (when-let [msg (<! input-ch)]
-          (post-msg target writer msg)
+          (post-message target writer msg)
           (recur)))
       (finally-fn))
     {:input-ch  input-ch


Fix #15, disable boot-reload if running advanced with optimization

goog/dependencies_ only exists in development mode. The same check is
used by Figwheel.

This also disables the WebSocket connection.

There is no warning currently.

--- src/adzerk/boot_reload/client.cljs
+++ src/adzerk/boot_reload/client.cljs
@@ -44,7 +44,8 @@
 (defn connect
   ([url] (connect url nil))
   ([url opts]
-   (when-not (alive?)
+   (when (and (not (alive?))
+              (some? goog/dependencies_))
      (let [conn (ws/websocket-connection)]
        (patch-goog-base!)
        (reset! ws-conn conn)


Fix closed-over var

Fix closed-over var

--- src/braid/client/quests/views.cljs
+++ src/braid/client/quests/views.cljs
@@ -6,7 +6,7 @@

 (defn quest-view [quest]
   (let [show-video? (r/atom false)]
-    (fn []
+    (fn [quest]
       [:div.quest
        [:div.main {:data-icon (quest :icon)}
         [:div.info


Add job view tracking

Add job view tracking

--- src/clj/clojuredocs/pages/jobs.clj
+++ src/clj/clojuredocs/pages/jobs.clj
@@ -8,6 +8,7 @@
             :job-type "Permanent"
             :job-location "Seattle, WA"
             :job-apply-href "https://jobs.lever.co/amperity.com/a3890aff-1688-4ad0-ba9b-5203ac44fd7f"
+            :id "amp1"
             :short-id "amp1"
             :remote-ok? false
             :posted-at (util/now)
@@ -59,6 +60,7 @@
             :job-type "Permanent"
             :job-location "Durham, NC"
             :job-apply-href "https://angel.co/adzerk/jobs"
+            :id "adz1"
             :short-id "adz1"
             :remote-ok? false
             :posted-at (util/now)
@@ -106,6 +108,7 @@
             :job-type "Permanent"
             :job-location "Charlottesville, VA"
             :job-apply-href "https://www.roomkey.com/careers.html#back-end-dev"
+            :id "rk1"
             :short-id "rk1"
             :remote-ok? false
             :posted-at (util/now)
@@ -162,6 +165,7 @@
             :job-type "Permanent"
             :job-location "Charlottesville, VA"
             :job-apply-href "https://www.roomkey.com/careers.html#front-end-dev"
+            :id "rk2"
             :short-id "rk2"
             :remote-ok? false
             :posted-at (util/now)
@@ -225,7 +229,8 @@
             :job-type "Permanent"
             :job-location "Toronto, Canada"
             :job-apply-href "https://kirasystems.com/careers#op-131123-clojureclojurescript-web-developer"
-            :short-id "kira1"
+            :id "ki1"
+            :short-id "ki1"
             :remote-ok? true
             :posted-at (util/now)
             :company-name "Kira Systems"
@@ -270,6 +275,7 @@
             :job-type "Permanent"
             :job-location "Ann Arbor, MI"
             :job-apply-href ""
+            :id "fl1"
             :short-id "fl1"
             :remote-ok? false
             :posted-at (util/now)
@@ -326,7 +332,8 @@
             :job-type "Permanent"
             :job-location "New York, NY"
             :job-apply-href "http://intentmedia.com/jobs/?gh_jid=453872"
-            :short-id "intmed1"
+            :id "im1"
+            :short-id "im1"
             :remote-ok? false
             :posted-at (util/now)
             :company-name "Intent Media"
@@ -519,10 +526,16 @@
        (filter #(= job-id (:short-id %)))
        first))

+(defn track-job-view [job]
+  (mon/update! :job-metrics
+    {:_id (:id job)}
+    {:$inc {:views 1}}))
+
 (defn single-handler [job-id]
   (fn [{:keys [params uri user]}]
     (let [job (find-job job-id)]
       (when job
+        (track-job-view job)
         (common/$main
           {:body-class "jobs-page"
            :title (str "Jobs | ClojureDocs - Community-Powered Clojure Documentation and Examples")


RR: revert view link href

RR: revert view link href

--- src/cljs/hatti/views/dataview.cljs
+++ src/cljs/hatti/views/dataview.cljs
@@ -98,8 +98,8 @@
                        (if (and (= view :map) no-geodata?)
                          [:a {:class "inactive" :title "No geodata"}
                           (name view)]
-                         [:a {:on-click (click-fn #(activate-view! view))
-                              :href "#" :class (view->cls view)} label]))]
+                         [:a {:href (str "#/" (name view))
+                              :class (view->cls view)} label]))]
         (html
          [:div.tab-container.dataset-tabs
           [:div.tab-bar


unused function removed.

unused function removed.

--- src/cljs/om_next_leaflet/core.cljs
+++ src/cljs/om_next_leaflet/core.cljs
@@ -81,10 +81,6 @@
   (if-let [v (get @state k)]
     {:value v}
     {}))
-
-(defn get-mapobj
-  [this]
-  (-> (om/react-ref this :leaflet) om/get-state :mapobj))

 (defn get-stations-layer
   [this]
@@ -187,7 +183,7 @@
                                                        ])))
                    :disabled loading?} "update"]]
         (leaflet-map-fn {:mapid "map"
-                         :ref :leaflet ;; referenced from get-mapobj function
+                         :ref :leaflet ;; referenced from get-xxx-layer function
                          :center init-center
                          :zoom init-zoom
                          :base-layers [osm-layer pale-layer std-layer]


Tasks are now toggled when clicked

Tasks are now toggled when clicked

--- src/cljs/todo_list/views/main.cljs
+++ src/cljs/todo_list/views/main.cljs
@@ -3,12 +3,19 @@

 (defonce tasks (atom []))

+(defn- toggle-status [status]
+  (if (= status :done) :notdone :done))
+
+(defn- toggle-task [index]
+  (swap! tasks #(update-in @tasks [index :status] toggle-status)))
+
 (defn- add-task [text]
   (swap! tasks #(conj % {:text text, :status :notdone})))

-(defn- show-task [task]
+(defn- show-task [index task]
   "Show a single task"
-  ^{:key task} [:div {:class (str "task task-" (name (:status task)))}
+  ^{:key index} [:div {:class (str "task task-" (name (:status task)))
+                      :on-click #(toggle-task index)}
                 [:b (:text task)]])

 (defn- new-task-input []
@@ -22,5 +29,5 @@
   [:div
    [:h2 "TODO list"]
    (new-task-input)
-   (map show-task @tasks)
+   (map-indexed show-task @tasks)
    [:div [:a {:href "#/about"} "go to about page"]]])


Add an optional format message to col-predicate

--- src/circle/utils/model_validation_helpers.clj
+++ src/circle/utils/model_validation_helpers.clj
@@ -7,10 +7,10 @@

 (defmacro col-predicate
   "Require that f, a predicate, returns truthy when passed (get obj col)"
-  [col f]
+  [col f & [msg]]
   `(fn [o#]
      (when-not (~f (get o# ~col))
-       "field %s must pass predicate %s" (quote ~col) (quote ~f))))
+       (or ~msg (format "field %s must pass predicate %s" (quote ~col) (quote ~f))))))

 (defn require-key* [o k]
   ;;{:post [(do (println "require-key* post:" k "=" %) true)]}


file upload small change

file upload small change

--- src/cljs/re_form/inputs/file_upload_impl.cljs
+++ src/cljs/re_form/inputs/file_upload_impl.cljs
@@ -45,10 +45,9 @@

            (if uploading?
              (str "Uploading " (str/join ", " (map #(.-name %) files)) "...")
-             (if value
+             (if-not (empty? value)
                [:div
-                [:span.remove {:title "Delete" :on-click #(on-change nil)} "X"]
-                [:span.value (label-fn  (:value @state))]
-                ]
+                [:span.remove {:title "Delete" :on-click #(on-change {})} "X"]
+                [:span.value (label-fn  (:value @state))]]
                [:a {:href "javascript:void(0);" :on-click #(open-file-dialog @inp)}
                 (or (:placeholder props) "Select file to upload...")]))]))})))


Fix the bug with possible unmatched delimiters in solution

--- src/clojure/org/bytopia/foreclojure/logic.clj
+++ src/clojure/org/bytopia/foreclojure/logic.clj
@@ -1,5 +1,6 @@
 (ns org.bytopia.foreclojure.logic
-  (:require clojure.walk)
+  (:require [clojure.string :as str]
+            clojure.walk)
   (:import [java.util.concurrent FutureTask TimeUnit TimeoutException]))

 (def ^:const timeout 3000)
@@ -27,6 +28,16 @@
 (def ^:private forbidden-symbols
   #{'eval 'resolve 'read 'read-string 'throw 'ns 'in-ns 'require 'use 'refer})

+(defn read-code
+  "Safely read Clojure code from a string. Returns a sequence of read forms.
+  Taken from 4clojure.com source."
+  [^String code]
+  (binding [*read-eval* false]
+    (with-in-str code
+      (let [end (Object.)]
+        (doall (take-while (complement #{end})
+                           (repeatedly #(read *in* false end))))))))
+
 (defn check-suggested-solution
   "Evaluates user code against problem tests. Returns a map of test numbers to
   the errors (map is empty if all tests passed correctly). `restricted` is a set
@@ -37,8 +48,8 @@
      (if (empty? code)
        (assoc err-map i "Empty input is not allowed.")
        (try
-         (let [code-form (binding [*read-eval* false]
-                           (read-string (.replace test "__" code)))
+         (let [user-forms (str/join " " (map pr-str (read-code code)))
+               [code-form] (read-code (.replace test "__" user-forms))
                found-restricted (clojure.walk/postwalk
                                  (fn [f]
                                    (if (sequential? f)


Make the paths volume aware

Make the paths volume aware

--- src/mdr2/production/path.clj
+++ src/mdr2/production/path.clj
@@ -6,45 +6,67 @@
 (def production-path (env :production-path))

 (defn structured-path
-  "The path to the files relevant to a production that has been structured"
+  "The path to the files relevant to a production that has been
+  structured"
   [{id :id}]
   (file production-path "structured" (str id)))

 (defn recording-path
-  "The path to the files relevant to a production that is being recorded"
+  "The path to the files relevant to a production that is being
+  recorded"
   [{id :id}]
   (file production-path "recording" (str id)))

+(defn split-path
+  "The path to the files relevant to a `production` that has been
+  manually split"
+  ([{id :id}]
+   (file production-path "split" (str id)))
+  ([production volume]
+   (file (split-path production) (str volume))))
+
 (defn recorded-path
-  "The path to the files relevant to a production that has been recorded"
-  [{id :id}]
-  (file production-path "recorded" (str id)))
+  "The path to the files relevant to a production that has been
+  recorded"
+  ([{id :id}]
+   (file production-path "recorded" (str id)))
+  ([production volume]
+   (if volume
+     (split-path production volume)
+     (recorded-path production))))

 (defn encoded-path
   "Path to the encoded version of the exported DTB, i.e. the DTB
-  containing mp3s for given `production`"
-  [{id :id}]
-  (file production-path "encoded" (str id)))
+  containing mp3s for given `production` and `volume`"
+  ([{id :id}]
+   (file production-path "encoded" (str id)))
+  ([production volume]
+   (file (encoded-path production) (str volume))))

 (defn iso-path
   "Path to the directory where the iso of the exported DTB for given
-  `production` is placed"
-  [{id :id}]
-  (file production-path "iso" (str id)))
+  `production` and `volume` is placed"
+  ([{id :id}]
+   (file production-path "iso" (str id)))
+  ([production volume]
+   (file (iso-path production) (str volume))))

 (defn iso-name
-  "Path to the iso of the exported DTB for given `production`"
-  [{id :id :as production}]
-  (file (iso-path production) (str id ".iso")))
+  "Path to the iso of the exported DTB for given `production` and
+  `volume`"
+  [{id :id :as production} volume]
+  (file (iso-path production volume) (str id "_" volume ".iso")))

 (defn manifest-path
   "Path to the manifest of the DTB which was exported from obi for
-  given `production`"
-  [production]
-  (file (recorded-path production) "package.opf"))
+  given `production`."
+  ([production]
+   (manifest-path production nil))
+  ([production volume]
+   (file (recorded-path production volume) "package.opf")))

 (defn all
   "Return all the paths needed for a particular `production`"
   [production]
   (map #(% production)
-       [structured-path recording-path recorded-path encoded-path iso-path]))
+       [structured-path recording-path recorded-path split-path encoded-path iso-path]))


update metadata sync code to look for any Table or Field without a display_name and set it if so.

--- src/metabase/driver/sync.clj
+++ src/metabase/driver/sync.clj
@@ -10,7 +10,8 @@
             (metabase.driver [interface :refer :all]
                              [query-processor :as qp])
             [metabase.driver.sync.queries :as queries]
-            (metabase.models [field :refer [Field] :as field]
+            (metabase.models [common :as common]
+                             [field :refer [Field] :as field]
                              [foreign-key :refer [ForeignKey]]
                              [table :refer [Table]])
             [metabase.util :as u]))
@@ -19,6 +20,7 @@
          mark-category-field!
          mark-no-preview-display-field!
          mark-url-field!
+         set-field-display-name-if-needed!
          sync-database-active-tables!
          sync-field!
          sync-table-active-fields-and-pks!
@@ -89,6 +91,12 @@
    (e.g., `sync-table-fks!` can't run until all tables have finished `sync-table-active-fields-and-pks!`, since creating `ForeignKeys` to `Fields` of *other*
    Tables can't take place before they exist."
   [driver active-tables]
+
+  ;; make sure table has :display_name
+  (log/debug (color/green "Checking table display names..."))
+  (doseq [table active-tables]
+    (u/try-apply update-table-display-name! table))
+
   ;; update the row counts for every Table. These *can* happen asynchronously, but since they make a lot of DB calls each so
   ;; going to block while they run for the time being. (TODO - fix this)
   (log/debug (color/green "Updating table row counts..."))
@@ -118,6 +126,19 @@

 ;; ## sync-table steps.
+
+;; ### 0) update-table-row-count!
+
+(defn update-table-display-name!
+  "Update the display_name of TABLE if it doesn't exist."
+  [table]
+  {:pre [(integer? (:id table))]}
+  (try
+    (when (nil? (:display_name table))
+      (upd Table (:id table) :display_name (common/name->human-readable-name (:name table))))
+    (catch Throwable e
+      (log/error (color/red (format "Unable to update display_name for %s: %s" (:name table) (.getMessage e)))))))
+

 ;; ### 1) update-table-row-count!

@@ -246,6 +267,7 @@
          field]}
   (log/debug (format "Syncing field '%s.%s'..." (:name @(:table field)) (:name field)))
   (sync-field->> field
+                 set-field-display-name-if-needed!
                  (mark-url-field! driver)
                  mark-category-field!
                  (mark-no-preview-display-field! driver)
@@ -254,6 +276,18 @@

 ;; Each field-syncing function below should return FIELD with any updates that we made, or nil.
 ;; That way the next fn in the 'pipeline' won't trample over changes made by the last.
+
+;; ### set-field-display-name-if-needed!
+
+(defn set-field-display-name-if-needed!
+  "If FIELD doesn't yet have a `display_name`, calculate one now and set it."
+  [field]
+  (when (nil? (:display_name field))
+    (let [display-name (common/name->human-readable-name (:name field))]
+      (log/info (format "Field '%s.%s' has no display_name. Setting it now." (:name @(:table field)) (:name field) display-name))
+      (upd Field (:id field) :display_name display-name)
+      (assoc field :display_name display-name))))
+

 ;; ### mark-url-field!


putting in missing declaration.

putting in missing declaration.

--- src/metabase/driver/sync.clj
+++ src/metabase/driver/sync.clj
@@ -26,6 +26,7 @@
          sync-table-active-fields-and-pks!
          sync-table-fks!
          sync-table-fields-metadata!
+         update-table-display-name!
          update-table-row-count!)

 ;; ## sync-database! and sync-table!


Initialize cue-local variables when starting.

--- src/afterglow/max/Cue.clj
+++ src/afterglow/max/Cue.clj
@@ -116,6 +116,21 @@
                                              (into-array Atom [(Atom/newAtom id) (Atom/newAtom cue-name)])))))
   (controllers/add-cue-fn! (:cue-grid *show*) x y (:f @(.state this))))

+(defn apply-cue-local-variables
+  "After we start a cue, this function looks for any local values we
+  have saved for variables are creted for the duration of the cue,
+  and if any are found, copies them into the actual cue variables."
+  [this]
+  (let [{:keys [x y]} @(.state this)
+        [_ active] (show/find-cue-grid-active-effect *show* x y)]
+    (when active
+      (doseq [v (cue-variables this)]
+        (when (string? (:key v))
+          (let [cue-local-key (keyword (:key v))
+                cue-local-value (get-in @(.state this) [:variables cue-local-key])]
+            (when cue-local-value
+              (show/set-variable! (get-in active [:variables cue-local-key]) cue-local-value))))))))
+
 (defn- -start
   "Start the cue if it is not already running (if it is in the process
   of ending, start a new instance in its place)."
@@ -123,7 +138,8 @@
   (let [{:keys [x y]} @(.state this)
         [_ active] (show/find-cue-grid-active-effect *show* x y)]
     (when-not (and active (not (:ending active)))
-      (show/add-effect-from-cue-grid! x y))))
+      (show/add-effect-from-cue-grid! x y)
+      (apply-cue-local-variables this))))

 (defn- -end
   "Ask the cue to end; if it has already been asked once, kill it
@@ -171,8 +187,8 @@
         [_ active] (show/find-cue-grid-active-effect *show* x y)]
     (if (zero? inlet)  ; Cue control inlet?
       (if active  ; Transition the cue to the next appropriate state.
-        (show/end-effect! (:key cue))
-        (show/add-effect-from-cue-grid! x y))
+        (-end this)
+        (-start this))
       (let [v (nth (cue-variables this) (dec inlet)) ; One of the variable inlets; output its current value.
             current-val (if (keyword? (:key v))
                           (show/get-variable (:key v))


don't nuke the state from the getgo

don't nuke the state from the getgo

Signed-off-by: Chris Granger <5654cde260ae99bc4d30054171b8bcd902efd19a@gmail.com>

--- src/aurora/editor/ui.cljs
+++ src/aurora/editor/ui.cljs
@@ -964,6 +964,7 @@
 (defn repopulate []
   (let [stored (aget js/localStorage "aurora-state")]
     (if (and stored
+             (not= "{}" stored)
              (not= "null" stored)
              (not= stored ""))
       (reset! aurora-state (thaw stored))
@@ -1070,11 +1071,6 @@
                                    (deref)
                                    (:id)))))))

-(path->iter-count '([:page "ba5dec97_8922_4b74_a657_a077da4b9dc4"] [:step "5ed68cef_7c8f_4b50_b0d9_808a95aedbbb"] [:page "f2d8b4fa_84aa_470b_80a2_64a7c8f030f5"] [:notebook "346af462_5dd8_488a_b6d2_ea2dbfad2844"]))
-
-(assoc-cache! [:path-iterations] {'([:page "ba5dec97_8922_4b74_a657_a077da4b9dc4"] [:step "5ed68cef_7c8f_4b50_b0d9_808a95aedbbb"] [:page "f2d8b4fa_84aa_470b_80a2_64a7c8f030f5"] [:notebook "346af462_5dd8_488a_b6d2_ea2dbfad2844"])
-                                  1})
-
 (defn path->match-branch [path]
   (when-let [frame (path->frame path)]
     (-> frame


Use more concise, idiomatic swap! result.

--- src/afterglow/effects.clj
+++ src/afterglow/effects.clj
@@ -382,8 +382,7 @@
     ;; Could optimize for a non-dymanic phase, but that seems unlikely to be useful.
     (Effect. fade-name
              (fn [show snapshot]  ; We are still active if either effect is
-               (swap! active update-still-active [from-effect to-effect] show snapshot)
-               (some true? @active))
+               (some true? (swap! active update-still-active [from-effect to-effect] show snapshot)))
              (fn [show snapshot]
                (let [v (params/resolve-param phase show snapshot)
                      from-active (if (@active 0) from-effect blank-effect)
@@ -394,8 +393,7 @@
                    :else
                    (generate-fade from-active to-active v show snapshot))))
              (fn [show snapshot]  ; Ask any remaining active effects to end, record and report results
-               (swap! active end-still-active [from-effect to-effect] show snapshot)
-               (every? false? @active)))))
+               (every? false? (swap! active end-still-active [from-effect to-effect] show snapshot))))))

 (defn- find-chase-element
   "Look up the effect within a chase corresponding to a given position.


Add Neue Hörbucher download to front page

--- src/catalog/web/views.clj
+++ src/catalog/web/views.clj
@@ -4,6 +4,7 @@
              [validation :as validation]
              [vubis :as vubis]]
             [catalog.layout
+             [common :refer [translations]]
              [dtbook :as layout.dtbook]
              [fop :as layout.fop]]
             [catalog.web.layout :as layout]
@@ -27,16 +28,18 @@
     (layout/common
      identity
      [:div.row
-      [:div.col-md-4
-       [:h2 "Neu im Sortiment"]
+      [:div.col-md-3
+       [:h2 (translations :all-formats)]
        (icon-button "/neu-im-sortiment.pdf" "download" "Download")]
-      [:div.col-md-4
-       [:h2 "Neu in Grossdruck"]
-       (icon-button "/editorial" "pencil" "Edit")
-       (icon-button "/neu-in-grossdruck.pdf" "download" "Download")]
-      [:div.col-md-4
-       [:h2 "Neu in Braille "]
-       (icon-button "/neu-in-braille.xml" "download" "Download")]]
+      [:div.col-md-3
+       [:h2 (translations :grossdruck)]
+       (icon-button "/neue-grossdruckbücher.pdf" "download" "Download")]
+      [:div.col-md-3
+       [:h2 (translations :braille)]
+       (icon-button "/neue-braillebücher.xml" "download" "Download")]
+      [:div.col-md-3
+       [:h2 (translations :hörbuch)]
+       (icon-button "/neue-hörbücher.xml" "download" "Download")]]
      )))

 (defn read-catalog [f]


throw a JsonGenerationException instead of a regular Exception when we can't encode

--- src/cheshire/generate.clj
+++ src/cheshire/generate.clj
@@ -1,5 +1,5 @@
 (ns cheshire.generate
-  (:import (org.codehaus.jackson JsonGenerator)
+  (:import (org.codehaus.jackson JsonGenerator JsonGenerationException)
            (java.util Date Map List Set SimpleTimeZone UUID)
            (java.sql Timestamp)
            (java.text SimpleDateFormat)
@@ -10,8 +10,8 @@
   `(.writeString ~jg ~str))

 (definline fail [obj]
-  `(throw (Exception. (str "Cannot JSON encode object of class: "
-                           (class ~obj) ": " ~obj))))
+  `(throw (JsonGenerationException. (str "Cannot JSON encode object of class: "
+                                         (class ~obj) ": " ~obj))))

 (defmacro number-dispatch [^JsonGenerator jg obj]
   (if (< 2 (:minor *clojure-version*))