fix *eval-fn* docstring, :lang isn't a thing. Fix eval*

--- src/main/cljs/cljs/js.cljs
+++ src/main/cljs/cljs/js.cljs
@@ -71,7 +71,6 @@
   source. Whatever function *eval-fn* is bound to will be passed a map
   containing the following keys:

-  :lang   - the language, :clj or :js
   :source - the source of the library (string)
   :name   - used to unique identify the script (symbol)

@@ -441,9 +440,9 @@
                   (if (:error res)
                     (cb res)
                     (let [src (str "goog.provide(\"" (munge (:name ast)) "\")")]
-                      (cb (*eval-fn* {:lang :clj :source src}))))))
+                      (cb (*eval-fn* {:source src}))))))
               (let [src (with-out-str (comp/emit ast))]
-                (cb (*eval-fn* {:lang :clj :source src}))))))))))
+                (cb (*eval-fn* {:source src}))))))))))

 (defn eval
   "Evaluate a single ClojureScript form. The parameters:


comments and whitespace

comments and whitespace

--- src/babel/english/morphology.cljc
+++ src/babel/english/morphology.cljc
@@ -23,7 +23,7 @@
                 (dissoc-paths input [[:english :a :note] ;; this handles "you" in "you wash yourself"
                                      [:english :b :b :note]]) ;; this handles "yourself" in the same sentence.
                 input)]
-    (cond
+    (cond ;; fo
       (= input :fail)
       (str input)

@@ -299,7 +299,7 @@
              used-to-form

              true
-       (cond
+       (cond ;; imperfect exception-handling: check for :participle

         ;; TODO: add support for per-agreement (by number or person) irregular participle;
         ;; for now, only support for a single participle irregular form for all agreements.
@@ -438,7 +438,7 @@
          last-stem-char-is-vowel (re-find #"[aeiou]$" stem)]
      (log/debug "+else")
      (log/debug (str "(english):word: " word))
-     (cond
+     (cond ;; :infl=:present
       (and (= person :1st) (= number :sing)
            (string? (get-in word '(:present :1sing))))
       (get-in word '(:present :1sing))
@@ -499,7 +499,7 @@
       (string? (get-in word '(:english)))
       (get-in word '(:english))

-      :else (str root )))
+      :else (str root)))

    (and
     (get-in word '(:plur))


Make defhook macro work in clj too, make initial-val & add-fn work

--- src/braid/core/module_helpers.clj
+++ src/braid/core/module_helpers.clj
@@ -98,18 +98,34 @@
   By default, the values will be `conj`-ed into a vector, but this can
   be customized with the `:initial-val` and `:add-fn` arguments."
   [& {:keys [reader writer initial-val add-fn]
-      :or {initial-val [] add-fn conj}}]
+      :or {initial-val [] add-fn 'conj}}]
   (assert (symbol? reader))
   (assert (symbol? writer))
   `(do
-     (defonce atom# (atom []))
+     (defonce extend-thunks# (atom []))
      (def ~reader
-       (reify ~'IDeref
-         (~'-deref [_#]
-           (doall (map (fn [th#] (th#)) (deref atom#))))))
+       ;; Hack around protocol being clojure.lang.IDeref in Clojure vs
+       ;; cljs.core/IDeref in Clojurescript and the method being
+       ;; `deref` in Clojure vs `-deref` in Clojurescript.
+       (reify ~(if (nil? (:ns &env))
+                 'clojure.lang.IDeref
+                 'cljs.core/IDeref)
+         ;; This is a macro, so it'll always be Clojure, so we can't just use
+         ;; a reader conditional, so we check `(:ns &env)`, which will be
+         ;; `nil` if evaluating the macro in Clojure.
+         (~(if (nil? (:ns &env))
+             'deref
+             '-deref)
+          [_#]
+          (reduce
+            (fn [vs# th#]
+              (~add-fn vs# (th#)))
+            ~initial-val
+            (deref extend-thunks#)))))
      (defn ~writer [f#]
        (when-not (fn? f#)
-         (throw "Extensions must be functions"
-                {:invalid-value f#
-                 :register-fn (quote ~writer)}))
-       (swap! atom# conj f#))))
+         (throw (ex-info
+                  "Extensions must be functions"
+                  {:invalid-value f#
+                   :register-fn (quote ~writer)})))
+       (swap! extend-thunks# conj f#))))


Delete projects.clj

Delete projects.clj

--- bin/codestarter/views/projects.clj
+++ bin/codestarter/views/projects.clj
@@ -1,417 +0,0 @@
-(ns codestarter.views.projects
-  (:use codestarter.views.common
-        [clojure.contrib.seq :only (indexed)]
-        [clojure.data :only (diff)]
-        [clojure.set :only (intersection)]
-        hiccup.core
-        hiccup.form-helpers
-        [hiccup.page-helpers :exclude (url)]
-        korma.core
-        korma.db
-        [clj-time.core :exclude (extend)]
-        clj-time.format
-        [clj-time.coerce])
-  (:require [clojure.string :as string]
-            [codestarter.views.users :as users]
-            [noir.validation :as vali])
-  (:import [org.mozilla.javascript Context ScriptableObject]))
-
-(let [date-format "MM/dd/yyyy"]
-  (def date-formatter (formatter date-format))
-  (def date-formatter* (formatter (str date-format " hh:mm:ss a"))))
-
-(let [popular (map #(list (frequencies (string/split (% :languages) #", "))
-                         (frequencies (string/split (% :licenses) #", ")))
-                  (select projects))
-      popular #(string/join ", " (keys (reverse (sort (apply merge-with + (map % popular))))))]
-  (def popular-languages (popular first))
-  (def popular-licenses (popular second)))
-
-(defn clean [items]
-  (filter #(not= % "") (string/split (string/trim items) #",\s")))
-
-(defn get-n [n]
-  (if (and n (string? n)) (read-string n) (or n 2)))
-
-(defn goals->vec [goals]
-  (if (vector? goals) goals (vec (vals goals))))
-
-(defn valid? [{:keys [accept? id name description type deadline languages licenses wmd-input n-goals goals] :as params}]
-  (if (not id)
-    (do
-      (required params :accept? :name)
-      (vali/rule (<= (count name) 100)
-                 [:name "Project name must be less than or equal to 100 characters."])
-      (vali/rule (zero? (count (select projects (where {:name name}))))
-                 [:name "A project with this name already exists."])))
-  (required params :description :type)
-  (vali/rule (vali/has-value? wmd-input)
-             [:wmd-input "Plan is required."])
-  (vali/rule (<= (count description) 240)
-             [:description "Description must be less than or equal to 240 characters in length."])
-  (vali/rule (some #{type} ["new [funding]" "new [funding, lead]" "proprietary [funding]"])
-               [:type "Type must be one of \"new [funding]\", \"new [funding, lead]\", \"proprietary [funding]\"."])
-
-  (doseq [[field key items] [["language" :languages languages]
-                             ["license" :licenses licenses]]]
-    (let [items (clean items)]
-      (vali/rule (not (empty? items))
-                 [key (format "At least one %s is required." field)])
-      (doseq [counts (frequencies items)]
-        (vali/rule (< (second counts) 2)
-                   [key (format "Cannot have duplicate %ss." field)]))))
-
-  (vali/rule (not (params :add-goal)) [])
-  (vali/rule (not (params :delete-goal)) [])
-
-  (let [goals (goals->vec goals)]
-    (vali/rule (seq (filter #(not= (vals %) '("" "" "")) goals))
-               ["goals[0]" "At least one goal is required."])
-
-    (loop [n 0
-           n-goals (get-n n-goals)
-           last-amount 0
-           last-deadline (now)]
-      (if (< n n-goals)
-        (let [goal (get goals n)
-              valid-amount (and (re-matches #"[0-9]*\.?[0-9]+" (goal :amount))
-                                (pos? (read-string (goal :amount))))
-              amount (if valid-amount (read-string (goal :amount)))
-              valid-deadline (and (re-matches #"(0[1-9]|1[012])/(0[1-9]|[12][0-9]|3[01])/(19|20)\d\d" (get goal :deadline ""))
-                                  (within? (interval (now) (plus (now) (months 18))) (parse (formatter "MM/dd/yyyy") (goal :deadline))))
-              deadline (if valid-deadline (parse (formatter "MM/dd/yyyy") (goal :deadline)))]
-          (if (not= (vals goal) '("" "" ""))
-            (do
-              (vali/rule (vali/has-value? (goal :amount))
-                         [(format "goals[%s][amount]" n) "Amount is required."])
-              (vali/rule valid-amount
-                         [(format "goals[%s][amount]" n) "Amount must be a number greater than 0."])
-              (vali/rule (and valid-amount (> amount last-amount))
-                         [(format "goals[%s][amount]" n) "Amount must be greater than the amounts of preceeding goals."])
-              (vali/rule (vali/has-value? (goal :deadline))
-                         [(format "goals[%s][deadline]" n) "Deadline is required."])
-              (vali/rule valid-deadline
-                         [(format "goals[%s][deadline]" n) "Deadline must be a date in the format mm/dd/yyyy that is within the next 18 months."])
-              (vali/rule (and valid-deadline (not (before? deadline last-deadline)))
-                         [(format "goals[%s][deadline]" n) "Deadline must be at or after the deadlines of preceeding goals."])
-              (vali/rule (vali/has-value? (goal :description))
-                         [(format "goals[%s][description]" n) "Description is required."])
-              (vali/rule (<= (count (goal :description)) 500)
-                         [(format "goals[%s][description]" n) "Description must be less than or equal to 500 characters in length."])))
-          (recur (inc n) n-goals (if valid-amount amount last-amount) (if valid-deadline deadline last-deadline)))))))
-
-(defn form [request params & [project]]
-  (let [params (if (params :goals) (assoc params :goals (goals->vec (params :goals))) params)
-        params (cond
-                 (params :add-goal) (update-in params [:n-goals] #(inc (read-string %)))
-                 (params :delete-goal) (let [goals (params :goals)
-                                             deleted (read-string (params :delete-goal))
-                                             params (assoc params :goals
-                                                           (vec (concat (subvec goals 0 deleted)
-                                                                        (subvec goals (inc deleted)))))]
-                                         (update-in params [:n-goals] #(dec (read-string %))))
-                 :else params)
-        params (if project (merge project params) params)]
-    (form-to [:post "."]
-             (csrf)
-             (if (not project) (warning params))
-             [:h4 "general information"]
-             (control :name (text-field (if project {:disabled ""} {}) :name (params :name))
-                      :label "project name")
-             (control :description (text-area :description (params :description)))
-             (control :lead
-                      (html (text-field {:disabled true} :lead
-                                        (display (if project
-                                                   (assoc params :name (params :name_2))
-                                                   (get-user request))))
-                            (if (= (params :type) "new [funding, lead]")
-                              [:span {:style "padding-left: 1em"}
-                               (link-to (url "projects" (params :id) "applications")
-                                        (str (get-count applications {:project_id (params :id)}) " applications"))])))
-             (control :type
-                      (html
-                        (for [[type help] [["new [funding]" "project which you will implement"]
-                                           ["new [funding, lead]" "project which you want someone else to implement"]
-                                           ["proprietary [funding]" "software you have the rights to which you want to open source"]]]
-                          [:label (radio-button :type (= (params :type) type) type)
-                           [:span (str type " - " help)]])))
-             (control :languages
-                      (text-area :languages (params :languages))
-                      :help (html [:p "Comma-seperated list of the languages which your project uses."]
-                                  [:p "popular: " popular-languages]))
-             (control :licenses
-                      (text-area :licenses (params :licenses))
-                      :help (html [:p "Comma-seperated list of the licenses which your project uses."]
-                                  [:p "popular: " popular-licenses]))
-             [:hr]
-             [:h4 "plan"]
-             [:p "The details of your project. It is important to describe your project accurately and in as much detail as possible."]
-             [:div {:class (str "wmd-panel" (if (vali/errors? :wmd-input) " error"))}
-              (text-area {:class "big"} :wmd-input (params :wmd-input))
-              (on-error :wmd-input)
-              [:p "formatting: " (link-to "http://daringfireball.net/projects/markdown/" "Markdown")]
-              [:div#wmd-preview.wmd-panel.wmd-preview.panel]]
-             [:hr]
-             [:h4 "goals"]
-             [:p "The funding goals for your project. Each goal is a subset of functionality that will be implemented if the funding amount is met."]
-             [:p "For example, in a new project, $100 of funding would mean Python support, $200 of funding would mean Clojure support. Or, when releasing proprietary software, $150 of funding would mean the release of code, $200 would mean the release of art assets."]
-             [:p {:style "padding-bottom: 1em"} "You should describe your goals in more detail in the project's plan."]
-             (let [n-goals (get-n (params :n-goals))]
-               (html
-                 (hidden-field "n-goals" n-goals)
-                 (for [n (range n-goals)
-                       :let [id (format "goals[%s]" n)
-                             amount (format "%s[amount]" id)
-                             deadline (format "%s[deadline]" id)
-                             description (format "%s[description]" id)
-                             amount-value (-> (params :goals) (get n) :amount)
-                             amount-value (if (= (type amount-value) java.lang.Double)
-                                            (format "%.2f" amount-value)
-                                            amount-value)]]
-                   [:fieldset
-                    [:legend (str "goal " (inc n))
-                     " "
-                     (if (pos? n) [:button.button.tiny {:name "delete-goal" :value n} "delete"])]
-                    [:div
-                     (on-error id)
-                     (control amount
-                              [:div.row.collapse
-                               [:div.one.columns [:span.prefix "$"]]
-                               [:div.eleven.columns (text-field {:name amount} amount amount-value)
-                                  (on-error amount)]]
-                              :label "amount"
-                              :help [:p "The amount of funding needed to implement this goal. Be realistic with costs."]
-                              :skip-errors? true)
-                     (control deadline
-                              (text-field {:name deadline} deadline (-> (params :goals) (get n) :deadline))
-                              :label "expected date"
-                              :help [:p "The expected date (up to 18 months from now) that the goal will be completed if funding is met. When this date is reached, individuals who have funded your project can rate whether you have completed the goal."])
-                     (control description
-                                (text-area {:name description} description
-                                           (-> (params :goals) (get n) :description))
-                                :label "description"
-                                :help [:p "Description of what functionality will be implemented if the goal is met."])]])))
-             [:div.eight.columns.centered [:button.button.secondary {:name "add-goal"} "add another goal"]]
-             [:hr]
-             [:button.button (if project "save changes" "create project")])))
-
-(defn index [request]
-  (fluid
-    request
-    (html
-     [:div.panel [:h3 "Test"]]
-     [:div
-      [:span [:h2 "current projects"]]
-      [:span
-       [:a {:href "/projects/create/"} "create project"]]]
-     [:table#table
-      [:thead
-       [:tr
-        [:th "id"]
-        [:th "name"]
-        [:th "description"]
-        [:th "languages"]]]
-      [:tbody
-       (for [project (select projects (order :id :DESC))]
-         [:tr
-          [:td (project :id)]
-          [:td (link-to (format "/projects/%s/" (project :id)) (project :name))]
-          [:td (project :description)]
-          [:td (project :languages)]])]])))
-
-(defn show [id request]
-  (body* [project (select-one projects (where {:id id}) (with users) (with goals)
-                              (with pledges (aggregate (sum :amount) :total)))]
-         true
-         request
-         (html
-           (header project request)
-           [:div.row
-            [:div.dl.eight.columns
-             [:div.row
-              [:div.two.columns.offset-by-one "deadline"]
-              [:div.nine.columns
-               [:span.radius.alert.label
-                (let [minutes (in-minutes
-                                (interval (now) (plus (from-sql-date (project :time)) (days 30))))
-                      remainder (rem minutes 1440)]
-                  (format "%s days %s hours %s minutes" (quot minutes 1440) (quot remainder 60)
-                          (rem remainder 60)))]]]
-             [:div.row
-              [:div.two.columns.offset-by-one "lead"]
-              [:div.nine.columns
-               (if (= (project :type) "new [funding, lead]")
-                 [:div.panel
-                  [:p (link-to (url "users" (project :id_2)) (display (assoc project :name (project :name_2)) true))
-                   [:span.radius.secondary.label "temporary"]]
-                  (if (not= (project :user_id) (*user* :id))
-                    (html
-                      [:p "This project needs someone to lead it. If you are interested and capable, consider applying. If accepted, you take on the rewards and responsibilies."]
-                      (if-let [application (select-one applications (where {:project_id id :user_id (*user* :id)}))]
-                        (link-to {:class "button secondary"}
-                                 (url "projects" (project :id) "applications" (application :id) "delete")
-                                 "delete application")
-                        (link-to {:class "button success"}
-                                 (url "projects" (project :id) "applications" "create")
-                                 "apply"))))]
-                 (link-to (format "/user/%s/" (project :id_2))
-                          (display (assoc project :name (project :name_2)))))]]
-             [:div.row
-              [:div.two.columns.offset-by-one "languages"]
-         [:div.nine.columns (project :languages)]]
-             [:div.row
-              [:div.two.columns.offset-by-one "licenses"]
-              [:div.nine.columns (project :licenses)]]
-             [:hr]
-             (markdown (project :plan))]
-            [:div#funding.dl.four.columns
-             (let [total (-> project :goals last :amount)
-                   pledges-$ (-> project :pledges first :total)
-                   total-percentage (cents->$ (* (/ total pledges-$) 100))
-                   amount (-> project :goals first :amount)
-                   percentage (cents->$ (* (/ amount pledges-$) 100))
-                   pledge (select-one pledges (where {:user_id (*user* :id) :project_id id}))]
-               [:div.panel
-                [:h4 "funding"]
-                 [:div.row
-                  [:div.four.columns "pledged"]
-                  [:div.eight.columns
-                   [:span.radius.success.label (format "$%s" (cents->$ pledges-$))] ]]
-                 [:div.row
-                  [:div.four.columns "status"]
-                  [:div.eight.columns
-                   (format "0 / %s goals met" (count (project :goals)))]]
-                 [:div.row
-                  [:div.four.columns "goal 1"]
-                  [:div.eight.columns
-                   (format "$%s (%s%%)" (cents->$ amount) percentage)]]
-                 [:div.progress [:div.bar {:style (format "width: %s" percentage)}]]
-                 [:div.row
-                  [:div.four.columns "overall"]
-                  [:div.eight.columns
-                   (format "$%s (%s%%)" (cents->$ total) total-percentage)]]
-                 [:div.progress [:div.bar {:style (format "width: %s" total-percentage)}]]
-                 (if pledge
-                   [:div.row
-                    [:div.four.columns "current pledge"]
-                    [:div.eight.columns
-                     [:span.radius.success.label (format "$%s" (cents->$ (pledge :amount)))]
-                     (link-to {:class "button secondary tiny"} (str (pledge :id) "/edit/") "edit")
-                     (link-to {:class "button secondary tiny"} (str (pledge :id) "/delete/") "delete")]]
-                   (link-to {:class "button success"} (str "pledges/create/") "pledge"))])
-             [:div.panel
-              [:h4 "goals"]
-              (map-indexed
-                #(vector :div.goal
-                         [:div.row
-                          [:div.four.columns (format "goal %s" (inc %))]
-                          [:div.eight.columns (format "$%s" (cents->$(%2 :amount)))]]
-                         [:div.row
-                          [:div.eight.columns.offset-by-four
-                           [:span.radius.secondary.label "delivery date"]
-                           (unparse date-formatter (from-sql-date (%2 :deadline)))]]
-                         (%2 :description)(if (< (inc %) (count (project :goals))) [:hr]))
-                (project :goals))]]])))
-
-(defn create [{:keys [params] :as request}]
-  (body* [params params]
-         (get-user request)
-         request
-         (html
-           [:h1 "create project"]
-           (form request params))
-         (valid? params)
-         "Project created."
-         (let [user (get-user request)
-               project (insert projects (values {:user_id (user :id)
-                                                 :founder (user :id)
-                                                 :time (to-timestamp (now))
-                                                 :name (params :name)
-                                                 :description (params :description)
-                                                 :type (params :type)
-                                                 :languages (string/join ", " (clean (params :languages)))
-                                                 :licenses (string/join ", " (clean (params :licenses)))
-                                                 :plan (params :wmd-input)}))]
-           (map
-             #(insert goals (values {:project_id (project :id)
-                                     :amount (read-string (% :amount))
-                                     :deadline (to-timestamp (parse date-formatter (% :deadline)))
-                                     :description (% :description)}))
-             (filter #(not= (vals %) '("" "" "")) (goals->vec (params :goals))))
-           (insert subscriptions (values {:project_id (project :id)
-                                          :user_id (user :id)
-                                          :edit true
-                                          :comment true
-                                          :update true
-                                          :update_comment true
-                                          :email (user :email)}))
-           (redirect (url "projects" (project :id))))))
-
-(defn edit [id {:keys [params] :as request}]
-  (body* [project (select-one projects (where {:id id}) (with users) (with goals))]
-        (= (project :user_id) (get-user request :id))
-        request
-        (html
-          (header project request)
-          (form request (assoc params :id id)
-                (merge project {:wmd-input (project :plan)
-                                :n-goals (count (project :goals))
-                                :goals (vec (map
-                                              #(assoc % :deadline
-                                                      (unparse date-formatter
-                                                               (from-sql-date (% :deadline))))
-                                              (project :goals)))})))
-        (valid? params)
-        "Project updated."
-        (let [project* (update projects (set-fields {:edit_time (to-timestamp (now))
-                                                     :description (params :description)
-                                                     :type (params :type)
-                                                     :languages (string/join ", " (clean (params :languages)))
-                                                     :licenses (string/join ", " (clean (params :licenses)))
-                                                     :plan (params :wmd-input)})
-                               (where {:id id}))
-              goals* (delete goals (where {:project_id id}))
-              goals* (map #(insert goals (values {:project_id id
-                                                  :amount (read-string (% :amount))
-                                                  :deadline (to-timestamp
-                                                              (parse date-formatter (% :deadline)))
-                                                  :description (% :description)}))
-                          (filter #(not= (vals %) '("" "" "")) (goals->vec (params :goals))))
-              changes (diff (assoc project* :goals goals*) project)
-              changes (merge (second changes) (first changes))
-              hash #(apply hash-map (apply concat (map % %2)))
-              goals-changes (hash #(vector (inc (first %)) (intersection (set (keys (second %)))
-                                                                         (set [:amount :deadline :description])))
-                                  (indexed (changes :goals)))
-              n-goals* (count goals*)
-              n-goals (count (project :goals))
-              n-changed-goals (- n-goals* n-goals)
-              goals-changes (merge goals-changes
-                                   (cond (neg? n-changed-goals)
-                                         (hash #(vector (inc %) "deleted") (range n-goals* n-goals))
-                                         (pos? n-changed-goals)
-                                         (hash #(vector % "added") (range n-goals* (+ n-goals* n-changed-goals)))))
-              changed-keys (intersection (set (keys changes))
-                                         (set [:description :lead :deadline :languages :licenses :plan]))
-              changes (string/join ", " (map name changed-keys))
-              goals-changes (string/join ", "
-                                         (for [change goals-changes
-                                               :let [details (second change)]
-                                               :when (seq details)]
-                                           (format "goal %s %s" (first change)
-                                                   (if (string? details) (second details)
-                                                     (format "[%s]" (string/join ", " (map name details)))))))
-              changes (str changes (if (or (string/blank? changes) (string/blank? goals-changes)) "" ", ")
-                           goals-changes)
-              project* (update projects (set-fields {:changes changes}) (where {:id id}))]
-          (if (string/blank? (project* :changes))
-            (redirect "" :flash "Nothing changed.")
-            (do
-              (notify id
-                      (get-user request)
-                      (project* :edit_time)
-                      :edit
-                      (project* :changes)
-                      (url "projects" id)
-                      (project* :changes))
-              (redirect ""))))))


fixed Election Day message

fixed Election Day message

--- src/clj/game/cards-operations.clj
+++ src/clj/game/cards-operations.clj
@@ -217,7 +217,7 @@
                    (filter #(not (= (:cid %) (:cid card))))
                    (count)
                    (pos?)))
-    :msg (msg "to trash all cards in HQ and draw 5 cards")
+    :msg (msg "trash all cards in HQ and draw 5 cards")
     :effect (effect (trash-cards (get-in @state [:corp :hand]))
                     (draw 5))}


bucketize by scan_date

bucketize by scan_date

--- src/cljs/apollo/client/pages.cljs
+++ src/cljs/apollo/client/pages.cljs
@@ -117,7 +117,7 @@
       (let [result-count (om/get-state owner :result-count)
             buckets (group-by
                      (fn [x]
-                       (let [d (x "last_modified")]
+                       (let [d (x "scan_date")]
                          (date-to-range-val (c/from-long d))))
                      (take result-count (:albums data)))]
         (html [:div.browse


Use [:span] instead of [:div]

Use [:span] instead of [:div]

--- src/cljs/cljs_webrepl/syntax.cljs
+++ src/cljs/cljs_webrepl/syntax.cljs
@@ -100,4 +100,4 @@
                        (conj (pop res) (str old val))
                        (conj res val)))
                    (conj res [:span style val])))
-          (into [:div] res))))))
+          (into [:span] res))))))


simplify turn

simplify turn

--- src/cljs/triboard/logic/turn.cljs
+++ src/cljs/triboard/logic/turn.cljs
@@ -12,25 +12,27 @@
 ;; Private
 ;; -----------------------------------------

-(defn- with-available-moves
-  "Add the available moves on the board"
-  [{:keys [board] :as turn}]
-  (assoc turn :moves (move/all-transitions board)))
+(defn- with-next-player
+  "Complete the turn to compute to find the next player than can act
+   * Requires to look-ahead for the next possible transitions
+   * To save computation, keep this look-ahead available"
+  [{:keys [board player] :as turn}]
+  (let [transitions (move/all-transitions board)
+        who-can-play (filter #(get transitions %) (player/next-three player))]
+    (-> turn
+      (assoc :moves transitions)
+      (assoc :player (first who-can-play))
+      )))

-(defn- with-next-player
-  "Find the next player to act - dismiss those that cannot play any move"
-  [{:keys [moves player] :as turn}]
-  (let [who-can-play (filter #(get moves %) (player/next-three player))]
-    (assoc turn :player (first who-can-play))
-    ))
-
-(defn- apply-moves
+(defn- apply-transition
+  "Apply the transtion to the current turn, yielding a new turn"
   [turn transition]
   (let [new-board (move/apply-transition (:board turn) transition)
         new-scores (reduce scores/update-scores (:scores turn) transition)]
     (-> turn
       (assoc :board new-board)
       (assoc :scores new-scores)
+      (with-next-player)
       )))

@@ -45,12 +47,11 @@
      ::scores/scores]))

 (defn new-init-turn []
-  (-> {:board (board/new-board)
-       :player (rand-nth player/all)
-       :moves {}
-       :scores scores/initial-scores}
-    with-available-moves
-    with-next-player))
+  (with-next-player
+    {:board (board/new-board)
+     :player (rand-nth player/all)
+     :moves {}
+     :scores scores/initial-scores}))

 (s/fdef play-move
   :args (s/cat :turn ::board/coord)
@@ -59,8 +60,5 @@
 (defn play-move
   "On player playing the move [x y] - update all the game state accordingly"
   [{:keys [player board] :as turn} point]
-  (if-let [moves (get-in turn [:moves player point])]
-    (-> turn
-      (apply-moves moves)
-      (with-available-moves)
-      (with-next-player))))
+  (if-let [transitions (get-in turn [:moves player point])]
+    (apply-transition turn transitions)))


add styles to dot export

add styles to dot export

--- src/cljx/thi/ng/fabric/utils.cljx
+++ src/cljx/thi/ng/fabric/utils.cljx
@@ -27,5 +27,10 @@
                    "%d[label=\"%d (%d)\"];\n"
                    (:id @v) (:id @v) (int (:state @v))))))))
        (apply str)
-       (format "digraph g {\nranksep=2;\noverlap=scale;\n%s}")
+       (format "digraph g {
+node[color=black,style=filled,fontname=Inconsolata,fontcolor=white,fontsize=9];
+edge[fontname=Inconsolata,fontsize=9];
+ranksep=1;
+overlap=scale;
+%s}")
        (spit "sc.dot")))


Trim base64 output of crypto.core util functions.

--- src/clojure/buddy/crypto/core.clj
+++ src/clojure/buddy/crypto/core.clj
@@ -1,6 +1,7 @@
 (ns buddy.crypto.core
   "Basic crypto primitives that used for more high
   level abstractions."
+  (:require [clojure.string :refer [trim]])
   (:import (org.apache.commons.codec.binary Base64 Hex)
            (javax.crypto Mac)
            (javax.crypto.spec SecretKeySpec)
@@ -36,7 +37,7 @@
   "Encode a bytes array to base64."
   [#^bytes data]
   (let [codec (Base64. true)]
-    (.encodeToString codec data)))
+    (trim (.encodeToString codec data))))

 (defn base64->bytes
   "Decode from base64 to bytes."
@@ -50,7 +51,7 @@
   [^String s]
   (let [codec (Base64. true)
         data  (str->bytes s)]
-    (.encodeToString codec data)))
+    (trim (.encodeToString codec data))))

 (defn base64->str
   "Decode from base64 to string."


rewriting/fixing some query logic. Ancestors working

--- src/com/billpiel/sayid/query2.clj
+++ src/com/billpiel/sayid/query2.clj
@@ -80,7 +80,6 @@

 (defn-zipper->> lazy-sibling-zipr-seq all-sib-zips)
 (defn-tags-functor lazy-sibling-tag-seq lazy-sibling-zipr-seq)
-

 (defn some-tags
   [tag-set tag-seq]
@@ -264,27 +263,82 @@
              (recur r)
              true)))))

+#_ (defn mk-relative-final-qry-fn
+     [opts tag-set & [dist]]
+     (let [opts' (util/obj-pred-action-else opts
+                                            (partial some #{:w})
+                                            :t [:a :s :d])
+           f' (fn [tag-seq-fnr]
+                (let [taker (if dist
+                              (partial take-lazy-tag-seq-functor dist)
+                              identity)
+                      stis (->> tag-seq-fnr
+                                taker
+                                prepend-node-to-lazy-tag-seq-functor
+                                (mk-some-tags-in-seq-fn tag-set))]
+                  stis))
+           rel-seq-map {:a lazy-descendant-tag-seq
+                        :s lazy-sibling-tag-seq
+                        :d lazy-ancestor-tag-seq}]
+       (->> opts'
+            (keep rel-seq-map)
+            (map f')
+            (apply some-fn-2))))
+
+(defn children-zips [zipr]
+  (some->> zipr
+           z/down
+           (iter-while-identity z/right)))
+
+(defn children-zips-by-generation [zipr]
+  (if (not-empty zipr)
+    (let [zipr' (if (some-> zipr
+                            meta
+                            :zip/make-node)
+                  [zipr]
+                  zipr)
+          kids (mapcat children-zips zipr')]
+      (concat (if (not-empty kids)
+                [kids]
+                [])
+              (children-zips-by-generation kids)))
+    nil))
+
+(defn mk-lazy-descendant-tag-seq
+  [node tag-fn dist]
+  (def n' node)
+  (def tag-fn' tag-fn)
+  (def d' dist)
+  (let [generations-seq (->> node
+                             :zipper
+                             children-zips-by-generation)
+        g-seq (if dist
+                (take dist generations-seq)
+                generations-seq)]
+    (->> g-seq
+         (apply concat)
+         (map z/node)
+         (mapcat tag-fn))))
+
+
+(defn mk-lazy-sibling-tag-seq [])
+(defn mk-lazy-ancestor-tag-seq [])
+
 (defn mk-relative-final-qry-fn
   [opts tag-set & [dist]]
-  (let [opts' (util/obj-pred-action-else opts
-                                        (partial some #{:w})
-                                        :t [:a :s :d])
-        f' (fn [tag-seq-fnr]
-             (let [taker (if dist
-                           (partial take-lazy-tag-seq-functor dist)
-                           identity)
-                   stis (->> tag-seq-fnr
-                             taker
-                             prepend-node-to-lazy-tag-seq-functor
-                             (mk-some-tags-in-seq-fn tag-set))]
-               stis))
-        rel-seq-map {:a lazy-descendant-tag-seq
-                     :s lazy-sibling-tag-seq
-                     :d lazy-ancestor-tag-seq}]
-    (->> opts'
-         (keep rel-seq-map)
-         (map f')
-         (apply some-fn-2))))
+  (fn [node tag-fn]
+    (or (some tag-set (tag-fn node))
+        (let [opts' (if (some #{:w} opts)
+                      [:a :s :d]
+                      opts)
+              rel-seq-map {:a mk-lazy-descendant-tag-seq
+                           :s mk-lazy-sibling-tag-seq
+                           :d mk-lazy-ancestor-tag-seq}
+              tag-seq-coll (->> opts'
+                                (keep rel-seq-map)
+                                (mapv #(% node tag-fn dist)))]
+          (some (partial some tag-set)
+                tag-seq-coll)))))

 (defn parse-to-kw-chars
   [s]


Add trace->tree

Add trace->tree

--- src/com/wsscode/pathom/trace.cljc
+++ src/com/wsscode/pathom/trace.cljc
@@ -15,7 +15,7 @@
         ::timestamp (now)))))

 (s/fdef trace
-  :args (s/cat :env map? :event (s/keys :opt [::event])))
+  :args (s/cat :env map? :event (s/keys :req [::event])))

 (defn trace-enter
   ([env event]
@@ -45,10 +45,9 @@
         (print (str (pr-str [(::event evt) (dissoc evt ::event)]) "\n"))))))

 (defn compute-durations [trace]
-  (let [leave-items
-        (into {} (comp (filter (comp #(= ::leave %) ::direction))
-                       (map (juxt ::id identity)))
-              trace)
+  (let [leave-items  (into {} (comp (filter (comp #(= ::leave %) ::direction))
+                                    (map (juxt ::id identity)))
+                           trace)

         initial-time (::timestamp (first trace))]

@@ -65,3 +64,51 @@
                                (dissoc ::id ::direction))
                            e)))))
           trace)))
+
+(defn trace->tree* [paths path]
+  (-> (reduce
+        (fn [x {::keys [event relative-timestamp]
+                :keys     [key]
+                :as       row}]
+          (case event
+            :com.wsscode.pathom.parser/parse-loop
+            (update x :response merge (select-keys row [::relative-timestamp ::duration :com.wsscode.pathom.core/path]))
+
+            :com.wsscode.pathom.parser/process-key
+            (let [next-path (conj path key)]
+              (if (contains? (:visited x) next-path)
+                x
+                (-> x
+                    (assoc-in [:response :children key]
+                      (-> (merge (trace->tree* paths next-path) (select-keys row [::relative-timestamp :key]))
+                          (assoc :com.wsscode.pathom.core/path next-path)))
+                    (update :visited conj next-path))))
+
+            (:com.wsscode.pathom.parser/call-read :com.wsscode.pathom.parser/async-return :com.wsscode.pathom.parser/skip-wait-key :com.wsscode.pathom.parser/skip-resolved-key :com.wsscode.pathom.parser/external-wait-key)
+            (update-in x [:response :children key ::details] (fnil conj []) (select-keys row [::event ::relative-timestamp]))
+
+            :com.wsscode.pathom.parser/max-iterations-reached
+            (update-in x [:response :children key ::details] (fnil conj []) (select-keys row [::event ::relative-timestamp :com.wsscode.pathom.parser/max-key-iterations]))
+
+
+            (:com.wsscode.pathom.connect/plan-ready :com.wsscode.pathom.connect/waiting-resolver
+              :com.wsscode.pathom.connect/call-resolver-with-cache :com.wsscode.pathom.connect/call-resolver-without-cache :com.wsscode.pathom.connect/call-resolver-cache-miss
+              :com.wsscode.pathom.connect/call-resolver-batch :com.wsscode.pathom.connect/batch-items-ready :com.wsscode.pathom.connect/batch-result-error :com.wsscode.pathom.connect/batch-result-ready
+              :com.wsscode.pathom.connect/merge-resolver-response :com.wsscode.pathom.connect/resolver-error :com.wsscode.pathom.connect/invalid-resolve-response)
+            (update-in x [:response ::details] (fnil conj []) (select-keys row [::event ::relative-timestamp ::duration :com.wsscode.pathom.connect/waiting-key
+                                                                                :com.wsscode.pathom.connect/sym :error :com.wsscode.pathom.connect/items-count :com.wsscode.pathom.connect/plan]))
+
+            :com.wsscode.pathom.parser/value-return
+            (-> x
+                (update-in [:response :children key ::details] (fnil conj []) (select-keys row [::event ::relative-timestamp]))
+                (update-in [:response :children key] assoc ::duration (- relative-timestamp (get-in x [:response :children key ::relative-timestamp]))))
+
+            x))
+        {:visited  #{}
+         :response {}}
+        (get paths path))
+      :response))
+
+(defn trace->tree [trace]
+  (let [paths (->> trace compute-durations (group-by :com.wsscode.pathom.core/path))]
+    (trace->tree* paths [])))


Add missing require [skip ci]

Add missing require [skip ci]

--- src/afterglow/web/layout.clj
+++ src/afterglow/web/layout.clj
@@ -1,5 +1,6 @@
 (ns afterglow.web.layout
-  (:require [environ.core :refer [env]]
+  (:require [clojure.java.io]
+            [environ.core :refer [env]]
             [markdown.core :refer [md-to-html-string]]
             [ring.middleware.anti-forgery :refer [*anti-forgery-token*]]
             [ring.util.anti-forgery :refer [anti-forgery-field]]


group button sets page to inbox

group button sets page to inbox

--- src/chat/client/views/groups_nav.cljs
+++ src/chat/client/views/groups_nav.cljs
@@ -25,6 +25,7 @@
                                                (when (= (@store/app-state :open-group-id)  (group :id)) "active"))
                                :style #js {:backgroundColor (id->color (group :id))}
                                :onClick (fn [e]
-                                          (store/set-open-group! (group :id)))}
+                                          (store/set-open-group! (group :id))
+                                          (store/set-page! {:type :inbox}))}
                    (string/join "" (take 2 (group :name)))))
                (vals (data :groups))))))))


move all dynamic pieces to let form to keep markup cleaner and easier to manipulate

--- src/cljs/cljspazzer/client/pages.cljs
+++ src/cljs/cljspazzer/client/pages.cljs
@@ -10,54 +10,70 @@
 (def nav-seq (concat (map str "#abcdefghijklmnopqrstuvwxyz") ["all"]))

 (defn nav-item [x]
-  [:li [:a {:href (utils/format "#/nav/%s" (utils/encode x))} x]])
+  (let [nav-url (utils/format "#/nav/%s" (utils/encode x))]
+    [:li [:a {:href nav-url} x]]))

 (defn artist-item [x]
-  (let [artist-image (utils/format "/api/artists/%s/image" (utils/encode x))]
+  (let [artist-image (utils/format "/api/artists/%s/image" (utils/encode x))
+        artist-url (utils/format "#/artists/%s" (utils/encode x))]
     [:li
-      [:a {:href (utils/format "#/artists/%s" (utils/encode x))}
-    ;; [:img {:src artist-image}]
-        [:div x]]]))
+     [:a {:href artist-url}
+      ;; [:img {:src artist-image}]
+      [:div x]]]))

 (defn album-item [active-artist album]
-  [:li
-   [:a {:href (utils/format "#/artists/%s/albums/%s"
-                            (utils/encode active-artist)
-                            (utils/encode (album "album_canonical")))}
-    [:img {:src (utils/format "/api/artists/%s/albums/%s/image"
-                              (utils/encode active-artist)
-                              (utils/encode (album "album_canonical")))}]
-    (utils/format "%s" (album "album_canonical"))]
-   [:a.download {:href (utils/format "/api/artists/%s/albums/%s/zip"
-                                     (utils/encode active-artist)
-                                     (utils/encode (album "album_canonical")))}
-    [:i.fa.fa-download.fa-lg]]
-   ])
+  (let [album-name (album "album_canonical")
+        album-url (utils/format "#/artists/%s/albums/%s"
+                                (utils/encode active-artist)
+                                (utils/encode album-name))
+        album-image (utils/format "/api/artists/%s/albums/%s/image"
+                                  (utils/encode active-artist)
+                                  (utils/encode album-name))
+        album-label (utils/format "%s" album-name)
+        album-zip-url (utils/format "/api/artists/%s/albums/%s/zip"
+                                    (utils/encode active-artist)
+                                    (utils/encode album-name))]
+    [:li
+     [:a {:href album-url}
+      [:img {:src album-image}]
+      album-label]
+     [:a.download {:href album-zip-url}
+      [:i.fa.fa-download.fa-lg]]
+     ]))

 (defn track-detail [track]
   (let [t (track "track")
+        track-num (t "track")
+        track-title (t "title")
+        track-id (t "id")
         artist (t "artist_canonical")
-        album (t "album_canonical")]
+        album (t "album_canonical")
+        track-url (utils/format "/api/artists/%s/albums/%s/tracks/%s"
+                                (utils/encode artist)
+                                (utils/encode album)
+                                (utils/encode track-id))
+        track-label (utils/format "%s. %s" track-num track-title)]
     [:li
-     [:a {:href (utils/format "/api/artists/%s/albums/%s/tracks/%s"
-                              (utils/encode artist)
-                              (utils/encode album)
-                              (utils/encode (t "id")))}
-      (utils/format "%s. %s" (t "track") (t "title"))]]))
+     [:a {:href track-url}
+      track-label]]))

 (defn album-detail [artist album]
-  (if (and (not (nil? artist)) (not (nil? album)))
-    [:div
-     [:h1 artist]
-     [:h2 (utils/format "%s - (%s)" (album "name") (album "year"))]
-     [:img {:src
-            (utils/format "/api/artists/%s/albums/%s/image"
-                          (utils/encode artist)
-                          (utils/encode (album "name")))}]
-     [:ul.tracks
-      (map track-detail (album "tracks"))]
-     ])
+  (let [album-name (album "name")
+        album-year (album "year")
+        album-label (utils/format "%s - (%s)" album-name album-year)
+        album-image (utils/format "/api/artists/%s/albums/%s/image"
+                                  (utils/encode artist)
+                                  (utils/encode album-name))
+        tracks (album "tracks")]
+    (if (and (not (nil? artist)) (not (nil? album)))
+      [:div
+       [:h1 artist]
+       [:h2 album-label]
+       [:img {:src album-image}]
+       [:ul.tracks
+        (map track-detail tracks)]
+       ]))
   )

 (defn nav-partial []


CSS fix

CSS fix

--- src/cljs/clojexcms/views/content.cljs
+++ src/cljs/clojexcms/views/content.cljs
@@ -28,7 +28,8 @@
                     (if (:changed-on-server? content)
                       (dom/div {:class "alert alert-warning"
                                 :role "alert"
-                                :style {:margin-top "8px"}}
+                                :style {:margin-top "8px"
+                                        :margin-bottom "0"}}
                                (dom/strong "Warning: ")
                                (str "Content changed server-side by someone else. If you "
                                     "publish now, these changes will be overwritten!")))


replace search component

replace search component

--- src/cljs/phonecat_re_frame/views.cljs
+++ src/cljs/phonecat_re_frame/views.cljs
@@ -1,9 +1,8 @@
 (ns phonecat-re-frame.views
   (:require phonecat-re-frame.subs
             phonecat-re-frame.handlers
-            [reagent.core :as reagent :refer [atom]]
             [re-frame.core :refer [subscribe, dispatch]]
-            [re-com.core :refer [button, h-box, v-box, single-dropdown]])
+            [re-com.core :refer [button, h-box, v-box, single-dropdown, input-text]])
   (:require-macros [reagent.ratom :refer [reaction]]))

 ;; -------------------------
@@ -44,8 +43,12 @@
   "component for the search input"
   []
   (fn []
-    [:div "Search"
-     [:input {:on-change #(dispatch [:search-input-entered (-> % .-target .-value)])}]]))
+    [input-text
+     :model ""
+     :width "150px"
+     :placeholder "Search"
+     :on-change #(dispatch [:search-input-entered %])
+     :change-on-blur? false]))

 (defn order-by-component
   "component to define how you want to order the phones list"
@@ -53,18 +56,19 @@
   (let [order-prop (subscribe [:order-prop])]
     (fn []
       [single-dropdown
-       :choices     [{:id "name" :label "Alphabetically"}
-                     {:id "age" :label "Newest"}]
-       :model       @order-prop
+       :choices [{:id "name" :label "Sort by name"}
+                 {:id "age" :label "Newest first"}]
+       :model @order-prop
        :placeholder "Sort order"
-       :width       "150px"
-       :on-change   #(dispatch [:order-prop-changed %])])))
+       :width "150px"
+       :on-change #(dispatch [:order-prop-changed %])])))

 (defn home-page
   "defines the home page which will be the phone list component"
   []
   [h-box
    :children [[v-box
+               :gap "10px"
                :children [[search-component]
                           [order-by-component]]]
               [v-box


small fix

small fix

--- src/cljs/salava/gallery/ui/block.cljs
+++ src/cljs/salava/gallery/ui/block.cljs
@@ -29,14 +29,15 @@
         {:keys [edit-mode? user-id user]} data]
     (init-grid "badges" data)
     (fn []
-      [:div#user-badges
-       [:div.row
-        [:div.col-md-12
-         [:h3 {:class ""} (t :user/Recentbadges)]
-         [badge-grid (:badges @data) @badge-small-view]
+     (when (seq (:badges @data))
+           [:div#user-badges
+            [:div.row
+             [:div.col-md-12
+              [:h3 {:class ""} (t :user/Recentbadges)]
+              [badge-grid (:badges @data) @badge-small-view]

-         (when (< 6 (count @(cursor data [:badges])))
-          [:div [:a {:href "#" :on-click #(reset! badge-small-view (if @badge-small-view false true))}  (if @badge-small-view (t :admin/Showless) (t :user/Showmore))]])]]])))
+              (when (< 6 (count @(cursor data [:badges])))
+               [:div [:a {:href "#" :on-click #(reset! badge-small-view (if @badge-small-view false true))}  (if @badge-small-view (t :admin/Showless) (t :user/Showmore))]])]]]))))

@@ -45,11 +46,12 @@
         {:keys [edit-mode? user-id user]} data]
     (init-grid "pages" data)
     (fn []
-      [:div#user-pages
-       [:div.row
-        [:div.col-md-12
-         [:h3 {:class ""} (t :user/Recentpages)]
-         [page-grid (:pages @data) (:profile_picture user) @page-small-view]
+      (when (seq (:pages @data))
+       [:div#user-pages
+        [:div.row
+         [:div.col-md-12
+          [:h3 {:class ""} (t :user/Recentpages)]
+          [page-grid (:pages @data) (:profile_picture user) @page-small-view]

-         (when (< 6 (count @(cursor data [:pages])))
-          [:div [:a {:href "#" :on-click #(reset! page-small-view (if @page-small-view false true))}  (if @page-small-view (t :admin/Showless) (t :user/Showmore))]])]]])))
+          (when (< 6 (count @(cursor data [:pages])))
+           [:div [:a {:href "#" :on-click #(reset! page-small-view (if @page-small-view false true))}  (if @page-small-view (t :admin/Showless) (t :user/Showmore))]])]]]))))


Added placeholder and modified validation.

--- src/cljs/back_channeling/components/curation.cljs
+++ src/cljs/back_channeling/components/curation.cljs
@@ -31,6 +31,7 @@
                       {:class "error"})
          [:textarea
           {:value content
+           :placeholder "Input content and press Ctrl+Enter to save."
            :on-change (fn [e]
                         (om/set-state! owner :content
                                        (.. (om/get-node owner) (querySelector "textarea") -value)))
@@ -150,7 +151,11 @@
           [:button.ui.primary.button
            {:on-click (fn [_]
                         (let [article (om/get-state owner :editing-article)
-                              [result map] (b/validate article :article/name v/required)]
+                              [result map] (b/validate article
+                                                       :article/name v/required
+                                                       :article/blocks [[v/every #(not (or (nil? (:curating-block/content %))
+                                                                                (empty? (:curating-block/content %))))
+                                                                         :message "All editable spaces must be saved."]])]
                           (if result
                             (om/set-state! owner :error-map (:bouncer.core/errors map))
                             (if-let [id (:db/id article)]
@@ -166,6 +171,11 @@
                                                  (set! (.-href js/location) (str "#/article/" (:db/id response)))
                                                  (.reload js/location))})))))}
            [:i.save.icon] "Save"]]
+         (when-not (empty? error-map)
+           [:div.ui.error.message
+            (for [[_ messages] error-map]
+              (for [message messages]
+                [:div.header message]))])
          [:div.scroll-pane
           [:div.ui.comments
            (map-indexed
@@ -206,11 +216,14 @@
                    (om/build editorial-space-view curating-block
                              {:state {:content (:curating-block/content curating-block)}
                               :opts {:save-fn (fn [content]
-                                                (om/update-state! owner [:editing-article :article/blocks index ]
-                                                                  (fn [block]
-                                                                    (assoc block
-                                                                           :curating-block/content content
-                                                                           :curating-block/posted-at (js/Date.)))))}})
+                                                (om/update-state! owner
+                                                                  (fn [state]
+                                                                    (-> state
+                                                                        (update-in [:editing-article :article/blocks index]
+                                                                                assoc
+                                                                                :curating-block/content content
+                                                                                :curating-block/posted-at (js/Date.))
+                                                                        (update-in [:error-map] dissoc :article/blocks)))))}})
                    (case (get-in curating-block [:curating-block/format :db/ident])
                      :curating-block.format/markdown {:dangerouslySetInnerHTML {:__html (.render js/md (:curating-block/content curating-block))}}
                      :curating-block.format/voice [:audio {:controls true


Use `clojure.set/rename-keys` instead of doing it the hard way

--- src/com/puppetlabs/puppetdb/http/v2/resources.clj
+++ src/com/puppetlabs/puppetdb/http/v2/resources.clj
@@ -12,11 +12,7 @@
 (defn munge-result-rows
   "Munge the result rows so that they will be compatible with the v2 API specification"
   [rows]
-  (map (fn [r] (-> r
-                 (assoc :sourceline (:line r))
-                 (assoc :sourcefile (:file r))
-                 (dissoc :file :line)))
-    rows))
+  (map #(clojure.set/rename-keys % {:file :sourcefile :line :sourceline}) rows))

 (defn produce-body
   "Given a `limit`, a query, and database connection, return a Ring


implement lt-seq and begin sat-reduction

--- src/main/clojure/conexp/layouts/dim_draw.clj
+++ src/main/clojure/conexp/layouts/dim_draw.clj
@@ -6,6 +6,76 @@
             [conexp.util.graph :refer :all]
             [conexp.base :exclude [transitive-closure] :refer :all]
             [rolling-stones.core :as sat :refer :all]))
+
+(defn- lt-seq
+  ([xs k]
+   (lt-seq xs k (Math/random)))
+  ([xs k prefix]
+   (if (> k 0)
+     (let [n (count xs)
+           s prefix]
+       (concat
+         [[(! (xs 0)) [:tmp s 0 0]]]
+         (map #(vec [(! [:tmp s 0 %])])
+              (vec (range 1 k)))
+         (mapcat (fn [i] (concat [
+                                  [(! (xs i)) [:tmp s i 0]]
+                                  [(! [:tmp s (- i 1) 0]) [:tmp s i 0]]]
+                                 (mapcat (fn [j] [
+                                                  [(! (xs i)) (! [:tmp s (- i 1) (- j 1)]) [:tmp s i j]]
+                                                  [(! [:tmp s (- i 1) j]) [:tmp s i j]]])
+                                         (vec (range 1 k)))
+                                 [[(! (xs i)) (! [:tmp s (- i 1) (- k 1)])]]))
+                 (vec (range 1 (- n 1))))
+         [[(! (xs (- n 1))) (! [:tmp s (- n 2) (- k 1)])]]))
+     (vec (map #(vec [(! %)]) xs)))))
+
+(def cnf (lt-seq [:x1 :x2 :x3] 0 "s"))
+(println cnf)
+(println)
+(doseq [line (sat/solutions-symbolic-cnf cnf)]
+  (println line))
+
+(defn sat-reduction
+  ([g]
+   (first (drop-while #(= % nil) (map #(sat-reduction g %) (range)))))
+  ([g k]
+   (let [node-clauses (mapcat
+                        #(vec [[[% 1] [% 2] [% 3]]          ;either V_{i,1}, V_{i,2}, or V_{i,3} is true
+                               [(! [% 1]) (! [% 2])]        ;but not two of them
+                               [(! [% 2]) (! [% 3])]
+                               [(! [% 3]) (! [% 1])]])
+                        (nodes g))
+         ;edge-clauses (mapcat
+         ;               #(let [vi (:src %) vj (:dest %)]
+         ;                  [[[vi 1] [vj 1]] [[vi 2] [vj 2]]])
+         ;               (lg/edges g))
+         edge-clauses (mapcat
+                        #(let [vi (:src %) vj (:dest %)]
+                           [[[vi 1] [vj 1] [vi 2] [vj 2]]
+                            [[vi 2] [vj 2] [vi 3] [vj 3]]
+                            [[vi 3] [vj 3] [vi 1] [vj 1]]])
+                        (lg/edges g))
+         no-more-than-k-bad-edges-clauses (lt-seq
+                                            (vec (map #(vec [% 3]) (nodes g)))
+                                            k "s")
+         clauses (concat node-clauses edge-clauses no-more-than-k-bad-edges-clauses)
+         expected [[[:a 1]] [[:b 2]] [[:c 2]] [[:e 3]]]
+         ]
+     (println node-clauses)
+     (println edge-clauses)
+     (println no-more-than-k-bad-edges-clauses)
+     (println "solved:")
+     (println (sat/solve-symbolic-cnf clauses))
+     (println (sat/solve-symbolic-cnf (concat expected node-clauses)))
+     (println (sat/solve-symbolic-cnf (concat expected edge-clauses)))
+     (println (sat/solve-symbolic-cnf (concat expected no-more-than-k-bad-edges-clauses)))
+     (println (sat/solve-symbolic-cnf (concat expected node-clauses edge-clauses)))
+     (println (sat/solve-symbolic-cnf (concat expected edge-clauses no-more-than-k-bad-edges-clauses)))
+     (println (sat/solve-symbolic-cnf (concat expected no-more-than-k-bad-edges-clauses node-clauses)))
+     )))
+
+(sat-reduction (uber/digraph [:a :b] [:a :c] [:b :e] [:c :e] [:a :e]) 1)

 (defn compute-conjugate-order
   [P <=]
@@ -87,10 +157,6 @@
 (draw-ascii (compute-coordinates
               #{1 2 3 4 5} (non-strict #(or (= 1 %1) (= 5 %2)))))

-(defn sat-test
-  []
-  (println (sat/solve [[1] [1 2] [-1 2 -3]])))

-(sat-test)

 nil


fix to schema

fix to schema

--- src/braid/common/schema.cljc
+++ src/braid/common/schema.cljc
@@ -37,7 +37,7 @@

     #(= :tag (first %))
     [(s/one (s/eq :tag) "rule") (s/one s/Uuid "id")]))
-(def NotifyRules "User notification rules" [Rule])
+(def NotifyRules "User notification rules" [NotifyRule])
 (def rules-valid? (s/validator NotifyRules))

 (def Extension


shutdown c* sessions properly

shutdown c* sessions properly

--- src/er_cassandra/session/alia.clj
+++ src/er_cassandra/session/alia.clj
@@ -45,6 +45,13 @@
        (h/->raw statement)))
    opts))

+(defn shutdown-session-and-cluster
+  [session]
+  (info "closing underlying alia session and cluster")
+  (let [cluster (.getCluster session)]
+    (alia/shutdown session)
+    (alia/shutdown cluster)))
+
 (defnk ^:private create-alia-session*
   [contact-points
    datacenter
@@ -74,7 +81,7 @@
   (execute-buffered [_ statement opts]
     (execute-buffered* alia-session statement opts))
   (close [_]
-    (.close alia-session)))
+    (shutdown-session-and-cluster alia-session)))

 (defnk create-session
   [contact-points datacenter keyspace :as args]
@@ -123,7 +130,7 @@
   (close [self]
     (when truncate-on-close
       (truncate-spy-tables self))
-    (.close alia-session))
+    (shutdown-session-and-cluster alia-session))

   KeyspaceProvider
   (keyspace [_] keyspace)


Hide new button in leaf chats

Hide new button in leaf chats

--- src/chat/cljs/virt/chat.cljs
+++ src/chat/cljs/virt/chat.cljs
@@ -13,7 +13,7 @@
 (defn header [app owner]
   (reify
     om/IRenderState
-    (render-state [_ {:keys [comm]}]
+    (render-state [_ {:keys [comm show-new-button]}]
       (dom/header nil
         (dom/div nil
           (dom/button #js {:id "home-button"
@@ -23,10 +23,11 @@
         (dom/div nil
           (dom/div #js {:id "header-title"} "Chat"))
         (dom/div nil
-          (dom/button #js {:id "new-button"
-                           :className "transparent-button"
-                           :onClick #(put! comm [:navigate :new])}
-                      "New"))))))
+          (if show-new-button
+            (dom/button #js {:id "new-button"
+                             :className "transparent-button"
+                             :onClick #(put! comm [:navigate :new])}
+                        "New")))))))

 (defn leaf-chat [chat owner {:keys [chat-id]}]
   (reify
@@ -131,11 +132,11 @@
                     nil)))))))
     om/IRenderState
     (render-state [_ {:keys [comm page-id]}]
-      (dom/div nil
-        (dom/div #js {:id "header"}
-          (om/build header app {:init-state {:comm comm}}))
-        (dom/div #js {:id "content"}
-          (let [m {:init-state {:comm comm}}]
+      (let [m {:init-state {:comm comm}}]
+        (dom/div nil
+          (dom/div #js {:id "header"}
+            (om/build header app (assoc m :state {:show-new-button (= page-id nil)})))
+          (dom/div #js {:id "content"}
             (case page-id
               :new (om/build new-chat app m)
               nil (om/build chat-root app m)


Document lambdacd.runners

Document lambdacd.runners

--- src/clj/lambdacd/runners.clj
+++ src/clj/lambdacd/runners.clj
@@ -1,4 +1,6 @@
 (ns lambdacd.runners
+  "Runners are what keeps a pipeline going. The start new builds based on some logic,
+   e.g. when the previous build is finished or (e.g if the first step is a trigger) after the first step is done."
   (:require [lambdacd.execution.core :as execution]
             [clojure.core.async :as async]
             [lambdacd.event-bus :as event-bus]
@@ -17,7 +19,9 @@
   should-trigger-next-build?
   (every-pred is-first-step? is-not-retriggered?))

-(defmacro while-not-stopped [ctx & body]
+(defmacro while-not-stopped
+  "Execute a runners body until it is stopped from the outside (usually by someone calling `stop-runner`, e.g. on shutdown)."
+  [ctx & body]
   `(let [running# (atom true)]
      (async/go
        (async/<! (event-bus/subscribe ~ctx :stop-runner))
@@ -27,7 +31,7 @@
      (log/info "Runner stopped. No new pipeline instances will be spawned.")))

 (defn start-new-run-after-first-step-finished
-  "Runner that makes sure there is always one pipeline-run with the first step active. useful if the first step is waiting for
+  "Runner that makes sure there is always one pipeline-run with the first step active. Useful if the first step is waiting for
   a trigger such as a VCS commit and you don't want to wait for the whole pipeline to complete before starting the next run.
   Do not use this if your first step finishes immediately as this will lead to lots of active pipelines"
   [{pipeline-def :pipeline-def context :context}]
@@ -41,12 +45,16 @@
         (async/<!! first-steps-finisehd)))))

 (defn start-one-run-after-another
-  "Runner that always keeps one pipeline-run active. It waits for a run to complete, then starts a new one."
+  "Runner that always keeps one pipeline-run active. It waits for a run to complete, then starts a new one.
+  Commonly used when running multiple pipelines in parallel is not an option or the pipeline has no trigger."
   [{pipeline-def :pipeline-def context :context}]
  (async/thread
    (while-not-stopped context
      (execution/run-pipeline pipeline-def context))))

-(defn stop-runner [ctx]
+(defn stop-runner
+  "Triggers an event that will stop runners so they no longer start new pipeline-runs.
+  Does not stop running pipelines and does not wait for runners to stop."
+  [ctx]
   (log/info "Stopping runner...")
   (event-bus/publish!! ctx :stop-runner {}))


apply evidence settings to badge pdf

apply evidence settings to badge pdf

--- src/clj/salava/badge/pdf.clj
+++ src/clj/salava/badge/pdf.clj
@@ -34,7 +34,7 @@
                          (dissoc :content)
                          (assoc :qr_code (str->qr-base64 (badge-url ctx (:id %1)))
                            :endorsements (vec (select-badge-endorsements {:id (:badge_id %1)} (u/get-db ctx)))
-                           :evidences (badge-evidences ctx (:id %1))
+                           :evidences (remove (fn [e] (= true (get-in e [:properties :hidden]))) (badge-evidences ctx (:id %1) user-id))
                            :content %2)) badge-with-content temp)]
     (replace-nils badges)))


fix params passed into grant creation

fix params passed into grant creation

--- src/clj_money/web/grants.clj
+++ src/clj_money/web/grants.clj
@@ -2,6 +2,7 @@
   (:refer-clojure :exclude [update])
   (:require [clojure.tools.logging :as log]
             [clojure.pprint :refer [pprint]]
+            [clojure.set :refer [rename-keys]]
             [environ.core :refer [env]]
             [hiccup.core :refer :all]
             [hiccup.page :refer :all]
@@ -161,7 +162,9 @@
   (let [grant (-> params
                   (select-keys [:entity-id])
                   (assoc :permissions (extract-permissions params)
-                         :user-id (:id (find-or-create-user (:user params))))
+                         :user-id (:id (find-or-create-user (-> params
+                                                                (select-keys [:user])
+                                                                (rename-keys {:user :email})))))
                   (tag-resource :grant)
                   (authorize :create))
         result (grants/create (env :db) grant)]


more work on text

more work on text

--- src/cljs/fluch/terminal.cljs
+++ src/cljs/fluch/terminal.cljs
@@ -39,23 +39,22 @@
                    ::out-channel
                    ::options]))

-(defn process-input-text [terminal text]
-  (cond
-    (.startsWith text "\n")
-    (do
-
-      )
-    ))
+(declare process-input-text)

 (defprotocol ITerminal
   (init [this])
   (current-position [this])
   (move-to! [this col row])
   (put-char! [this char])
+  (delete-char! [this])
   (up-char! [this])
   (right-char! [this])
   (down-char! [this])
   (left-char! [this])
+  (beginning-of-line! [this])
+  (end-of-line! [this])
+  (new-line! [this])
+  (delete-backward-char! [this])
   (in> [this input options])
   (in>> [this input options])
   (refresh! [this])
@@ -75,14 +74,20 @@
           (case type
             :key-press
             (>! in-channel key)
+            :key-press-special
+            (case key
+              :backspace
+              (>! in-channel "\b")
+              :enter
+              (>! in-channel "\n")
+              nil)
             nil)
           )
         (recur)))

     (go-loop []
       (let [text (<! in-channel)]
-        (put-char! this text)
-        (right-char! this)
+        (process-input-text this text)
         (refresh! this))
       (recur)))

@@ -95,6 +100,10 @@
   (put-char! [this char]
     (let [[i j] (current-position this)]
       (reset! screen (screen/put-char @screen char i j {}))))
+
+  (delete-char! [this]
+    (let [[i j] (current-position this)]
+      (reset! screen (screen/clear-block @screen i j))))

   (up-char! [this]
     (let [[i j] (current-position this)]
@@ -121,6 +130,23 @@
       (when (> i 0)
         (move-to! this (dec i) j))))

+  (beginning-of-line! [this]
+    (let [[i j] (current-position this)]
+      (move-to! this 0 j)))
+
+  (end-of-line! [this]
+    (let [[i j] (current-position this)
+          {:keys [rows cols]} @screen]
+      (move-to! this (dec cols) j)))
+
+  (new-line! [this]
+    (down-char! this)
+    (beginning-of-line! this))
+
+  (delete-backward-char! [this]
+    (left-char! this)
+    (delete-char! this))
+
   (in> [this input options])

   (in>> [this input options])
@@ -131,6 +157,25 @@
   (out< [this options])

   (out<< [this callback options]))
+
+(defn process-input-text [terminal text]
+  (loop [text text]
+    (cond
+      (<= (count text) 0)
+      nil
+      (.startsWith text "\n")
+      (do
+        (new-line! terminal)
+        (recur (-> text rest rest)))
+      (.startsWith text "\b")
+      (do
+        (delete-backward-char! terminal)
+        (recur (-> text rest rest)))
+      :else
+      (do
+        (put-char! terminal (first text))
+        (right-char! terminal))
+      )))

 (defn terminal
   [screen


copy paste now without delay

copy paste now without delay

--- src/cljs/spaghetti/core.cljs
+++ src/cljs/spaghetti/core.cljs
@@ -27,23 +27,19 @@
 (defn focus-input [e app owner]
   (if (and (or (.-ctrlKey e) (.-metaKey e)) (not= (.-keyCode e) 86))
     (let [node (om/get-node owner)]
-      (prn "focus: " (t/write w @app))
       (set! (.-value node) (t/write w @app))
       (.select node))))

 (defn paste-state [app owner]
-  (let [input-data (.-value (om/get-node owner))
-        new-state (t/read r input-data)]
-     (prn "paste: " new-state)
-     (om/update! app new-state)))
+  (let [input-data (.-value (om/get-node owner))]
+     (om/update! app (t/read r input-data))))

 (defcomponent clipboard [app owner]
   (did-mount [_]
     (.listen goog/events js/document "keydown" #(focus-input % app owner)))
   (render [_]
-          (html [:input {:type "textarea" ;:style {:opacity 0}
-                         :onPaste (fn [] (js/setTimeout (paste-state app owner) 200))
-                         }])))
+          (html [:input {:type "textarea" :style {:opacity 0}
+                         :onPaste (fn [] (js/setTimeout #(paste-state app owner) 30))}])))

 (defn add-node
   [app n x y]


Clarify MonadTrans docstrings

Clarify MonadTrans docstrings

--- src/cljx/cats/protocols.cljx
+++ src/cljx/cats/protocols.cljx
@@ -67,6 +67,11 @@
   (local [m f reader] "Create a reader in a modified version of the environment."))

 (defprotocol MonadTrans
-  (inner [mt] "Return the inner monad of this transformer.")
-  (outer [mt] "Return the outer monad of this transformer.")
-  (lift [m mv] "Lift a value from the inner monad to the outher monad."))
+  (outer [mt]
+    "Return the outer monad of this transformer. The values of the transformer
+     are values whose context is this monad.")
+  (inner [mt]
+    "Return the inner monad of this transformer. The values of the transformer
+     contain a value whose context is this monad.")
+  (lift [m mv]
+    "Lift a value from the parameterized monad to the transformer."))


add tuple print methods

add tuple print methods

--- src/clojure/flambo/tuple.clj
+++ src/clojure/flambo/tuple.clj
@@ -1,7 +1,8 @@
 (ns flambo.tuple
   (:require [serializable.fn :as sfn])
   (:import [scala Tuple2]
-           [flambo.function AbstractFlamboFunction]))
+           [flambo.function AbstractFlamboFunction]
+           [java.io Writer]))

 (set! *warn-on-reflection* true)

@@ -17,3 +18,9 @@
     (let [k (._1 t)
           v ^Tuple2 (._2 t)]
       (f k (._1 v) (._2 v)))))
+
+(defmethod print-method Tuple2 [^Tuple2 o ^Writer w]
+  (.write w (str "#flambo/tuple " (pr-str [(._1 o) (._2 o)]))))
+
+(defmethod print-dup Tuple2 [o w]
+  (print-method o w))


Added Layout selection to lattice editor

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

--- src/conexp/graphics/draw.clj
+++ src/conexp/graphics/draw.clj
@@ -1,6 +1,8 @@
 (ns conexp.graphics.draw
   (:use [conexp.util :only (update-ns-meta!, get-root-cause, with-swing-error-msg)]
+	[conexp.base :only (defvar-)]
 	[conexp.layout :only (*standard-layout-function*)]
+	[conexp.layout.base :only (lattice)]
 	[conexp.layout.force :only (force-layout,
 				    layout-energy,
 				    *repulsive-amount*,
@@ -19,7 +21,7 @@
 	clojure.contrib.swing-utils)
   (:import [javax.swing JFrame JPanel JButton JTextField JLabel
 	                JOptionPane JSeparator SwingConstants
-	                BoxLayout Box JScrollBar]
+	                BoxLayout Box JScrollBar JComboBox]
 	   [java.awt Canvas Color Dimension BorderLayout GridLayout Component Graphics]
 	   [java.awt.event ActionListener]))

@@ -27,15 +29,18 @@
   :doc "This namespace provides a lattice editor and a convenience function to draw lattices.")

-;;; lattice editor -- a lot TODO
-
-(declare make-button, make-label, make-labeled-text-field, make-padding, make-separator)
+;;; Lattice Editor
+
+(declare make-button, make-label, make-labeled-text-field,
+	 make-padding, make-separator, make-combo-box)
+

 ;; editor features

 (defn- change-parameters
   "Installs parameter list which influences lattice drawing."
   [frame scn buttons]
+  ;; node radius
   (let [#^JTextField node-radius (make-labeled-text-field buttons "radius" (str *default-node-radius*))]
     (add-action-listener node-radius (fn [evt]
 				       (let [new-radius (Double/parseDouble (.getText node-radius))]
@@ -43,10 +48,23 @@
 					  (do-nodes [n scn]
 					   (set-node-radius! n new-radius))
 					  (redraw-scene scn))))))
+
   ;; labels
-  ;; layout
+
+  ;; layouts
+  (let [layouts {"standard" *standard-layout-function*},
+	#^JComboBox combo-box (make-combo-box buttons (keys layouts))]
+    (add-action-listener combo-box
+			 (fn [evt]
+			   (let [selected (.. evt getSource getSelectedItem),
+				 layout-fn (get layouts selected)]
+			     (update-layout-of-scene
+			      scn
+			      (layout-fn (lattice (get-layout-from-scene scn))))))))
+
   ;; move mode (ideal, filter, chain, single)
   nil)
+

 ;; improve with force layout

@@ -72,16 +90,16 @@
 	#^JButton button          (make-button buttons "Force"),

 	get-force-parameters      (fn []
-				    (with-swing-error-msg frame "Invalid Parameter given."
-				     (let [r (Double/parseDouble (.getText rep-field)),
-					   a (Double/parseDouble (.getText attr-field)),
-					   g (Double/parseDouble (.getText grav-field)),
-					   i (Integer/parseInt (.getText iter-field))]
-				       [r a g i])))]
+				    (let [r (Double/parseDouble (.getText rep-field)),
+					  a (Double/parseDouble (.getText attr-field)),
+					  g (Double/parseDouble (.getText grav-field)),
+					  i (Integer/parseInt (.getText iter-field))]
+				      [r a g i]))]
     (add-action-listener button (fn [evt]
 				  (with-swing-error-msg frame "An Error occured."
 				   (let [[r a g i] (get-force-parameters)]
 				     (improve-with-force scn i r a g)))))))
+

 ;; zoom-move

@@ -107,14 +125,85 @@
 			      ;; TODO: Show current zoom factor
 			      (.setText zoom-info "??"))))))

-;;
+
+;; export images to files

 (defn- export-as-file
   "Installs a file exporter."
   [frame scn buttons]
   nil)

-;; technical helpers
+
+;;; Buttons, Labels and the like
+
+(defvar- *item-width* 100
+  "Width of items in toolbar.")
+
+(defvar- *item-height* 25
+  "Heights of items on toolbar.")
+
+(defvar- *toolbar-width* (+ 10 *item-width*)
+  "Width of toolbar containing buttons, labels and so on.")
+
+(defn- make-padding
+  "Adds a padding to buttons."
+  [buttons]
+  (.add buttons (Box/createRigidArea (Dimension. 0 2))))
+
+(defn- make-separator
+  "Adds a separator to buttons."
+  [buttons]
+  (let [sep (JSeparator. SwingConstants/HORIZONTAL)]
+    (.setMaximumSize sep (Dimension. *item-width* 1))
+    (.add buttons sep)
+    sep))
+
+(defn- make-button
+  "Uniformly creates buttons for lattice editor."
+  [buttons text]
+  (let [button (JButton. text)]
+    (.add buttons button)
+    (.setAlignmentX button Component/CENTER_ALIGNMENT)
+    (.setMaximumSize button (Dimension. *item-width* *item-height*))
+    button))
+
+(defn- make-label
+  "Uniformly creates labels for lattice editor."
+  [buttons text]
+  (let [label (JLabel. text)]
+    (.add buttons label)
+    (.setMaximumSize label (Dimension. *item-width* *item-height*))
+    (.setAlignmentX label Component/CENTER_ALIGNMENT)
+    (.setHorizontalAlignment label SwingConstants/CENTER)
+    label))
+
+(defn- make-labeled-text-field
+  "Uniformly creates a text field for lattice editor."
+  [buttons label text]
+  (let [#^JTextField text-field (JTextField. text),
+	#^JLabel label (JLabel. label),
+	#^JPanel panel (JPanel.)]
+    (doto panel
+      (.add label)
+      (.add text-field)
+      (.setMaximumSize (Dimension. *item-width* *item-height*)))
+    (.setPreferredSize label (Dimension. (* 0.4 *item-width*) (* 0.8 *item-height*)))
+    (.setPreferredSize text-field (Dimension. (* 0.5 *item-width*) (* 0.8 *item-height*)))
+    (.add buttons panel)
+    text-field))
+
+(defn- make-combo-box
+  "Uniformly creates a combo box from the given choices. First item is
+  selected by default."
+  [buttons choices]
+  (let [#^JComboBox combo-box (JComboBox. (into-array String choices))]
+    (doto combo-box
+      (.setMaximumSize (Dimension. *item-width* *item-height*)))
+    (.add buttons combo-box)
+    combo-box))
+
+
+;;; Technical Helpers

 (defmacro install-changers
   "Installs given methods to scene with buttons."
@@ -129,54 +218,8 @@
 			 (make-padding buttons))
 		       methods))))

-(defn- make-padding
-  "Adds a padding to buttons."
-  [buttons]
-  (.add buttons (Box/createRigidArea (Dimension. 0 2))))
-
-(defn- make-separator
-  "Adds a separator to buttons."
-  [buttons]
-  (let [sep (JSeparator. SwingConstants/HORIZONTAL)]
-    (.setMaximumSize sep (Dimension. 100 1))
-    (.add buttons sep)
-    sep))
-
-(defn- make-button
-  "Uniformly creates buttons for lattice editor."
-  [buttons text]
-  (let [button (JButton. text)]
-    (.add buttons button)
-    (.setAlignmentX button Component/CENTER_ALIGNMENT)
-    (.setMaximumSize button (Dimension. 100 20))
-    button))
-
-(defn- make-label
-  "Uniformly creates labels for lattice editor."
-  [buttons text]
-  (let [label (JLabel. text)]
-    (.add buttons label)
-    (.setMaximumSize label (Dimension. 100 25))
-    (.setAlignmentX label Component/CENTER_ALIGNMENT)
-    (.setHorizontalAlignment label SwingConstants/CENTER)
-    label))
-
-(defn- make-labeled-text-field
-  "Uniformly creates a text field for lattice editor."
-  [buttons label text]
-  (let [#^JTextField text-field (JTextField. text),
-	#^JLabel label (JLabel. label),
-	#^JPanel panel (JPanel.)]
-    (doto panel
-      (.add label)
-      (.add text-field)
-      (.setMaximumSize (Dimension. 100 25)))
-    (.setPreferredSize label (Dimension. 40 20))
-    (.setPreferredSize text-field (Dimension. 50 20))
-    (.add buttons panel)
-    text-field))
-
-;; constructor
+
+;;; Constructor

 (defn make-lattice-editor
   "Creates a lattice editor for lattice with initial layout."
@@ -193,7 +236,7 @@
 	#^JPanel buttons (JPanel.),
 	box-layout (BoxLayout. buttons BoxLayout/Y_AXIS)]
     (.setLayout buttons box-layout)
-    (.setPreferredSize buttons (Dimension. 110 0))
+    (.setPreferredSize buttons (Dimension. *toolbar-width* 0))
     (install-changers frame scn buttons
       toggle-zoom-move
       change-parameters
@@ -210,7 +253,7 @@
     main-panel))

-;;; drawing routine for the repl
+;;; Drawing Routine for the REPL

 (defn draw-lattice
   "Draws given lattice with given layout-function on a canvas and returns


Modified 'upgrade' task to operate on list of artifacts-to-upgrade.

--- src/leiningen/ancient/upgrade.clj
+++ src/leiningen/ancient/upgrade.clj
@@ -21,186 +21,152 @@
 ;; check functions to find the artifacts that need updating and rewrite-clj to
 ;; create the updated project map.

-(defn upgrade-project-file!*
-  [settings path]
-  (when-let [project (read-project-map! path)]
-    (let [repos (collect-repositories project)
-          artifacts (collect-artifacts project settings)]
-      (with-settings settings
-        (let [outdated (c/get-outdated-artifacts! repos settings artifacts)]
-          ;; TODO: Use Zipper to update
-          )))))
-
 ;; ## Prompt

-(defn- prompt-for-upgrade
+(defn- prompt-for-upgrade!
   "If the `:interactive` flag in the given settings map is set, this function will ask the
    user (on stdout/stdin) whether he wants to upgrade the given artifact and return a boolean
    value indicating the user's choice."
-  [settings group-id artifact-id latest version]
-  (or
-    (not (:interactive settings))
-    (do
-      (println)
-      (println (artifact-string group-id artifact-id latest)
-               "is available but we use"
-               (yellow (version-string version)))
-      (prompt "Do you want to upgrade?"))))
+  [settings {:keys [group-id artifact-id latest version]}]
+  (when latest
+    (or
+      (not (:interactive settings))
+      (do
+        (println)
+        (println (artifact-string group-id artifact-id latest)
+                 "is available but we use"
+                 (yellow (version-string version)))
+        (prompt "Do you want to upgrade?")))))

-;; ## Upgrade
+(defn- filter-artifacts-with-prompt!
+  "Given a seq of artifacts (with the ':latest' key set), retain only those
+   that should be upgraded. If ':interactive' is set in the settings map
+   this is decided by prompting the user."
+  [settings artifacts]
+  (filter
+    (partial prompt-for-upgrade! settings)
+    artifacts))

-(defn- upgrade-dependency!
-  "Given a zipper node containing a single artifact's dependency vector `[artifact version]`
-   check if newer versions are available and replace if so."
-  [zloc repos settings]
-  (or
-    (let [prompt! (partial prompt-for-upgrade settings)]
-      (when (z/vector? zloc)
-        (let [{:keys [group-id artifact-id version] :as artifact} (anc/artifact-map (z/sexpr zloc)) ]
-          (when (or (:check-clojure settings)
-                    (not= (str group-id "/" artifact-id) "org.clojure/clojure"))
-            (when-let [latest (anc/artifact-outdated? settings repos artifact)]
-              (when (prompt! group-id artifact-id latest version)
-                (println "Upgrade to" (artifact-string group-id artifact-id latest)
-                         "from" (yellow (version-string version)))
-                (z/subedit-> zloc z/down z/right (z/replace (first latest)))))))))
-    zloc))
+;; ## Zipper Helpers

-(defn- upgrade-dependencies!
-  "Given a zipper node containing a vector of artifact vectors `[[artifact version] ...]`, perform
-   upgrading mechanism on each one of them."
-  [zloc repos settings]
-  (if-not (z/vector? zloc)
-    zloc
-    (z/map #(upgrade-dependency! % repos settings) zloc)))
+(defn- move-to-value-or-index
+  "This goes to the value preceded by a given keyword or the node
+   at a given position right of the current one."
+  [zloc p]
+  (cond (not zloc) nil
+        (integer? p) (nth (iterate z/right zloc) p)
+        (keyword? p) (when-let [floc (z/find-value zloc p)]
+                       (when-let [floc (z/right floc)]
+                         (z/down floc)))
+        :else nil))

-(defn- upgrade-project-key!
-  "Given a zipper node containing the 'defproject' structure, find a given key and upgrade the
-   dependencies following it."
-  [repos settings proj k]
-  (or
-    (when-let [n (z/find-value (z/down proj) k)]
-      (when-let [v (z/right n)]
-        (when-let [r (upgrade-dependencies! v repos settings)]
-          (z/up r))))
-    proj))
+(defn- move-to-path
+  "Given a path seq (consisting of map keys and indices) move to a zipper location
+   represented by the given path."
+  [zloc ps]
+  (reduce move-to-value-or-index zloc ps))

-(defn- upgrade-profiles-key!
-  "Given a zipper node containing the 'defproject' structure, find a given key in each profile
-   and upgrade the dependencies following it."
-  [repos settings proj k]
-  (or
-    (when-let [profiles-key (-> proj z/down (z/find-value :profiles))]
-      (when-let [profiles (z/right profiles-key)]
-        (when (z/map? profiles)
-          (->> profiles
-            (z/map
-              (fn [loc]
-                (when (z/map? loc)
-                  (if-let [n (z/get loc k)]
-                    (z/up (upgrade-dependencies! n repos settings))
-                    loc))))
-            z/up))))
-    proj))
+(defn- read-project-zipper!
+  "Read rewrite-clj zipper from project file."
+  [path]
+  (try
+    (when-let [loc (z/of-file path)]
+      (when-let [loc (z/find-value loc z/next 'defproject)]
+        (z/up loc)))
+    (catch Exception ex
+      (println (red "ERROR:") "could not create zipper from file at:" path)
+      nil)))

-(defn- upgrade-project!
-  "Given a zipper representing the contents of the `project.clj` file, upgrade everytihng allowed
-   in the given settings map using the given retrievers."
-  [repos settings zloc]
-  (let [upgrade-proj! (partial upgrade-project-key! repos settings)
-        upgrade-prof! (partial upgrade-profiles-key! repos settings)
-        deps? (:dependencies settings)
-        plugins? (:plugins settings)
-        upgrading-steps (concat
-                          (when deps? [#(upgrade-proj! % :dependencies)])
-                          (when plugins? [#(upgrade-proj! % :plugins)])
-                          (when (:profiles settings)
-                            (concat
-                              (when deps? [#(upgrade-prof! % :dependencies)])
-                              (when plugins? [#(upgrade-prof! % :plugins)]))))]
-    (or
-      (if-let [proj (z/find-value zloc z/next 'defproject)]
-        (reduce
-          (fn [proj f]
-            (f proj))
-          (z/up proj) upgrading-steps)
-        (println "Could not find valid project map '(defproject ...)'."))
-      zloc)))
-
-(defn- upgrade-profiles-plugins!
-  "Given a zipper location containing a map of profiles, update the profile plugins."
-  [repos settings zloc]
-  (when-let [zloc (z/find-tag zloc z/next :map)]
-    (z/map
-      (fn [loc]
-        (or
-          (when (z/map? loc)
-            (when-let [plugins (z/get loc :plugins)]
-              (-> plugins
-                (upgrade-dependencies! repos settings)
-                z/up)))
-          loc))
-      zloc)))
-
-;; ## Handle Files
-
-(defn- write-clojure-file!
-  "Write Clojure File. Returns `::ok` if data was written to disk, and `::failure`
-   if something fails."
-  [^File f data settings]
+(defn- write-zipper!
+  "Write zipper back to file. Returns true if data was written to disk."
+  [^String path zloc settings]
   (try
     (if (:print settings)
       (do
         (println)
-        (z/print-root data)
+        (z/print-root zloc)
         (println))
-      (binding [*out* (io/writer f)]
-        (z/print-root data)
+      (binding [*out* (io/writer path)]
+        (z/print-root zloc)
         (.flush ^java.io.Writer *out*)
-        ::ok))
+        true))
     (catch Exception ex
-      (println (red "An error occured while writing the generated data:") (.getMessage ex))
-      ::failure)))
+      (println (red "An error occured while writing the generated data:") (.getMessage ex)))))

-(defn- read-clojure-file!
-  "Read Clojure File. Prints errors and returns `nil` if a failure occurs;
-   otherwise a rewrite-clj zipper is returned."
-  [^File f]
-  (try
-    (z/of-file f)
-    (catch Exception ex
-      (println (red "Could not read artifacts from file:") (.getMessage ex))
-      nil)))
+;; ## Zipper Update

-(defn- upgrade-file-with-backup!
-  "Given a Clojure file and an upgrade function, upgrade everything allowed
-   in the given settings map using the given repositories and write result back
-   to file, creating a backup file first."
-  [upgrade-fn ^File f project repos settings]
-  (verbose "Upgrading artifacts in: " (.getCanonicalPath f))
-  (when-let [backup (create-backup-file! f settings)]
-    (when-let [src-data (read-clojure-file! f)]
-      (when-let [data (upgrade-fn repos settings src-data)]
-        (condp = (write-clojure-file! f data settings)
-          ::failure (replace-with-backup! f backup)
-          ::ok (if (or (not (:tests settings)) (t/run-tests-with-refresh! project))
-                 (delete-backup-file! backup)
-                 (replace-with-backup! f backup))
-          (delete-backup-file! backup))))))
+(defn- upgrade-artifact-node!
+  "Use the path stored in the artifact map to find it in the zipper and
+   upgrade its version."
+  [map-loc settings {:keys [group-id artifact-id version latest] :as artifact}]
+  (or
+    (when-let [zloc (when map-loc (z/down map-loc))]
+      (when-let [path (artifact-path artifact)]
+        (when-let [artifact-loc (move-to-path zloc path)]
+          (when (z/vector? artifact-loc)
+            (z/assoc artifact-loc 1 (first latest))))))
+    map-loc))

-(defn- upgrade-file!
-  "Given a Clojure file (as `java.io.File`) and a upgrade function, upgrade everything allowed in
-   the given settings map using the given retrievers and write result back to the file."
-  [upgrade-fn ^File f project repos settings]
-  (if-not (and (.isFile f) (.exists f))
-    (println "No such file:" (.getPath f))
-    (upgrade-file-with-backup! upgrade-fn f project repos settings)))
+(defn- upgrade-artifact-map!
+  "Given a zipper residing on a map (or map-like structure, e.g. defproject s-expr) and
+   a seq of outdated artifacts (containing the `:latest` key with the version to upgrade to),
+   upgrade the zipper to contain the respective versions."
+  [map-loc settings artifacts]
+  (reduce
+    (fn [map-loc artifact]
+      (z/subedit-> map-loc (upgrade-artifact-node! settings artifact)))
+    map-loc artifacts))

-(def ^:private upgrade-project-file!
-  (partial upgrade-file! upgrade-project!))
+(defn upgrade-artifact-file!
+  "Upgrade an artifact file. We need:
+   - a function that produces the data contained in the file
+   - two collect functions that retrieve repositories and artifact maps from that data
+   - a function that creates a rewrite-clj zipper from the file
+   These parts depend on whether you want to read a project or profiles file.
+   Behaviour can be modified by supplying different settings maps.

-(def ^:private upgrade-profiles-file!
-  (partial upgrade-file! upgrade-profiles-plugins!))
+   This will return true, if changes were made; nil otherwise."
+  [read-map-fn collect-repo-fn collect-artifact-fn read-zipper-fn settings path]
+  (when-let [artifact-map (read-map-fn path)]
+    (let [repos (collect-repo-fn artifact-map)
+          artifacts (collect-artifact-fn artifact-map settings)]
+      (with-settings settings
+        (when-let [outdated (seq
+                              (->> artifacts
+                                (c/get-outdated-artifacts! repos settings)
+                                (filter-artifacts-with-prompt! settings)))]
+          (when-let [map-loc (read-zipper-fn path)]
+            (when-let [new-loc (upgrade-artifact-map! map-loc settings outdated)]
+              (write-zipper! path new-loc settings))))))))
+
+(def ^:private upgrade-project-file!*
+  "Upgrade the project file (containing 'defproject') at the given path using the given
+   settings."
+  (partial upgrade-artifact-file!
+           read-project-map!
+           collect-repositories
+           collect-artifacts
+           read-project-zipper!))
+
+;; ## Upgrade w/ Backup
+
+(defn- with-backup
+  "Wraps a given function to produce/restore backup files. Returns true
+   if new data was written to disk."
+  [upgrade-fn]
+  (fn [settings path]
+    (let [^File f (io/file path)
+          ^String path (.getCanonicalPath f)]
+      (verbose "Upgrading artifacts in: " path)
+      (when-let [backup (create-backup-file! f settings)]
+        (if (upgrade-fn settings path)
+          (do (delete-backup-file! backup) true)
+          (do (replace-with-backup! f backup) nil))))))
+
+(def upgrade-project-file!
+  "Run upgrade on the given project file using the given settings."
+  (-> upgrade-project-file!*
+    with-backup))

 ;; ## Task

@@ -209,16 +175,13 @@
   [{:keys [root] :as project} args]
   (if-not root
     (println "'upgrade' can only be run inside of project.")
-    (let [project-file (io/file root "project.clj")
-          settings (parse-cli args)
-          repos (collect-repositories project)]
-      (with-settings settings
-        (upgrade-project-file! project-file project repos settings)))))
+    (let [settings (parse-cli args)]
+      (upgrade-project-file! (io/file root "project.clj") settings))))

 (defn run-upgrade-global-task!
   "Run plugin upgrade on global profiles."
   [project args]
-  (let [profiles-file (io/file (System/getProperty "user.home") ".lein" "profiles.clj")
+  #_(let [profiles-file (io/file (System/getProperty "user.home") ".lein" "profiles.clj")
         settings (parse-cli args)
         repos (collect-repositories project)]
     (with-settings settings


resources-path now uses /tmp/test trying to get resources from thread fails

--- storm-multicore/src/clj/backtype/storm/config.clj
+++ storm-multicore/src/clj/backtype/storm/config.clj
@@ -209,7 +209,10 @@
 (defn resources-path
   "Retrieves the path to resources on the current Thread."
   []
-  (.getPath (.getResource (.getContextClassLoader (Thread/currentThread)) RESOURCES-SUBDIR)))
+  (try
+    (.getPath (.getResource (.getContextClassLoader (Thread/currentThread)) RESOURCES-SUBDIR))
+    (catch NullPointerException t
+      "tmp/test")))

 (defn read-supervisor-storm-conf


(PDB-5138) validate-binary-operators: remove redundant guard

--- src/puppetlabs/puppetdb/query_eng/engine.clj
+++ src/puppetlabs/puppetdb/query_eng/engine.clj
@@ -1982,8 +1982,7 @@

               [["=" field value]]
               (let [col-type (get-in query-context [:projections field :type])]
-                (when (and (or (= :numeric col-type)
-                               (= :numeric col-type)) (string? value))
+                (when (and (= :numeric col-type) (string? value))
                   (throw
                    (IllegalArgumentException.
                     (tru


remove bad conditional, breaking source maps

don't know why I ever made that conditional. always need to apply
input source maps, otherwise source maps are useless.

fixes #785

--- src/main/shadow/build/closure.clj
+++ src/main/shadow/build/closure.clj
@@ -912,9 +912,8 @@
     ;; we do not need yet
     (.justSetOptions cc closure-opts)

-    (when (and source-map? (:source-map-include-sources-content compiler-options))
-      (.setApplyInputSourceMaps closure-opts true)
-      (add-input-source-maps state cc))
+    (.setApplyInputSourceMaps closure-opts true)
+    (add-input-source-maps state cc)

     (.addCustomPass closure-opts CustomPassExecutionTime/BEFORE_CHECKS
       (ReplaceCLJSConstants. cc (true? (get-in state [:compiler-options :shadow-keywords]))))


workaround for npm incremental compile issues

I don't know exactly why but this seems to be polyfill related.
A missing polyfill should cause itself to be injected but somehow
in certain cases it seems to be relying on the polyfill already
being available instead.

fixes #948

--- src/main/shadow/build/closure.clj
+++ src/main/shadow/build/closure.clj
@@ -1936,6 +1936,15 @@
         _ (when (= :shadow (get-in state [:js-options :js-provider]))
             (.addCustomPass closure-opts CustomPassExecutionTime/AFTER_OPTIMIZATION_LOOP property-collector))

+        ;; GCC doesn't seem to track polyfills properly in some cases and just fails to compile
+        ;; reinject all polyfills that were added before to limit this problem and just have them
+        ;; available if other sources already required them
+        force-injected-libs
+        (::shadow-js-injected-libs state)
+
+        _ (when (seq force-injected-libs)
+            (.setForceLibraryInjection closure-opts force-injected-libs))
+
         result
         (try
           (util/with-logged-time [state {:type ::shadow-convert
@@ -2107,9 +2116,11 @@
         (boolean (seq recompile-sources))

         state
-        (if-not need-compile?
-          (update state ::shadow-js-injected-libs set/union (:injected-libs cache-index))
-          (convert-sources-simple* state recompile-sources))
+        (-> state
+            (update ::shadow-js-injected-libs set/union (:injected-libs cache-index))
+            (cond->
+              need-compile?
+              (convert-sources-simple* recompile-sources)))

         cache-index-updated
         (if-not need-compile?