Reformatted html_renderer.clj by zprint

Reformatted html_renderer.clj by zprint

--- src/zg/html_renderer.clj
+++ src/zg/html_renderer.clj
@@ -11,510 +11,535 @@
 ;

 (ns zg.html-renderer
-    "Module that contains functions used to render HTML pages sent back to the browser.")
+  "Module that contains functions used to render HTML pages sent back to the browser.")

 (require '[hiccup.core            :as hiccup])
 (require '[hiccup.page            :as page])
 (require '[hiccup.form            :as form])

 (defn render-html-header
-    "Renders part of HTML page - the header."
-    [word url-prefix title]
-    [:head
-        [:title (str title ": " word)]
-        [:meta {:name "Author"    :content "Pavel Tisnovsky"}]
-        [:meta {:name "Generator" :content "Clojure"}]
-        [:meta {:http-equiv "Content-type" :content "text/html; charset=utf-8"}]
-        ;(page/include-css "http://torment.usersys.redhat.com/openjdk/style.css")]
-        (page/include-css (str url-prefix "bootstrap.min.css"))
-        (page/include-css (str url-prefix "smearch.css"))
-        (page/include-js  (str url-prefix "bootstrap.min.js"))
-    ] ; head
+  "Renders part of HTML page - the header."
+  [word url-prefix title]
+  [:head
+   [:title (str title ": " word)]
+   [:meta {:name "Author"    :content "Pavel Tisnovsky"}]
+   [:meta {:name "Generator" :content "Clojure"}]
+   [:meta {:http-equiv "Content-type" :content "text/html; charset=utf-8"}]
+   ;(page/include-css "http://torment.usersys.redhat.com/openjdk/style.css")]
+   (page/include-css (str url-prefix "bootstrap.min.css"))
+   (page/include-css (str url-prefix "smearch.css"))
+   (page/include-js  (str url-prefix "bootstrap.min.js"))
+  ] ; head
 )

 (defn render-html-footer
-    "Renders part of HTML page - the footer."
-    []
-    [:div "

Author: Pavel Tisnovsky <ptisnovs@redhat.com&gt"])
+  "Renders part of HTML page - the footer."
+  []
+  [:div "

Author: Pavel Tisnovsky <ptisnovs@redhat.com&gt"])

 (defn mode->str
-    "The actual zg mode (a keyword) is transformed into string that will be used in URL"
-    [mode]
-    (case mode
-        :whitelist    "whitelist"
-        :blacklist    "blacklist"
-        :atomic-typos "atomic-typos"
-        :glossary     "glossary"
-                      "whitelist")) ; default
+  "The actual zg mode (a keyword) is transformed into string that will be used in URL"
+  [mode]
+  (case mode
+    :whitelist    "whitelist"
+    :blacklist    "blacklist"
+    :atomic-typos "atomic-typos"
+    :glossary     "glossary"
+                  "whitelist")) ; default

 (defn search-href
-    "Generator of href destination for the 'search' input field."
-    [url-prefix mode]
-    (str url-prefix (mode->str mode)))
+  "Generator of href destination for the 'search' input field."
+  [url-prefix mode]
+  (str url-prefix (mode->str mode)))

 (defn render-search-field
-    "Renders search box on the top side of HTML page."
-    [word url-prefix mode]
-    (form/form-to {:class "navbar-form navbar-left" :role "search"} [:get (search-href url-prefix mode)]
-        [:div {:class "input-group"}
-            [:span {:class "input-group-addon"} "Search"]
-            (form/text-field {:size "40" :class "form-control" :placeholder "Search for word"} "word" (str word))
-            [:div {:class "input-group-btn"}
-                (form/submit-button {:class "btn btn-default"} "Search")]]))
+  "Renders search box on the top side of HTML page."
+  [word url-prefix mode]
+  (form/form-to
+    {:class "navbar-form navbar-left", :role "search"}
+    [:get (search-href url-prefix mode)]
+    [:div {:class "input-group"}
+     [:span {:class "input-group-addon"} "Search"]
+     (form/text-field
+           {:size "40", :class "form-control", :placeholder "Search for word"}
+           "word"
+           (str word))
+     [:div {:class "input-group-btn"}
+          (form/submit-button {:class "btn btn-default"} "Search")]]))

 (defn render-name-field
-    "Renders box for typing user name on the top side of HTML page."
-    [user-name url-prefix]
-    (form/form-to {:class "navbar-form navbar-left" :role "search"} [:get url-prefix ]
-        [:div {:class "input-group"}
-            ;[:span {:class "input-group-addon"} "Name"]
-            (form/text-field {:size "10" :class "form-control" :placeholder "User name"} "user-name" (str user-name))
-            [:div {:class "input-group-btn"}
-                (form/submit-button {:class "btn btn-default"} "Remember me")]]))
+  "Renders box for typing user name on the top side of HTML page."
+  [user-name url-prefix]
+  (form/form-to
+    {:class "navbar-form navbar-left", :role "search"}
+    [:get url-prefix]
+    [:div {:class "input-group"}
+     ;[:span {:class "input-group-addon"} "Name"]
+     (form/text-field
+           {:size "10", :class "form-control", :placeholder "User name"}
+           "user-name"
+           (str user-name))
+     [:div {:class "input-group-btn"}
+          (form/submit-button {:class "btn btn-default"} "Remember me")]]))

 (defn tab-class
-    "In the tab menu on top, only one item could be actived."
-    [active mode]
-    (if (= active mode)
-        {:class "active"}))
+  "In the tab menu on top, only one item could be actived."
+  [active mode]
+  (if (= active mode) {:class "active"}))

 (defn user-href
-    "Generator for href to the page containing user info."
-    [user-name mode]
-    (let [destination (if (= mode :whitelist)
-                          "user-whitelist"
-                          "user-blacklist")]
-        [:a {:href (str destination "?name=" user-name)} user-name]))
+  "Generator for href to the page containing user info."
+  [user-name mode]
+  (let [destination (if (= mode :whitelist)
+                        "user-whitelist"
+                        "user-blacklist")]
+    [:a {:href (str destination "?name=" user-name)} user-name]))

 (defn users-href
-    "Generator for URL used by 'Users' menu item."
-    [url-prefix mode]
-    (condp = mode
-        :whitelist    (str url-prefix "users-whitelist")
-        :blacklist    (str url-prefix "users-blacklist")
-        :atomic-typos (str url-prefix "users-atomic-typos")
-        :glossary     (str url-prefix "users-glossary")
-                      nil))
+  "Generator for URL used by 'Users' menu item."
+  [url-prefix mode]
+  (condp = mode
+    :whitelist    (str url-prefix "users-whitelist")
+    :blacklist    (str url-prefix "users-blacklist")
+    :atomic-typos (str url-prefix "users-atomic-typos")
+    :glossary     (str url-prefix "users-glossary")
+    nil))

 (defn remember-me-href
-    "Generator for URL used by 'remember me' button."
-    [url-prefix mode]
-    (condp = mode
-        :whitelist    (str url-prefix "whitelist")
-        :blacklist    (str url-prefix "blacklist")
-        :atomic-typos (str url-prefix "atomic-typos")
-        :glossary     (str url-prefix "glossary")
-                      nil))
+  "Generator for URL used by 'remember me' button."
+  [url-prefix mode]
+  (condp = mode
+    :whitelist    (str url-prefix "whitelist")
+    :blacklist    (str url-prefix "blacklist")
+    :atomic-typos (str url-prefix "atomic-typos")
+    :glossary     (str url-prefix "glossary")
+    nil))

 (defn render-navigation-bar-section
-    "Renders whole navigation bar."
-    [user-name url-prefix title mode]
-    [:nav {:class "navbar navbar-inverse navbar-fixed-top" :role "navigation"} ; use navbar-default instead of navbar-inverse
-        [:div {:class "container-fluid"}
-            [:div {:class "row"}
-                [:div {:class "col-md-7"}
-                    [:div {:class "navbar-header"}
-                        [:a {:href url-prefix :class "navbar-brand"} title]
-                    ] ; ./navbar-header
-                    [:div {:class "navbar-header"}
-                        [:ul {:class "nav navbar-nav"}
-                            [:li (tab-class :whitelist mode) [:a {:href (str url-prefix "whitelist")} "Whitelist"]]
-                            [:li (tab-class :blacklist mode) [:a {:href (str url-prefix "blacklist")} "Blacklist"]]
-                            [:li (tab-class :atomic-typos mode) [:a {:href (str url-prefix "atomic-typos")} "Atomic typos"]]
-                            [:li (tab-class :glossary mode) [:a {:href (str url-prefix "glossary")} "Glossary"]]
-                        ]
-                    ]
-                ] ; col-md-7 ends
-                [:div {:class "col-md-3"}
-                    (render-name-field user-name (remember-me-href url-prefix mode))
-                ]
-                [:div {:class "col-md-2"}
-                    [:div {:class "navbar-header"}
-                        [:a {:href (users-href url-prefix mode) :class "navbar-brand"} "Users"]
-                    ] ; ./navbar-header
-                ] ; col ends
-            ] ; row ends
-        ] ;

-]);
+  "Renders whole navigation bar."
+  [user-name url-prefix title mode]
+  [:nav {:class "navbar navbar-inverse navbar-fixed-top", :role "navigation"} ; use
+                                                                              ; navbar-default
+                                                                              ; instead
+                                                                              ; of
+                                                                              ; navbar-inverse
+   [:div {:class "container-fluid"}
+      [:div {:class "row"}
+         [:div {:class "col-md-7"}
+            [:div {:class "navbar-header"}
+               [:a {:href url-prefix, :class "navbar-brand"} title]
+              ] ; ./navbar-header
+            [:div {:class "navbar-header"}
+               [:ul {:class "nav navbar-nav"}
+                  [:li (tab-class :whitelist mode) [:a {:href (str url-prefix "whitelist")} "Whitelist"]]
+                  [:li (tab-class :blacklist mode) [:a {:href (str url-prefix "blacklist")} "Blacklist"]]
+                  [:li (tab-class :atomic-typos mode) [:a {:href (str url-prefix "atomic-typos")} "Atomic typos"]]
+                  [:li (tab-class :glossary mode) [:a {:href (str url-prefix "glossary")} "Glossary"]]
+                 ]
+              ]
+           ] ; col-md-7 ends
+         [:div {:class "col-md-3"}
+            (render-name-field user-name (remember-me-href url-prefix mode))
+           ]
+         [:div {:class "col-md-2"}
+            [:div {:class "navbar-header"}
+               [:a {:href (users-href url-prefix mode), :class "navbar-brand"} "Users"]
+              ] ; ./navbar-header
+           ] ; col ends
+        ] ; row ends
+     ] ;

+  ]);

 (defn render-error-page
-    "Render error page with a 'back' button."
-    [word user-name message url-prefix]
-    (page/xhtml
-        (render-html-header "" url-prefix nil) ; TODO change, it might not work correctly (title, mode)
-        [:body
-            [:div {:class "container"}
-                (render-navigation-bar-section user-name url-prefix nil); TODO change, it might not work correctly (title, mode)
-                [:div {:class "col-md-10"}
-                    [:h2 "Sorry, error occured in zg"]
-                    [:p message]
-                    [:button {:class "btn btn-primary" :onclick "window.history.back()" :type "button"} "Back"]
-                ]
-                [:br][:br][:br][:br]
-                (render-html-footer)
-            ] ;

-        ] ;
-    ))
+  "Render error page with a 'back' button."
+  [word user-name message url-prefix]
+  (page/xhtml
+    (render-html-header "" url-prefix nil) ; TODO change, it might not work
+                                           ; correctly (title, mode)
+    [:body
+     [:div {:class "container"}
+          (render-navigation-bar-section user-name url-prefix nil) ; TODO
+                                                                   ; change, it
+                                                                   ; might not
+                                                                   ; work
+                                                                   ; correctly
+                                                                   ; (title,
+                                                                   ; mode)
+          [:div {:class "col-md-10"}
+               [:h2 "Sorry, error occured in zg"]
+               [:p message]
+               [:button {:class "btn btn-primary", :onclick "window.history.back()", :type "button"} "Back"]
+              ]
+          [:br] [:br] [:br] [:br]
+          (render-html-footer)
+         ] ;

+    ] ;
+  ))

 (defn render-front-page-for-whitelist
-    [word url-prefix emender-page mode]
-    [:div {:class "container-fluid"}
-        [:div {:class "row"}
-            "The CCS Custom Dictionary Whitelist - allows you to add and remove words that should not be reported as errors in Red Hat documentation by Emender (" [:a {:href emender-page} "see Emender page" ] ")"
+  [word url-prefix emender-page mode]
+  [:div {:class "container-fluid"}
+   [:div {:class "row"}
+      "The CCS Custom Dictionary Whitelist - allows you to add and remove words that should not be reported as errors in Red Hat documentation by Emender (" [:a {:href emender-page} "see Emender page"] ")"
+     ]
+   [:br]
+   [:div {:class "row"}
+      [:div {:class "navbar-header"}
+         [:a {:href (str url-prefix "all-words-in-whitelist"), :class "navbar-brand"} "All words"]
+        ] ; ./navbar-header
+      [:div {:class "navbar-header"}
+         [:a {:href (str url-prefix "active-words-in-whitelist"), :class "navbar-brand"} "Active words"]
+        ] ; ./navbar-header
+      [:div {:class "navbar-header"}
+         [:a {:href (str url-prefix "deleted-words-in-whitelist"), :class "navbar-brand"} "Deleted words"]
+        ] ; ./navbar-header
+      [:div {:style "width:80%"}
+         (render-search-field word url-prefix mode)
         ]
-        [:br]
-        [:div {:class "row"}
-            [:div {:class "navbar-header"}
-                [:a {:href (str url-prefix "all-words-in-whitelist") :class "navbar-brand"} "All words"]
-            ] ; ./navbar-header
-            [:div {:class "navbar-header"}
-                [:a {:href (str url-prefix "active-words-in-whitelist") :class "navbar-brand"} "Active words"]
-            ] ; ./navbar-header
-            [:div {:class "navbar-header"}
-                [:a {:href (str url-prefix "deleted-words-in-whitelist") :class "navbar-brand"} "Deleted words"]
-            ] ; ./navbar-header
-            [:div {:style "width:80%"}
-                (render-search-field word url-prefix mode)
-            ]
+     ]
+   [:br]
+   [:br]
+   (form/form-to
+       [:post (str url-prefix "add-words-to-whitelist")]
+       [:div {:class "_label _label-primary"} "New words  (separate them with spaces, commas, or enter them on a new line)"]
+       (form/text-area {:cols "80", :rows "8"} "new-words")
+       [:br]
+       (form/submit-button {:class "btn btn-primary"} "Add new words")
+       [:br])
+   [:br]])
+
+(defn render-front-page-for-blacklist
+  [word url-prefix emender-page mode]
+  [:div {:class "container-fluid"}
+   [:div {:class "row"}
+      "The CCS Custom Dictionary Blacklist – allows you to add and remove words that are normally correct but should be reported as errors in Red Hat documentation by Emender (" [:a {:href emender-page} "see Emender page"] ")"
+     ]
+   [:br]
+   [:div {:class "row"}
+      [:div {:class "navbar-header"}
+         [:a {:href (str url-prefix "all-words-in-blacklist"), :class "navbar-brand"} "All words"]
+        ] ; ./navbar-header
+      [:div {:class "navbar-header"}
+         [:a {:href (str url-prefix "active-words-in-blacklist"), :class "navbar-brand"} "Active words"]
+        ] ; ./navbar-header
+      [:div {:class "navbar-header"}
+         [:a {:href (str url-prefix "deleted-words-in-blacklist"), :class "navbar-brand"} "Deleted words"]
+        ] ; ./navbar-header
+      [:div {:style "width:80%"}
+         (render-search-field word url-prefix mode)
         ]
-        [:br]
-        [:br]
-        (form/form-to [:post (str url-prefix "add-words-to-whitelist")]
-                [:div {:class "_label _label-primary"} "New words  (separate them with spaces, commas, or enter them on a new line)"]
-                (form/text-area {:cols "80" :rows "8"} "new-words")
-                [:br]
-                (form/submit-button {:class "btn btn-primary"} "Add new words")
-                [:br])
-        [:br]])
-
-(defn render-front-page-for-blacklist
-    [word url-prefix emender-page mode]
-    [:div {:class "container-fluid"}
-        [:div {:class "row"}
-            "The CCS Custom Dictionary Blacklist – allows you to add and remove words that are normally correct but should be reported as errors in Red Hat documentation by Emender (" [:a {:href emender-page} "see Emender page" ] ")"
+     ]
+   [:br]
+   [:br]
+   (form/form-to
+       [:post (str url-prefix "add-word-to-blacklist")]
+       [:table {:style "border-collapse: separate; border-spacing: 10px;"}
+        [:tr [:td [:div {:class "_label _label-primary"} "New word:"]]
+             [:td " "]
+             [:td (form/text-field {:size "30"} "new-word")]]
+        [:tr [:td [:div {:class "_label _label-default"} "Description (optional):"]]
+             [:td " "]
+             [:td (form/text-field {:size "50"} "description")]]
+        [:tr [:td [:div {:class "_label _label-default"} "Class:"]]
+             [:td " "]
+             [:td (form/drop-down
+                            "class"
+                            ["N/A" "Noun" "Verb" "Adjective" "Adverb" "Pronoun" "Preposition" "Conjunction" "Determiner" "Exclamation"])]]
+        [:tr [:td [:div {:class "_label _label-default"} "Internal:"]]
+             [:td " "]
+             [:td (form/check-box "internal")]]
+        [:tr [:td [:div {:class "_label _label-default"} "Copyright:"]]
+             [:td " "]
+             [:td (form/check-box "copyright")]]
+        ;[:tr [:td [:div {:class "_label _label-default"} "Source:"]]
+        ;     [:td " "]
+        ;     [:td (form/drop-down "source" (map (fn [i] [(:source i)(:id i)])
+        ;     sources) )]]
+        [:tr [:td " "]
+             [:td " "]
+             [:td (form/submit-button {:class "btn btn-primary"} "Add new word")]]]
+       [:br])
+   [:br]])
+
+(defn render-front-page-for-atomic-typos
+  [word url-prefix emender-page mode]
+  [:div {:class "container-fluid"}
+   [:div {:class "row"}
+      "The CCS Custom Dictionary Atomic Typos – allows you to add and remove words that are normally correct but should be reported as errors in Red Hat documentation by Emender (" [:a {:href emender-page} "see Emender page"] ")"
+     ]
+   [:br]
+   [:div {:class "row"}
+      [:div {:class "navbar-header"}
+         [:a {:href (str url-prefix "all-words-in-atomic-typos"), :class "navbar-brand"} "All words"]
+        ] ; ./navbar-header
+      [:div {:class "navbar-header"}
+         [:a {:href (str url-prefix "active-words-in-atomic-typos"), :class "navbar-brand"} "Active words"]
+        ] ; ./navbar-header
+      [:div {:class "navbar-header"}
+         [:a {:href (str url-prefix "deleted-words-in-atomic-typos"),
+                  :class "navbar-brand"} "Deleted words"]
+        ] ; ./navbar-header
+      [:div {:style "width:80%"}
+         (render-search-field word url-prefix mode)
         ]
-        [:br]
-        [:div {:class "row"}
-            [:div {:class "navbar-header"}
-                [:a {:href (str url-prefix "all-words-in-blacklist") :class "navbar-brand"} "All words"]
-            ] ; ./navbar-header
-            [:div {:class "navbar-header"}
-                [:a {:href (str url-prefix "active-words-in-blacklist") :class "navbar-brand"} "Active words"]
-            ] ; ./navbar-header
-            [:div {:class "navbar-header"}
-                [:a {:href (str url-prefix "deleted-words-in-blacklist") :class "navbar-brand"} "Deleted words"]
-            ] ; ./navbar-header
-            [:div {:style "width:80%"}
-                (render-search-field word url-prefix mode)
-            ]
+     ]
+   [:br]
+   [:br]
+   (form/form-to
+       [:post (str url-prefix "add-word-to-atomic-typos")]
+       [:table {:style "border-collapse: separate; border-spacing: 10px;"}
+        [:tr [:td [:div {:class "_label _label-primary"} "Word with typo(s):"]]
+             [:td " "]
+             [:td (form/text-field {:size "30"} "new-word")]]
+        [:tr [:td [:div {:class "_label _label-default"} "Correct form:"]]
+             [:td " "]
+             [:td (form/text-field {:size "30"} "correct-word")]]
+        [:tr [:td " "]
+             [:td " "]
+             [:td (form/submit-button {:class "btn btn-primary"} "Add new word")]]]
+       [:br])
+   [:br]])
+
+(defn render-front-page-for-glossary
+  [word url-prefix emender-page mode sources]
+  [:div {:class "container-fluid"}
+   [:div {:class "row"}
+      "Glossary"
+     ]
+   [:br]
+   [:h1 {:style "color:red"} "This application is in the Proof of concept state"]
+   [:br]
+   [:div {:class "row"}
+      [:div {:class "navbar-header"}
+         [:a {:href (str url-prefix "all-words-in-glossary"), :class "navbar-brand"} "All words"]
+        ] ; ./navbar-header
+      [:div {:class "navbar-header"}
+         [:a {:href (str url-prefix "active-words-in-glossary"), :class "navbar-brand"} "Active words"]
+        ] ; ./navbar-header
+      [:div {:class "navbar-header"}
+         [:a {:href (str url-prefix "deleted-words-in-glossary"), :class "navbar-brand"} "Deleted words"]
+        ] ; ./navbar-header
+      [:div {:style "width:80%"}
+         (render-search-field word url-prefix mode)
         ]
-        [:br]
-        [:br]
-        (form/form-to [:post (str url-prefix "add-word-to-blacklist")]
-                [:table {:style "border-collapse: separate; border-spacing: 10px;"}
-                    [:tr [:td [:div {:class "_label _label-primary"} "New word:"]]
-                         [:td " "]
-                         [:td (form/text-field {:size "30"} "new-word")]]
-                    [:tr [:td [:div {:class "_label _label-default"} "Description (optional):"]]
-                         [:td " "]
-                         [:td (form/text-field {:size "50"} "description")]]
-                    [:tr [:td [:div {:class "_label _label-default"} "Class:"]]
-                         [:td " "]
-                         [:td (form/drop-down "class" ["N/A" "Noun" "Verb" "Adjective" "Adverb" "Pronoun" "Preposition" "Conjunction" "Determiner" "Exclamation"])]]
-                    [:tr [:td [:div {:class "_label _label-default"} "Internal:"]]
-                         [:td " "]
-                         [:td (form/check-box "internal")]]
-                    [:tr [:td [:div {:class "_label _label-default"} "Copyright:"]]
-                         [:td " "]
-                         [:td (form/check-box "copyright")]]
-                   ;[:tr [:td [:div {:class "_label _label-default"} "Source:"]]
-                   ;     [:td " "]
-                   ;     [:td (form/drop-down "source" (map (fn [i] [(:source i)(:id i)]) sources) )]]
-                    [:tr [:td " "]
-                         [:td " "]
-                         [:td (form/submit-button {:class "btn btn-primary"} "Add new word")]]]
-                [:br])
-        [:br]])
-
-(defn render-front-page-for-atomic-typos
-    [word url-prefix emender-page mode]
-    [:div {:class "container-fluid"}
-        [:div {:class "row"}
-            "The CCS Custom Dictionary Atomic Typos – allows you to add and remove words that are normally correct but should be reported as errors in Red Hat documentation by Emender (" [:a {:href emender-page} "see Emender page" ] ")"
-        ]
-        [:br]
-        [:div {:class "row"}
-            [:div {:class "navbar-header"}
-                [:a {:href (str url-prefix "all-words-in-atomic-typos") :class "navbar-brand"} "All words"]
-            ] ; ./navbar-header
-            [:div {:class "navbar-header"}
-                [:a {:href (str url-prefix "active-words-in-atomic-typos") :class "navbar-brand"} "Active words"]
-            ] ; ./navbar-header
-            [:div {:class "navbar-header"}
-                [:a {:href (str url-prefix "deleted-words-in-atomic-typos") :class "navbar-brand"} "Deleted words"]
-            ] ; ./navbar-header
-            [:div {:style "width:80%"}
-                (render-search-field word url-prefix mode)
-            ]
-        ]
-        [:br]
-        [:br]
-        (form/form-to [:post (str url-prefix "add-word-to-atomic-typos")]
-                [:table {:style "border-collapse: separate; border-spacing: 10px;"}
-                    [:tr [:td [:div {:class "_label _label-primary"} "Word with typo(s):"]]
-                         [:td " "]
-                         [:td (form/text-field {:size "30"} "new-word")]]
-                    [:tr [:td [:div {:class "_label _label-default"} "Correct form:"]]
-                         [:td " "]
-                         [:td (form/text-field {:size "30"} "correct-word")]]
-                    [:tr [:td " "]
-                         [:td " "]
-                         [:td (form/submit-button {:class "btn btn-primary"} "Add new word")]]]
-                [:br])
-        [:br]])
-
-(defn render-front-page-for-glossary
-    [word url-prefix emender-page mode sources]
-    [:div {:class "container-fluid"}
-        [:div {:class "row"}
-            "Glossary"
-        ]
-        [:br]
-        [:h1 {:style "color:red"} "This application is in the Proof of concept state"]
-        [:br]
-        [:div {:class "row"}
-            [:div {:class "navbar-header"}
-                [:a {:href (str url-prefix "all-words-in-glossary") :class "navbar-brand"} "All words"]
-            ] ; ./navbar-header
-            [:div {:class "navbar-header"}
-                [:a {:href (str url-prefix "active-words-in-glossary") :class "navbar-brand"} "Active words"]
-            ] ; ./navbar-header
-            [:div {:class "navbar-header"}
-                [:a {:href (str url-prefix "deleted-words-in-glossary") :class "navbar-brand"} "Deleted words"]
-            ] ; ./navbar-header
-            [:div {:style "width:80%"}
-                (render-search-field word url-prefix mode)
-            ]
-        ]
-        [:br]
-        [:br]
-        (form/form-to [:post (str url-prefix "add-word-to-glossary")]
-                [:table {:style "border-collapse: separate; border-spacing: 10px;"}
-                    [:tr [:td [:div {:class "_label _label-primary"} "New word:"]]
-                         [:td " "]
-                         [:td (form/text-field {:size "30"} "new-word")]]
-                    [:tr [:td [:div {:class "_label _label-default"} "Description:"]]
-                         [:td " "]
-                         [:td (form/text-field {:size "50"} "description")]]
-                    [:tr [:td [:div {:class "_label _label-default"} "Class:"]]
-                         [:td " "]
-                         [:td (form/drop-down "class" ["N/A" "Noun" "Verb" "Adjective" "Adverb" "Pronoun" "Preposition" "Conjunction" "Determiner" "Exclamation"])]]
-                    [:tr [:td [:div {:class "_label _label-default"} "Use it"]]
-                         [:td " "]
-                         [:td (form/drop-down "use_it" ["Yes" "No" "With caution"])]]
-                    [:tr [:td [:div {:class "_label _label-default"} "Internal:"]]
-                         [:td " "]
-                         [:td (form/check-box "internal")]]
-                    [:tr [:td [:div {:class "_label _label-default"} "Copyright:"]]
-                         [:td " "]
-                         [:td (form/check-box "copyright")]]
-                    [:tr [:td [:div {:class "_label _label-default"} "Source:"]]
-                         [:td " "]
-                         [:td (form/drop-down "source" (map (fn [i] [(val i)(key i)]) sources) )]]
-                    [:tr [:td [:div {:class "_label _label-default"} "Correct forms"]]
-                         [:td " "]
-                         [:td (form/text-field {:size "30"} "correct-forms")]]
-                    [:tr [:td [:div {:class "_label _label-default"} "Incorrect forms"]]
-                         [:td " "]
-                         [:td (form/text-field {:size "30"} "incorrect-forms")]]
-                    [:tr [:td " "]
-                         [:td " "]
-                         [:td (form/submit-button {:class "btn btn-primary"} "Add new word")]]]
-                [:br])
-        [:br]])
+     ]
+   [:br]
+   [:br]
+   (form/form-to
+       [:post (str url-prefix "add-word-to-glossary")]
+       [:table {:style "border-collapse: separate; border-spacing: 10px;"}
+        [:tr [:td [:div {:class "_label _label-primary"} "New word:"]]
+             [:td " "]
+             [:td (form/text-field {:size "30"} "new-word")]]
+        [:tr [:td [:div {:class "_label _label-default"} "Description:"]]
+             [:td " "]
+             [:td (form/text-field {:size "50"} "description")]]
+        [:tr [:td [:div {:class "_label _label-default"} "Class:"]]
+             [:td " "]
+             [:td (form/drop-down
+                            "class"
+                            ["N/A" "Noun" "Verb" "Adjective" "Adverb" "Pronoun" "Preposition" "Conjunction" "Determiner" "Exclamation"])]]
+        [:tr [:td [:div {:class "_label _label-default"} "Use it"]]
+             [:td " "]
+             [:td (form/drop-down "use_it" ["Yes" "No" "With caution"])]]
+        [:tr [:td [:div {:class "_label _label-default"} "Internal:"]]
+             [:td " "]
+             [:td (form/check-box "internal")]]
+        [:tr [:td [:div {:class "_label _label-default"} "Copyright:"]]
+             [:td " "]
+             [:td (form/check-box "copyright")]]
+        [:tr [:td [:div {:class "_label _label-default"} "Source:"]]
+             [:td " "]
+             [:td (form/drop-down "source" (map (fn [i] [(val i) (key i)]) sources))]]
+        [:tr [:td [:div {:class "_label _label-default"} "Correct forms"]]
+             [:td " "]
+             [:td (form/text-field {:size "30"} "correct-forms")]]
+        [:tr [:td [:div {:class "_label _label-default"} "Incorrect forms"]]
+             [:td " "]
+             [:td (form/text-field {:size "30"} "incorrect-forms")]]
+        [:tr [:td " "]
+             [:td " "]
+             [:td (form/submit-button {:class "btn btn-primary"} "Add new word")]]]
+       [:br])
+   [:br]])

 (defn yes-no
-    [key-name search-results]
-    (condp = (get search-results key-name)
-        1 "yes"
-        0 "no"
-          "N/A"))
+  [key-name search-results]
+  (condp = (get search-results key-name)
+    1 "yes"
+    0 "no"
+      "N/A"))

 (defn yes-no-with-caution
-    [key-name search-results]
-    (condp = (get search-results key-name)
-        1 "yes"
-        0 "no"
-        2 "with caution"
-          "N/A"))
+  [key-name search-results]
+  (condp = (get search-results key-name)
+    1 "yes"
+    0 "no"
+    2 "with caution"
+      "N/A"))

 (defn get-source
-    [sources-map key-name search-results]
-    (let [source (get search-results key-name)]
-        (if source
-            (get sources-map (dec source))
-            "N/A")))
+  [sources-map key-name search-results]
+  (let [source (get search-results key-name)]
+    (if source
+      (get sources-map (dec source))
+      "N/A")))

 (defn get-class
-    [classes-map key-name search-results]
-    (let [class (get search-results key-name)]
-        (if class
-            (get classes-map class)
-            "N/A")))
+  [classes-map key-name search-results]
+  (let [class (get search-results key-name)]
+    (if class
+      (get classes-map class)
+      "N/A")))

 (defn handle-null
-    [key-name search-results]
-    (or (get search-results key-name) "N/A"))
+  [key-name search-results]
+  (or (get search-results key-name) "N/A"))

 (defn get-correct-or-preferred-forms
-    [search-result]
-    (str (:incorrect_forms search-result) (:correct_forms search-result)))
+  [search-result]
+  (str (:incorrect_forms search-result) (:correct_forms search-result)))

 (defn render-front-page
-    "Render front page of this application."
-    [word user-name search-results sources-map classes-map message url-prefix title emender-page mode]
-    (println user-name)
-    (println url-prefix)
-    (println title)
-    (println mode)
-    (println (first search-results))
-    (println sources-map)
-    (page/xhtml
-        (render-html-header word url-prefix title)
-        [:body
-            [:div {:class "container"}
-                (render-navigation-bar-section user-name url-prefix title mode)
-            (case mode
-                :whitelist    (render-front-page-for-whitelist word url-prefix emender-page mode)
-                :blacklist    (render-front-page-for-blacklist word url-prefix emender-page mode)
-                :atomic-typos (render-front-page-for-atomic-typos word url-prefix emender-page mode)
-                :glossary     (render-front-page-for-glossary word url-prefix emender-page mode sources-map)
-                )
-
-                (if message
-                    [:div {:class "label label-warning"} message ]
-                )
-                (if search-results
-                    [:table {:class "table table-stripped table-hover" :style "width:auto"}
-                        [:tr [:th "Word"]
-                             (if (= mode :atomic-typos)
-                                 [:th "Correct form(s)"])
-                             (if (not= mode :glossary)
-                                 [:th "Added at"])
-                             (if (not= mode :glossary)
-                                 [:th "Added by"])
-                             (if (or (= mode :blacklist) (= mode :glossary))
-                                 [:th "Description"])
-                             [:th "Class"]
-                             [:th "Use it"]
-                             [:th "Internal"]
-                             [:th "Copyright"]
-                             [:th "Verified"]
-                             (if (= mode :glossary)
-                                 [:th "Incorrect/preferred forms"])
-                             [:th "Source"]
-                             (if (= mode :glossary)
-                                 [:th "See also"])
-                             [:th "Status"]
-                             [:th "Operation"]]
-                        (for [search-result search-results]
-                            (let [deleted (= (:deleted search-result) 1)
-                                  word    (:word search-result)]
-                                [:tr [:td word]
-                                     (if (= mode :atomic-typos)
-                                         [:td (:correct search-result)])
-                                     (if (not= mode :glossary)
-                                         [:td (:datetime search-result)])
-                                     (if (not= mode :glossary)
-                                         [:td (user-href (:user search-result) mode)])
-                                     (if (or (= mode :blacklist) (= mode :glossary))
-                                         [:td (:description search-result)])
-                                     [:td (get-class classes-map :class search-result)]
-                                     [:td (yes-no-with-caution :use search-result)]
-                                     [:td (yes-no :internal search-result)]
-                                     [:td (yes-no :copyrighted search-result)]
-                                     [:td (yes-no :verified search-result)]
-                                     (if (= mode :glossary)
-                                         [:td (get-correct-or-preferred-forms search-result)])
-                                     [:td (get-source sources-map :source search-result)]
-                                     (if (= mode :glossary)
-                                         [:td (:see_also search-result)])
-                                     [:td {:style (if deleted "color:red" "color:green")} (if deleted "deleted" "active")]
-                                     [:td (if deleted [:a {:href (str "?undelete=" word) :class "btn btn-default"} "undelete"]
-                                                      [:a {:href (str "?delete="   word) :class "btn btn-default"}  "delete"])]
-                                ]))
-                    ])
-                (render-html-footer)
-            ] ;

-        ] ;
-    ))
+  "Render front page of this application."
+  [word user-name search-results sources-map classes-map message url-prefix title emender-page mode]
+  (println user-name)
+  (println url-prefix)
+  (println title)
+  (println mode)
+  (println (first search-results))
+  (println sources-map)
+  (page/xhtml
+    (render-html-header word url-prefix title)
+    [:body
+     [:div {:class "container"}
+          (render-navigation-bar-section user-name url-prefix title mode)
+          (case mode
+                :whitelist
+                  (render-front-page-for-whitelist word url-prefix emender-page mode)
+                :blacklist
+                  (render-front-page-for-blacklist word url-prefix emender-page mode)
+                :atomic-typos
+                  (render-front-page-for-atomic-typos word url-prefix emender-page mode)
+                :glossary (render-front-page-for-glossary word
+                                                          url-prefix
+                                                          emender-page
+                                                          mode
+                                                          sources-map))
+
+          (if message [:div {:class "label label-warning"} message])
+          (if search-results
+                [:table {:class "table table-stripped table-hover", :style "width:auto"}
+                 [:tr [:th "Word"]
+                        (if (= mode :atomic-typos) [:th "Correct form(s)"])
+                        (if (not= mode :glossary) [:th "Added at"])
+                        (if (not= mode :glossary) [:th "Added by"])
+                        (if (or (= mode :blacklist) (= mode :glossary)) [:th "Description"])
+                        [:th "Class"]
+                        [:th "Use it"]
+                        [:th "Internal"]
+                        [:th "Copyright"]
+                        [:th "Verified"]
+                        (if (= mode :glossary) [:th "Incorrect/preferred forms"])
+                        [:th "Source"]
+                        (if (= mode :glossary) [:th "See also"])
+                        [:th "Status"]
+                        [:th "Operation"]]
+                 (for [search-result search-results]
+                         (let [deleted (= (:deleted search-result) 1)
+                               word (:word search-result)]
+                           [:tr [:td word]
+                            (if (= mode :atomic-typos) [:td (:correct search-result)])
+                            (if (not= mode :glossary) [:td (:datetime search-result)])
+                            (if (not= mode :glossary)
+                                        [:td (user-href (:user search-result) mode)])
+                            (if (or (= mode :blacklist) (= mode :glossary))
+                                        [:td (:description search-result)])
+                            [:td (get-class classes-map :class search-result)]
+                            [:td (yes-no-with-caution :use search-result)]
+                            [:td (yes-no :internal search-result)]
+                            [:td (yes-no :copyrighted search-result)]
+                            [:td (yes-no :verified search-result)]
+                            (if (= mode :glossary)
+                                        [:td (get-correct-or-preferred-forms search-result)])
+                            [:td (get-source sources-map :source search-result)]
+                            (if (= mode :glossary) [:td (:see_also search-result)])
+                            [:td {:style (if deleted "color:red" "color:green")} (if deleted "deleted" "active")]
+                            [:td (if deleted
+                                                       [:a {:href (str "?undelete=" word), :class "btn btn-default"} "undelete"]
+                                                       [:a {:href (str "?delete=" word), :class "btn btn-default"} "delete"])]
+                           ]))
+                ])
+          (render-html-footer)
+         ] ;

+    ] ;
+  ))

 (defn dictionary-name
-    [dictionary-type]
-    (condp = dictionary-type
-        "w" "whitelist"
-        "b" "blacklist"
-        "a" "atomic typos"
-        "g" "glossary"
-        "u" "glossary"
-            "unknown"))
+  [dictionary-type]
+  (condp = dictionary-type
+    "w" "whitelist"
+    "b" "blacklist"
+    "a" "atomic typos"
+    "g" "glossary"
+    "u" "glossary"
+        "unknown"))

 (defn render-users
-    "Render page containing list of all users."
-    [user-name statistic changes url-prefix title mode]
-    (page/xhtml
-        (render-html-header nil url-prefix title)
-        [:body
-            [:div {:class "container"}
-                (render-navigation-bar-section user-name url-prefix title mode)
-
-                [:table {:class "table table-stripped table-hover" :style "width:auto"}
-                    [:tr [:th "User name"]
-                         [:th "Changes made"]]
-                    (for [stat statistic]
-                        [:tr [:td (user-href (:user stat) mode)]
-                             [:td (:cnt stat)]]
-                    )
-                ] ;

-                [:br]
-                [:table {:class "table table-stripped table-hover" :style "width:auto"}
-                    [:tr [:th "Word"]
-                         [:th "Dictionary"]
-                         [:th "Added at"]
-                         [:th "Added by"]]
-                    (for [change changes]
-                        [:tr [:td (:word change)]
-                             [:td (dictionary-name (:dictionary change))]
-                             [:td (:datetime change)]
-                             [:td (user-href (:user change) mode)]])
-                ] ;

-                (render-html-footer)
-            ] ;

-        ] ;
-    ))
+  "Render page containing list of all users."
+  [user-name statistic changes url-prefix title mode]
+  (page/xhtml
+    (render-html-header nil url-prefix title)
+    [:body
+     [:div {:class "container"}
+          (render-navigation-bar-section user-name url-prefix title mode)
+
+          [:table {:class "table table-stripped table-hover", :style "width:auto"}
+               [:tr [:th "User name"]
+                    [:th "Changes made"]]
+               (for [stat statistic]
+                     [:tr [:td (user-href (:user stat) mode)]
+                      [:td (:cnt stat)]])
+              ] ;

+          [:br]
+          [:table {:class "table table-stripped table-hover", :style "width:auto"}
+               [:tr [:th "Word"]
+                    [:th "Dictionary"]
+                    [:th "Added at"]
+                    [:th "Added by"]]
+               (for [change changes]
+                     [:tr [:td (:word change)]
+                      [:td (dictionary-name (:dictionary change))]
+                      [:td (:datetime change)]
+                      [:td (user-href (:user change) mode)]])
+              ] ;

+          (render-html-footer)
+         ] ;

+    ] ;
+  ))

 (defn render-user-info
-    "Render page containing info about one selected user."
-    [user-name changes url-prefix title mode]
-    (page/xhtml
-        (render-html-header nil url-prefix title)
-        [:body
-            [:div {:class "container"}
-                (render-navigation-bar-section user-name url-prefix title mode)
-                [:h1 (str "Changes made by " user-name)]
-
-                [:br]
-                [:table {:class "table table-stripped table-hover" :style "width:auto"}
-                    [:tr [:th "Word"]
-                         [:th "Dictionary"]
-                         [:th "Added at"]]
-                    (for [change changes]
-                        [:tr [:td (:word change)]
-                             [:td (dictionary-name (:dictionary change))]
-                             [:td (:datetime change)]])
-                ] ;

-                (render-html-footer)
-            ] ;

-        ] ;
-    ))
-
+  "Render page containing info about one selected user."
+  [user-name changes url-prefix title mode]
+  (page/xhtml
+    (render-html-header nil url-prefix title)
+    [:body
+     [:div {:class "container"}
+          (render-navigation-bar-section user-name url-prefix title mode)
+          [:h1 (str "Changes made by " user-name)]
+
+          [:br]
+          [:table {:class "table table-stripped table-hover", :style "width:auto"}
+               [:tr [:th "Word"]
+                    [:th "Dictionary"]
+                    [:th "Added at"]]
+               (for [change changes]
+                     [:tr [:td (:word change)]
+                      [:td (dictionary-name (:dictionary change))]
+                      [:td (:datetime change)]])
+              ] ;

+          (render-html-footer)
+         ] ;

+    ] ;
+  ))
+


Connect gen property uses attr generator

--- src/com/wsscode/pathom/connect/gen.cljc
+++ src/com/wsscode/pathom/connect/gen.cljc
@@ -101,9 +101,8 @@
           seq))

    ::s.query/gen-property
-   (fn gen-property [{::p/keys  [path]
-                      ::pc/keys [indexes]}]
-     (if-let [ks (seq (keys (pc/discover-attrs indexes path)))]
+   (fn gen-property [{::keys [attrs] :as env}]
+     (if-let [ks (attrs env)]
        (gen/elements ks)
        (gen/return '*)))


Reenable loading code into the GUI repl

Reenable loading code into the GUI repl

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

--- src/conexp/contrib/gui/editors/code.clj
+++ src/conexp/contrib/gui/editors/code.clj
@@ -41,8 +41,7 @@
   (menu :text "Code",
         :items [(menu-item :text "Load into REPL",
                            :listen [:action (fn [_]
-                                              (get-file-and-go frame))]
-                           :enabled? false)]))
+                                              (get-file-and-go frame))])]))

 ;;;


add copyright header

add copyright header

--- src/main/clojure/clojure/tools/cli.cljc
+++ src/main/clojure/clojure/tools/cli.cljc
@@ -1,3 +1,11 @@
+;   Copyright (c) Rich Hickey. All rights reserved.
+;   The use and distribution terms for this software are covered by the
+;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
+;   which can be found in the file epl-v10.html at the root of this distribution.
+;   By using this software in any fashion, you are agreeing to be bound by
+;   the terms of this license.
+;   You must not remove this notice, or any other, from this software.
+
 (ns ^{:author "Gareth Jones, Sung Pae, Sean Corfield"
       :doc "Tools for working with command line arguments."}
   clojure.tools.cli


1st pass at a shutdown hook idea [IMMUTANT-605]

Subject to change. Not sure addShutdownHook is valid in all
environments. Also would like to consider wrapping all HttpHandlers in a
GracefulShutdownHandler, possibly in wboss/mount.

--- web/src/immutant/web/undertow.clj
+++ web/src/immutant/web/undertow.clj
@@ -19,7 +19,8 @@
             [immutant.web.internal.undertow :refer (create-http-handler)]
             [immutant.web.ssl :refer (keystore->ssl-context)])
   (:import [io.undertow Undertow Undertow$Builder UndertowOptions]
-           [io.undertow.server HttpHandler]
+           io.undertow.server.HttpHandler
+           io.undertow.server.handlers.GracefulShutdownHandler
            [org.xnio Options SslClientAuthMode]
            [org.projectodd.wunderboss.web Web$CreateOption Web$RegisterOption]))

@@ -27,6 +28,21 @@
   "Create an Undertow HttpHandler instance from a Ring handler function"
   [handler]
   (create-http-handler handler))
+
+(defn ^HttpHandler add-graceful-shutdown-hook
+  "Creates an io.undertow.server.handlers/GracefulShutdownHandler with
+  the passed HttpHandler, and adds a shutdown hook to the Java Runtime
+  that enables a graceful shutdown, prohibiting new requests while
+  waiting for pending ones to complete, up to a specified number of
+  milliseconds. Return value should be passed to immutant.web/run"
+  [^HttpHandler handler ^Long timeout]
+  (let [result (GracefulShutdownHandler. handler)]
+    (.addShutdownHook
+      (Runtime/getRuntime)
+      (Thread. (fn []
+                 (.shutdown result)
+                 (.awaitShutdown result timeout))))
+    result))

 (defn ^:no-doc tune
   "Return the passed tuning options with an Undertow$Builder instance


itemsOnLifecycle: run kibit and clean up

--- src/app/itemsOnLifecycle.clj
+++ src/app/itemsOnLifecycle.clj
@@ -55,14 +55,14 @@
      (getFieldsVariablesTuples cl))))

 (defn isPublicMethodSingleton? [cl]
-  (not (empty?
-         (filter
-           (fn [m]
-             (and
-               (isPublicOrHasPackageLevelAccess? m)
-               (isStatic? m)
-               (= (getName m) "getInstance")))
-           (getMethods cl)))))
+  (seq
+   (filter
+     (fn [m]
+       (and
+         (isPublicOrHasPackageLevelAccess? m)
+         (isStatic? m)
+         (= (getName m) "getInstance")))
+     (getMethods cl))))

 (defn isSingletonEnum? [e]
   (and


fix typo

fix typo

--- src/babel/espanol/writer.clj
+++ src/babel/espanol/writer.clj
@@ -229,7 +229,7 @@
                                 (list {:synsem {:sem {:tense :conditional}}}
                                       {:synsem {:sem {:tense :future}}}
                                       {:synsem {:sem {:tense :present}}}
-                                      {:synsem {:sem {:aspect :perfect
+                                      {:synsem {:sem {:aspect :progressive
                                                       :tense :past}}}
                                       {:synsem {:sem {:aspect :perfect
                                                       :tense :past}}}


(maint) add partial indexes on reports

(maint) add partial indexes on reports

These indexes help support some queries made by the reports summary page
in the PE console.  They take a couple minutes to run on a dataset with
11M reports. It'll probably worthwhile to test on a larger set somehow.

Space on disk is minimal (couple mb) due to how targeted these are.

--- src/puppetlabs/puppetdb/scf/migrate.clj
+++ src/puppetlabs/puppetdb/scf/migrate.clj
@@ -1251,6 +1251,12 @@
 (defn add-gin-index-on-resource-params-cache []
   (jdbc/do-commands
     "create index resource_params_cache_parameters_idx on resource_params_cache using gin (parameters)"))
+
+(defn reports-partial-indices
+  []
+  (jdbc/do-commands
+    "create index reports_noop_idx on reports(noop) where noop = true"
+    "create index reports_cached_catalog_status_on_fail on reports(cached_catalog_status) where cached_catalog_status = 'on_failure'"))

 (def migrations
   "The available migrations, as a map from migration version to migration function."
@@ -1287,7 +1293,8 @@
    55 index-certnames-unique-latest-report-id
    56 merge-fact-values-into-facts
    57 add-package-tables
-   58 add-gin-index-on-resource-params-cache})
+   58 add-gin-index-on-resource-params-cache
+   59 reports-partial-indices})

 (def desired-schema-version (apply max (keys migrations)))


Minor refactoring.

Minor refactoring.

--- src/cmr/indexer/services/concepts/granule.clj
+++ src/cmr/indexer/services/concepts/granule.clj
@@ -4,6 +4,7 @@
             [clj-time.format :as f]
             [cmr.indexer.services.index-service :as idx]
             [cmr.umm.echo10.granule :as granule]
+            [cmr.umm.echo10.related-url :as ru]
             [cmr.transmit.metadata-db :as mdb]
             [cmr.indexer.services.concepts.temporal :as temporal]
             [cmr.indexer.services.concepts.attribute :as attrib]
@@ -27,7 +28,7 @@
         producer-gran-id (:producer-gran-id data-granule)
         start-date (temporal/start-date :granule temporal)
         end-date (temporal/end-date :granule temporal)
-        downloadable (not (empty? (filter #(= "GET DATA" (:type %)) related-urls)))]
+        downloadable (not (empty? (filter ru/downloadable-url? related-urls)))]
     {:concept-id concept-id
      :collection-concept-id parent-collection-id
      :provider-id provider-id


update schemas

update schemas

--- src/chessground/schemas.cljs
+++ src/chessground/schemas.cljs
@@ -54,4 +54,6 @@
              :events {Keyword js/Function}}
    :selected (s/maybe Str)
    :dragging Bool
-   :spare-pieces Bool})
+   :spare-pieces Bool
+   :moved (s/maybe Str)
+   :showed-dests [Str]})


Fix issue #37: Add special cases to pprint-str for *print-level* and *print-length*

--- src/clj_ns_browser/utils.clj
+++ src/clj_ns_browser/utils.clj
@@ -477,7 +477,17 @@
 (defn pprint-str
   "Return string with pprint of v, and limit output to prevent blowup."
   ([v & kvs]
-    (with-out-str (binding [*print-length* 32 *print-level* 6] (pprint v)))))
+     (with-out-str
+       ;; Special case for these Vars so that they pprint the correct
+       ;; values.  Assume that their values do not need the
+       ;; *print-length* or *print-level* restrictions to be short.
+       ;; Since their values are almost always integers, this is
+       ;; usually the case.
+       (if (or (= v #'clojure.core/*print-length*)
+               (= v #'clojure.core/*print-level*))
+         (pprint v)
+         (binding [*print-length* 32 *print-level* 6]
+           (pprint v))))))

 (defn val-kv-filter


take advantage of refer-clojure

take advantage of refer-clojure

--- src/cljs/clojure/string.cljs
+++ src/cljs/clojure/string.cljs
@@ -1,6 +1,5 @@
 (ns clojure.string
-  ;; TODO pending refer-clojure exclude support
-  #_(:refer-clojure :exclude [replace reverse])
+  (:refer-clojure :exclude [replace reverse])
   (:require [goog.string :as gstring]
             [goog.string.StringBuffer :as gstringbuf]))

@@ -8,8 +7,7 @@
   [coll]
   (reduce conj () coll))

-;; TODO rename to reverse
-(defn str-reverse
+(defn reverse
   "Returns s with its characters reversed."
   [s]
   (let [sb (gstring/StringBuffer.)]


fix issue with missing Google Analytics in dev mode

--- src/cljs/netrunner/main.cljs
+++ src/cljs/netrunner/main.cljs
@@ -11,7 +11,7 @@
 (defn navigate [token]
   (let [page-number (case token "/" 0 "/play" 1 "/deckbuilder" 2 "/cards" 3 "/news" 4)]
     (.carousel (js/$ ".carousel") page-number))
-  (js/ga "send" "pageview")
+  (try (js/ga "send" "pageview") (catch js/Error e))
   (swap! app-state assoc :active-page [token]))

 (def history (Html5History.))


Refactor timer loop

Refactor timer loop

--- src/cljs/pomodonut/core.cljs
+++ src/cljs/pomodonut/core.cljs
@@ -34,31 +34,26 @@
     (reset! timeout t)
     c))

+(defn clear-timeout []
+  (js/clearTimeout @timeout)
+  (close! @interval)
+  (reset! interval nil)
+  (reset! timeout nil))
+
 (defn start-timer
   [c duration s]
   (let [i (go-loop [t (inc s)]
-            (do
-              (om/transact! c `[(timer/update-elapsed-time {:t ~t})])
-              (when (and
-                      (not (nil? @interval))
-                      (< t duration))
-                (do
-                  (<! (wait 1000))
-                  (recur (inc t))))
-              (when (>= t duration)
-                (when-not (nil? @interval)
-                  (close! @interval)
-                  (reset! interval nil)))))]
+            (om/transact! c `[(timer/update-elapsed-time {:t ~t})])
+            (if (< t duration)
+              (do
+                (<! (wait 1000))
+                (recur (inc t)))
+              (clear-timeout)))]
     (reset! interval i)))

-(defn stop-timer
-  [c]
-  (do
-    (js/clearTimeout @timeout)
-    (close! @interval)
-    (reset! interval nil)
-    (reset! timeout nil)
-    (om/transact! c `[(timer/update-elapsed-time {:t ~0})])))
+(defn stop-timer [c]
+  (clear-timeout)
+  (om/transact! c `[(timer/update-elapsed-time {:t ~0})]))

 (defui Timer
   static om/IQuery


update format-decimal

update format-decimal

--- src/cljs/ws_ldn_2/utils.cljs
+++ src/cljs/ws_ldn_2/utils.cljs
@@ -16,10 +16,9 @@

 (defn format-decimal
   [x prec thousands frac]
-  (str/replace
-   (str
-    (if (neg? x) "-")
-    (str/replace (.toFixed (Math/abs x) prec) #"(\d)(?=(\d{3})+\.)" (str "$1" thousands)))
-   "." frac))
+  (let [x' (str/replace (.toFixed (Math/abs x) prec) "." frac)]
+    (str
+     (if (neg? x) "-")
+     (str/replace x' #"(\d)(?=(\d{3})+[^\d])" (str "$1" thousands)))))

 (defn format-gbp [x] (format-decimal x 2 "," "."))


remove parsing of unpublished master branch commits

--- src/cljs_api_gen/catalog.clj
+++ src/cljs_api_gen/catalog.clj
@@ -81,9 +81,10 @@
         master-tag (get-master-tag "clojurescript")

         tags (case version
-               ;; (When latest, we also parse master)
-               :latest (cond-> @published-cljs-tags
-                         (not= last-tag master-tag) (concat [master-tag]))
+               :latest @published-cljs-tags
+                       ;; I used to parse unpublished commits on master when cljs was slower to publish recent changes, but I’m removing this now:
+                       ;;  (cond-> @published-cljs-tags
+                       ;;   (not= last-tag master-tag) (concat [master-tag]))
                (if-not ((set @published-cljs-tags) version)
                  (do
                    (println (style "Unrecognized version tag" :red) version)


[n.u.menu] Make :on-menu-item-click safe for ui

--- src/clojure/neko/ui/menu.clj
+++ src/clojure/neko/ui/menu.clj
@@ -1,7 +1,8 @@
 (ns neko.ui.menu
   "Provides utilities for declarative options menu generation.
   Intended to replace XML-based menu layouts."
-  (:require [neko.ui :as ui]
+  (:require [neko.debug :refer [safe-for-ui]]
+            [neko.ui :as ui]
             [neko.ui.mapping :refer [defelement]]
             [neko.ui.traits :refer [deftrait]]
             [neko.-utils :refer [call-if-nnil int-id]])
@@ -129,7 +130,7 @@
   [handler-fn]
   (reify android.view.MenuItem$OnMenuItemClickListener
     (onMenuItemClick [this item]
-      (handler-fn item)
+      (safe-for-ui (handler-fn item))
       true)))

 (defmacro on-menu-item-click


Guarding against clojure.core/any?

Guarding against clojure.core/any?

Guarding against any?, which is part of clojure.core in 1.9.

--- src/commons/clojure/core.clj
+++ src/commons/clojure/core.clj
@@ -17,7 +17,8 @@
             such.types
             such.wide-domains
             such.wrongness
-            such.imperfection))
+            such.imperfection)
+  (:refer-clojure :exclude [any?]))

 ;;; Other people's code


Code for "Enhancing your first Om component."

Write code for the section "Enhancing your first Om component." This
code changes our list of contacts by adding a (non-functional) "Delete"
button.

--- basic/om-tut/src/om_tut/core.cljs
+++ basic/om-tut/src/om_tut/core.cljs
@@ -28,7 +28,9 @@
 (defn contact-view [contact owner]
   (reify om/IRender
     (render [this]
-      (dom/li nil (display-name contact)))))
+      (dom/li nil
+              (dom/span nil (display-name contact))
+              (dom/button nil "Delete")))))

 (defn contacts-view [data owner]
   (reify om/IRender


Remove lateral menu namespace.

Remove lateral menu namespace.

--- src/uxbox/ui/workspace/lateralmenu.cljs
+++ src/uxbox/ui/workspace/lateralmenu.cljs
@@ -1,51 +0,0 @@
-(ns uxbox.ui.workspace.lateralmenu
-  (:require [sablono.core :as html :refer-macros [html]]
-            [rum.core :as rum]
-            [cats.labs.lens :as l]
-            [uxbox.rstore :as rs]
-            [uxbox.state :as s]
-            [uxbox.data.workspace :as dw]
-            [uxbox.ui.workspace.base :as wb]
-            [uxbox.ui.icons :as i]
-            [uxbox.ui.mixins :as mx]))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Lateral Menu
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defn- toggle-toolbox
-  [state item]
-  (update state item (fnil not false)))
-
-(defn lateralmenu-render
-  [own]
-  (let [toolboxes (rum/react wb/toolboxes-l)
-        toggle #(rs/emit! (dw/toggle-toolbox %))]
-    (html
-     [:div#tool-bar.tool-bar
-      [:div.tool-bar-inside
-       [:ul.main-tools
-        [:li.tooltip
-         {:alt "Shapes (Ctrl + Shift + F)"
-          :class (when (contains? toolboxes :draw) "current")
-          :on-click (partial toggle :draw)}
-         i/shapes]
-        [:li.tooltip
-         {:alt "Icons (Ctrl + Shift + I)"
-          :class (when (contains? toolboxes :icons) "current")
-          :on-click (partial toggle :icons)}
-         i/icon-set]
-        [:li.tooltip
-         {:alt "Elements (Ctrl + Shift + L)"
-          :class (when (contains? toolboxes :layers) "current")
-          :on-click (partial toggle :layers)}
-         i/layers]
-        [:li.tooltip
-         {:alt "Feedback (Ctrl + Shift + M)"}
-         i/chat]]]])))
-
-(def ^:static lateralmenu
-  (mx/component
-   {:render lateralmenu-render
-    :name "lateralmenu"
-    :mixins [rum/reactive]}))


Force doubles

Force doubles

--- src/wireframes/shapes/curved_solids.clj
+++ src/wireframes/shapes/curved_solids.clj
@@ -124,13 +124,13 @@
       n)))

 (defn make-mobius-strip [i j]
-  (let [x (fn [u v] (* (inc (* (/ v 2) (Math/sin (/ u 2)))) (Math/cos u)))
-        y (fn [u v] (* (inc (* (/ v 2) (Math/cos (/ u 2)))) (Math/sin u)))
-        z (fn [u v] (* (/ v 2) (Math/sin (/ u 2))))
-        u (range 0 (+ (* 2 Math/PI) i) i)
-        v (range -1 (+ 1 j) j)]
-    {:polygons (p/mesh (dec (count u)) (dec (count v)))
+  (let [x (fn [u v] (* (inc (* (/ v 2.0) (Math/sin (/ u 2.0)))) (Math/cos u)))
+        y (fn [u v] (* (inc (* (/ v 2.0) (Math/cos (/ u 2.0)))) (Math/sin u)))
+        z (fn [u v] (* (/ v 2.0) (Math/sin (/ u 2.0))))
+        u (range 0.0 (+ (* 2.0 Math/PI) i) i)
+        v (range -1.0 (+ 1.0 j) j)]
+    {:polygons (vec (p/mesh (dec (count u)) (dec (count v))))
      :points (vec
                (for [v' v
                      u' u]
-                 (t/point (x u' v') (y u' v') (z u' v'))))}))+                 (t/point (x u' v') (y u' v') (z u' v'))))}))


Problem added: "Rearranging Code: ->>"

Problem added: "Rearranging Code: ->>"

--- src/foreclojure/data_set.clj
+++ src/foreclojure/data_set.clj
@@ -742,10 +742,18 @@
            :times-solved 0
            :description "The -> macro threads an expression x through a variable number of forms. First, x is inserted as the second item in the first form, making a list of it if it is not a list already.  Then the first form is inserted as the second item in the second form, making a list of that form if necessary.  This process continues for all the forms.  Using -> can sometimes make your code more readable."
            :tags ["elementary"]
-           :tests ["(= (last (sort (rest (reverse [2 5 4 1 3 6]))))\n   (-> [2 5 4 1 3 6] reverse __ sort last)\n   5)"]})
+           :tests ["(= (__ (sort (rest (reverse [2 5 4 1 3 6]))))\n   (-> [2 5 4 1 3 6] reverse rest sort __)\n   5)"]})
+
+      (insert! :problems
+          {:_id 72
+           :title "Rearranging Code: ->>"
+           :times-solved 0
+           :description "The ->> macro threads an expression x through a variable number of forms. First, x is inserted as the last item in the first form, making a list of it if it is not a list already.  Then the first form is inserted as the last item in the second form, making a list of that form if necessary.  This process continues for all the forms.  Using ->> can sometimes make your code more readable."
+           :tags ["elementary"]
+           :tests ["(= (__ (map inc (take 3 (drop 2 [2 5 4 1 3 6]))))\n   (-> [2 5 4 1 3 6] (drop 2) (take 3) (map inc) (__))\n   11)"]})

       (insert! :problems
-           {:_id 72
+           {:_id 73
             :title "Power Set"
             :times-solved 0
             :description "A power set is the set of all subsets of a given set. Given a list, produce a set of sublists while preserving the order of elements."


when not logged in display the javascript code box as default

--- src/foreclojure/problems.clj
+++ src/foreclojure/problems.clj
@@ -245,8 +245,9 @@
                :golfChart (html (render-golf-chart))})))

 (defn wants-no-javascript-codebox? []
-  (with-user [{:keys [user] :as user-obj}]
-    (disable-codebox? user-obj)))
+  (when (session/session-get :user)
+    (with-user [{:keys [user] :as user-obj}]
+      (disable-codebox? user-obj))))

 (def-page code-box [id]
   (let [{:keys [_id title difficulty tags description


wip: update executor function arguments

wip: update executor function arguments

--- src/graphql_clj/executor.clj
+++ src/graphql_clj/executor.clj
@@ -1,6 +1,7 @@
 (ns graphql-clj.executor
   (:require [graphql-clj.parser :as parser]
             [graphql-clj.schema-validator :as sv]
+            [graphql-clj.query-validator :as qv]
             [graphql-clj.resolver :as resolver]
             [graphql-clj.error :as gerror]
             [clojure.set :as set]
@@ -83,7 +84,7 @@
                                  :schema schema
                                  :resolver (resolver/create-resolver-fn schema resolver-fn)})))
   ([context validated-schema resolver-fn validated-document]
-   (execute context validated-schema resolver-fn validated-document nil)))
+   (execute-validated-document context validated-schema resolver-fn validated-document nil)))

 (defn execute
   ([context string-or-validated-schema resolver-fn string-or-validated-document variables]
@@ -91,8 +92,10 @@
                             (-> (parser/parse-schema string-or-validated-schema)
                                 (sv/validate-schema))
                             string-or-validated-schema)
+         valid-schema (second validated-schema)
          validated-document (if (string? string-or-validated-document)
-                              (parser/parse-query-document string-or-validated-document)
+                              (->> (parser/parse-query-document string-or-validated-document)
+                                   (qv/validate-query valid-schema))
                               string-or-validated-document)]
      (execute-validated-document context validated-schema resolver-fn validated-document variables)))
   ([context validated-schema resolver-fn string-or-validated-document]


Reduced repitition in tests.

Reduced repitition in tests.

--- test/blutwurst/tuple_formatter_test.clj
+++ test/blutwurst/tuple_formatter_test.clj
@@ -8,6 +8,8 @@
 (use-fixtures :each logging-fixture)

 (def simple-schema {:name "Example" :schema "foo" :properties [{:name "A" :type :integer} {:name "B" :type :string}]})
+(def person-schema {:name "Person" :schema nil :properties [{:name "Address" :type :complex} {:name "Name" :type :string}]
+                        :dependencies [{:target-schema nil :target-name "Address" :dependency-name nil :links {"Address" :embedded}}]})

 (deftest csv-formatter-test
   (testing "Generating a CSV from rows."
@@ -19,10 +21,8 @@

   (testing "Flattens out embedded objects."
     (let [spec {:format :csv}
-          person-table {:name "Person" :schema nil :properties [{:name "Address" :type :complex} {:name "Name" :type :string}]
-                        :dependencies [{:target-schema nil :target-name "Address" :dependency-name nil :links {"Address" :embedded}}]}
-          data `({:entity ~person-table :tuples ~(list {:name "John Doe" :Address {:Address1 "123 Main" :City "Springfield"}})})]
-      (is (= [{:entity person-table :tuples ["name,Address.Address1,Address.City\nJohn Doe,123 Main,Springfield\n"]}]
+          data `({:entity ~person-schema :tuples ~(list {:name "John Doe" :Address {:Address1 "123 Main" :City "Springfield"}})})]
+      (is (= [{:entity person-schema :tuples ["name,Address.Address1,Address.City\nJohn Doe,123 Main,Springfield\n"]}]
              (format-rows spec data))))))

 (deftest sql-formatter-test
@@ -44,10 +44,8 @@

   (testing "SQL generation flattens out embedded objects."
     (let [spec {:format :sql}
-          person-table {:name "Person" :schema nil :properties [{:name "Address" :type :complex} {:name "Name" :type :string}]
-                        :dependencies [{:target-schema nil :target-name "Address" :dependency-name nil :links {"Address" :embedded}}]}
-          data `({:entity ~person-table :tuples ~(list {:Name "John Doe" :Address {:Address1 "123 Main" :City "Springfield"}})})]
-      (is (= [{:entity person-table :tuples ["INSERT INTO \"Person\" (\"Name\",\"Address.Address1\",\"Address.City\") VALUES ('John Doe','123 Main','Springfield');\n"]}]
+          data `({:entity ~person-schema :tuples ~(list {:Name "John Doe" :Address {:Address1 "123 Main" :City "Springfield"}})})]
+      (is (= [{:entity person-schema :tuples ["INSERT INTO \"Person\" (\"Name\",\"Address.Address1\",\"Address.City\") VALUES ('John Doe','123 Main','Springfield');\n"]}]
              (format-rows spec data)))))

   (testing "SQL generation formats DATE values."


Fix reflection warning :warning:

Fix reflection warning :warning:

--- src/metabase/driver/mongo/query_processor.clj
+++ src/metabase/driver/mongo/query_processor.clj
@@ -148,6 +148,7 @@
                                        3]})
           :year            {$year field})))))

+
 (extend-protocol IRValue
   nil (->rvalue [_] nil)

@@ -162,7 +163,7 @@
   Value
   (->rvalue [{value :value, {:keys [base-type]} :field}]
     (if (isa? base-type :type/MongoBSONID)
-      (ObjectId. value)
+      (ObjectId. (str value))
       value))

   DateTimeValue


Using any open port to avoid clashing when multiple notes are open.

--- src/ipython_clojure/core.clj
+++ src/ipython_clojure/core.clj
@@ -48,8 +48,8 @@
   (let [hb-addr (address (prep-config args) :hb_port)
         shell-addr (address (prep-config args) :shell_port)
         iopub-addr (address (prep-config args) :iopub_port)
-        nrepl-server (start-server :port 59528 :handler (nrepl-handler))]
-    (with-open [conn (repl/connect :port 59528)]
+        nrepl-server (start-server :handler (nrepl-handler))]
+    (with-open [conn (repl/connect :port (:port nrepl-server))]
       (println (prep-config args))
       (println (str "Connecting heartbeat to " hb-addr))
       (-> hb-addr heart-beat Thread. .start)


Remove some printlns.

Remove some printlns.

--- frontend/uxbox/data/workspace.cljs
+++ frontend/uxbox/data/workspace.cljs
@@ -64,7 +64,6 @@
   (reify
     rs/UpdateEvent
     (-apply-update [_ state]
-      (println "select-for-drawing" shape)
       (if shape
         (assoc-in state [:workspace :drawing] shape)
         (update-in state [:workspace] dissoc :drawing)))
@@ -111,7 +110,6 @@
   (reify
     rs/UpdateEvent
     (-apply-update [_ state]
-      (println "select-shapes" selrect)
       (let [pid (get-in state [:workspace :page])
             shapes (->> (vals (:shapes-by-id state))
                         (filter #(= (:page %) pid))


:art:

:art:

--- src/overtone_workspace/layers/lines_layer.clj
+++ src/overtone_workspace/layers/lines_layer.clj
@@ -2,20 +2,14 @@
   (:require [quil.core :as q])
   (:use [quil-layer.layer]))

-(defn- setup []
-  {:color 0
-   :angle 0})
+(def num-of-lines 5)

-(defn- update-state [state]
-  ; Update sketch state by changing circle color and position.
-  {:color (mod (+ (:color state) 0.7) 255)
-   :angle (+ (:angle state) 0.1)})
-
-(def num-of-lines 10)
+(defn- setup [] {})
+(defn- update-state [state] {})

 (defn- draw-state [state]
   (let [r (/ (q/width) num-of-lines)
-        rr (* -1.0 r)]
+        rr (- r)]
     (q/smooth)

     (q/color-mode :rgb)


wrap arguments to (conjugate) within {:français}

--- src/babel/francais/morphology.cljc
+++ src/babel/francais/morphology.cljc
@@ -277,7 +277,7 @@
                                       true
                                       (get-in word [:français]))]
                  (log/debug (str "conjugate: infinitive=" infinitive "; word=" (strip-refs word)))
-                 (conjugate infinitive word))))
+                 (conjugate infinitive {:français word}))))

            (and
             (= (get-in word '(:infl)) :imperfect)
@@ -288,7 +288,7 @@
            (cond (get-in word [:past-participle])
                  (get-in word [:past-participle])
                  true
-                 (conjugate (get-in word [:français]) word))
+                 (conjugate (get-in word [:français]) {:français word}))

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


add conditional-tense exceptions in lexical compilation

--- src/babel/italiano/morphology.cljc
+++ src/babel/italiano/morphology.cljc
@@ -1597,6 +1597,50 @@
                                            :italiano (get-in val [:italiano :future :3plur] :nothing)
                                            :agr {:number :plur
                                                  :person :3rd}}})}
+
+                            ;; 4. conditional-tense exceptions
+                            {:path [:italiano :conditional :1sing]
+                             :merge-fn
+                             (fn [val]
+                               {:italiano {:infl :conditional
+                                           :italiano (get-in val [:italiano :conditional :1sing] :nothing)
+                                           :agr {:number :sing
+                                                 :person :1st}}})}
+                            {:path [:italiano :conditional :2sing]
+                             :merge-fn
+                             (fn [val]
+                               {:italiano {:infl :conditional
+                                           :italiano (get-in val [:italiano :conditional :2sing] :nothing)
+                                           :agr {:number :sing
+                                                 :person :2nd}}})}
+                            {:path [:italiano :conditional :3sing]
+                             :merge-fn
+                             (fn [val]
+                               {:italiano {:infl :conditional
+                                           :italiano (get-in val [:italiano :conditional :3sing] :nothing)
+                                           :agr {:number :sing
+                                                 :person :3rd}}})}
+                            {:path [:italiano :conditional :1plur]
+                             :merge-fn
+                             (fn [val]
+                               {:italiano {:infl :conditional
+                                           :italiano (get-in val [:italiano :conditional :1plur] :nothing)
+                                           :agr {:number :plur
+                                                 :person :1st}}})}
+                            {:path [:italiano :conditional :2plur]
+                             :merge-fn
+                             (fn [val]
+                               {:italiano {:infl :conditional
+                                           :italiano (get-in val [:italiano :conditional :2plur] :nothing)
+                                           :agr {:number :plur
+                                                 :person :2nd}}})}
+                            {:path [:italiano :conditional :3plur]
+                             :merge-fn
+                             (fn [val]
+                               {:italiano {:infl :conditional
+                                           :italiano (get-in val [:italiano :conditional :3plur] :nothing)
+                                           :agr {:number :plur
+                                                 :person :3rd}}})}
                             ;; adjectives
                             {:path [:italiano :masc :plur]
                              :merge-fn


(PDB-2909) Update `java.jdbc/execute!` usage.

--- src/puppetlabs/puppetdb/scf/storage_utils.clj
+++ src/puppetlabs/puppetdb/scf/storage_utils.clj
@@ -240,7 +240,7 @@
 (defn vacuum-analyze
   [db]
   (sql/with-db-connection [conn db]
-    (sql/execute! db ["vacuum analyze"] :transaction? false)))
+    (sql/execute! db ["vacuum analyze"] {:transaction? false})))

 (defn parse-db-hash
   [db-hash]


Correctly handle arbitrary maps passed to emit

--- src/clj/backtype/storm/clojure.clj
+++ src/clj/backtype/storm/clojure.clj
@@ -1,6 +1,7 @@
 (ns backtype.storm.clojure
   (:use [clojure.contrib.def :only [defnk defalias]])
   (:use [backtype.storm bootstrap util])
+  (:use [clojure walk])
   (:import [backtype.storm StormSubmitter])
   (:import [backtype.storm.generated StreamInfo])
   (:import [backtype.storm.tuple Tuple])
@@ -159,8 +160,8 @@
 (defn- mk-tuple-values
   [^OutputCollector collector stream values]
   (if (map? values)
-    (let [ fields (.. collector getContext (getThisOutputFields stream)) ]
-      (map values fields))
+    (let [ fields (.. collector getContext (getThisOutputFields stream) toList) ]
+      (vec (map (stringify-keys values) fields)))
     values))

 (defnk emit-bolt! [^OutputCollector collector values


Split out transducers based on results.

Split out transducers based on results.

--- src/cljs/cmr/client/http/impl.cljs
+++ src/cljs/cmr/client/http/impl.cljs
@@ -10,15 +10,22 @@
 ;;;   Utility Functions   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

+(def result-xducer
+  (map clj->js))
+
+(def result-body-xducer
+  (map (comp clj->js :body)))
+
 (defn make-channel
   [client]
   (if (get-in client [:parent-client-options :return-body?])
-    (async/promise-chan (map :body))
-    (async/promise-chan)))
+    (async/promise-chan result-body-xducer)
+    (async/promise-chan result-xducer)))

 (defn get-default-options
   [client]
-  {:with-credentials? false})
+  {:with-credentials? false
+   :headers {"Accept" "application/json"}})

 (defn make-http-options
   [client call-options]


Changing the number of shards for granule and collection indexes.

--- src/cmr/indexer/data/index_set.clj
+++ src/cmr/indexer/data/index_set.clj
@@ -14,7 +14,7 @@
             [cmr.system-trace.core :refer [deftracefn]]))

 (def collection-setting {:index
-                         {:number_of_shards 2,
+                         {:number_of_shards 6,
                           :number_of_replicas 1,
                           :refresh_interval "1s"}})

@@ -130,7 +130,7 @@
                              :attributes attributes-field-mapping
                              :science-keywords science-keywords-field-mapping}}})

-(def granule-setting {:index {:number_of_shards 2,
+(def granule-setting {:index {:number_of_shards 6,
                               :number_of_replicas 1,
                               :refresh_interval "1s"}})


fix test description

fix test description

--- test/github_changelog/semver_test.clj
+++ test/github_changelog/semver_test.clj
@@ -17,7 +17,7 @@
       "0.0.1"
       "0.9.3-pre0"
       "1.0.1"))
-  (testing "with 'rel' prefix"
+  (testing "with 'pre' prefix"
     (are [version] (clj-semver/valid? (semver/extract version "pre"))
       "pre0.0.1"
       "pre0.9.3-pre0"


Extract test image basedir to var

Extract test image basedir to var

--- test/silly_image_store/store_test.clj
+++ test/silly_image_store/store_test.clj
@@ -2,10 +2,12 @@
   (:require [clojure.test :refer :all]
             [silly-image-store.store :refer :all]))

+(def test-basedir "test/fixtures/")
+
 (deftest test-store
   (testing "loading a file"
     (testing "load existing file"
-      (let [file (load-image "test/fixtures/" "test-all-the-things.jpg")]
+      (let [file (load-image test-basedir "test-all-the-things.jpg")]
         (is (= (class file) java.io.File))
         (is (= (.getPath file) "test/fixtures/test-all-the-things.jpg"))))

@@ -14,4 +16,4 @@
         (is (nil? file)))))

   (testing "listing images"
-    (is (= (list-images "test/fixtures/") ["another-test.jpg" "test-all-the-things.jpg"]))))
+    (is (= (list-images test-basedir) ["another-test.jpg" "test-all-the-things.jpg"]))))


Fix duplicate tables for MongoDB after doing manual sync #1633

--- src/metabase/driver/sync.clj
+++ src/metabase/driver/sync.clj
@@ -78,6 +78,7 @@
   (sync-database-active-tables! driver (for [table (sel :many Table, :db_id (:id database) :active true)]
                                          ;; replace default delays with ones that reuse database (and don't require a DB call)
                                          (assoc table :db (delay database)))))
+

 (defn- -sync-database! [driver database]
   (let [active-tables      (driver/active-tables driver database)


Use refer all instead of :use

Use refer all instead of :use

--- src/grafter/rdf/ontologies/rdf.clj
+++ src/grafter/rdf/ontologies/rdf.clj
@@ -1,6 +1,6 @@
 (ns grafter.rdf.ontologies.rdf
   "Some convenience terms for the RDF and RDFS vocabularies."
-  (:use grafter.rdf.ontologies.util))
+  (:require grafter.rdf.ontologies.util :refer :all))

 (def rdf (prefixer "http://www.w3.org/1999/02/22-rdf-syntax-ns#"))
 (def rdfs (prefixer "http://www.w3.org/2000/01/rdf-schema#"))


cleaned solution, todo

cleaned solution, todo

--- src/hackerrank/time_conversion.clj
+++ src/hackerrank/time_conversion.clj
@@ -27,22 +27,19 @@
 (defn remove-am-pm [time]
   (subs time 0 (- (count time) 2)))

-; http://clojure.org/reference/sequences
-; https://clojuredocs.org/clojure.string/join
 (defn pm-time [time]
   (let [hours (+ (hour time) 12)
         minutes-and-seconds (rest (time-parts time))]
-    (clojure.string/join ":" (cons hours minutes-and-seconds))))
+    (join ":" (cons hours minutes-and-seconds))))

 (defn hour-time [hours time]
-   (clojure.string/join ":" (cons hours (rest (time-parts time)))))
+   (join ":" (cons hours (rest (time-parts time)))))

 (defn format-24h [time]
   (if (and (pm? time) (not (= (hour time) 12)))
     (remove-am-pm (pm-time time))
     (remove-am-pm time)))

-; https://clojuredocs.org/clojure.core/cond
 (defn pm-am-time [time]
   (let [hours (hour time)
         time24 (cond
@@ -54,4 +51,9 @@
 (defn time-conversion [line]
   (pm-am-time line))

-(println (time-conversion "07:05:45PM"))
+;; (println (time-conversion "07:05:45PM"))
+;; for hackerrank
+;; (println (time-conversion (read-line)))
+
+;; 2016-08-03 13:50 run at hackerrank: 7/10 solution - 3 fails
+;; o preper more test cases


Removed stat changer from modifying a created character

--- src/hphelper/frontend/chargen.cljs
+++ src/hphelper/frontend/chargen.cljs
@@ -547,8 +547,9 @@
        ;; Page chooser
        [:div {:class "btn-group"}
         (shared/switcher-toolbar page-atom [:page]
-                                 [[:sheet "Display Sheet"] [:stats "Statistics"]
-                                  [:societies "Secret Societies"] [:finalize "Finalize Character"]]
+                                 [[:sheet "Display Sheet"]
+                                  [:societies "Secret Societies"]
+                                  [:finalize "Finalize Character"]]
                                  )
         ]
        ;; TODO


Checkpoint

Checkpoint

Signed-off-by: Gregory Haskins <640d9fe47775e6723f0355b7315e38f7d98d3539@gmail.com>

--- src/obcc/build/interface.clj
+++ src/obcc/build/interface.clj
@@ -35,11 +35,8 @@
   (let [interfaces (->> config getinterfaces (cons "project") (remove nil?))
         protopath (io/file path "build/proto/project.proto")]

-    ;; ensure the path exists, but the file is truncated to 0
+    ;; ensure the path exists
     (io/make-parents protopath)
-
-    (if (.exists protopath)
-        (io/delete-file protopath))

     ;; and then generate our output
     (with-open [proto (io/writer protopath :truncate true)]


Fix replies sort.

Fix replies sort.

--- src/oc/storage/db/common.clj
+++ src/oc/storage/db/common.clj
@@ -313,7 +313,7 @@
                       (r/le start (r/get-field row [:reduction :created-at]))))))
         ;; Sort
         (if-not count?
-          (r/order-by query (order-fn :created-at))
+          (r/order-by query (order-fn (r/fn [row] (r/get-field row [:reduction :created-at]))))
           query)
         ;; Join with the relative entry
         (r/eq-join query :group  ;; {:left {:group "resource-uuid" :reduction comment-map} :right entry-map}


rearranged the time qualifiers and made the chart bigger

--- src/anyviz/views.clj
+++ src/anyviz/views.clj
@@ -104,10 +104,10 @@
             [:div.panel-body
               [:form.form-horizontal {:role "form"}
                 [:div.form-group
+                  [:label.col-sm-2.control-label {:for "date-period"} "Over the range"]
+                  (wg4 (dropdown date-periods "date-period"))
                   [:label.col-sm-2.control-label {:for "group-times"} "Group time by"]
-                  (wg4 (dropdown group-times "group-times"))
-                  [:label.col-sm-2.control-label {:for "date-period"} "Over the range"]
-                  (wg4 (dropdown date-periods "date-period"))]
+                  (wg4 (dropdown group-times "group-times"))]

                 [:div.form-group
                   [:label.col-sm-2.control-label {:for "match-entities"} "Match where"]
@@ -142,7 +142,7 @@

           [:div.tab-content
             [:div#graph.tab-pane.active
-              [:div#dynamic-graph {:style "width 100%; height:325px;"}]]
+              [:div#dynamic-graph {:style "width 100%; height:600px;"}]]
             [:div#rawquery.tab-pane
               [:pre#query {:style "text-align: left;"}]]
             [:div#queryresults.tab-pane


use full classname in type hint for portability

--- src/asphalt/type.clj
+++ src/asphalt/type.clj
@@ -13,8 +13,8 @@

 (defprotocol IConnectionSource
-  (^Connection create-connection [this] "Create connection from the source")
-  (^Connection obtain-connection [this] "Obtain connection from the source")
+  (^java.sql.Connection create-connection [this] "Create connection from the source")
+  (^java.sql.Connection obtain-connection [this] "Obtain connection from the source")
   (return-connection  [this connection] "Return connection to the source"))


improve logging

improve logging

--- src/babel/cache.cljc
+++ src/babel/cache.cljc
@@ -104,10 +104,11 @@
 ;; TODO: spec is not used yet; add support for it.
 (defn get-lex [schema head-or-comp cache spec]
   "return the subset of the whole lexicon that can be added either as a head (head-or-comp=:head) or as a comp (head-or-comp=:comp)."
+  (log/debug (str "get-lex:" schema))
   (if (nil? schema)
     #{}
     (do
-      (log/debug (str "get-lex: " (get-in schema [:rule]) " ; " head-or-comp))
+      (log/debug (str "get-lex: " (get-in schema [:rule]) " ; head-or-comp:" head-or-comp))
       (if (not (map? schema))
         (throw (exception (str "first arguments should have been a map, but instead was of type: " (type schema) "; schema: " schema))))
       (log/trace (str "get-lex schema: " (get-in schema [:rule]) " for: " head-or-comp))
@@ -160,7 +161,7 @@
         result (if (nil? result) (list) result)
         label (label-of parent)]
     (if (empty? result)
-      (log/trace (str "headed-phrases of parent: " label " is empty.")))
+      (log/warn (str "headed-phrases of parent: " label " is empty.")))
     (lazy-shuffle result)))

 (defn get-comp-phrases-of [parent cache]


Refactoring of -main function. Note added about performance issue.

--- src/clj_git/core.clj
+++ src/clj_git/core.clj
@@ -7,11 +7,27 @@
   (:use clj-git.tree)
   (:gen-class))

-(declare modified)
+(declare is-file-modified)
+
 (defn -main [& args]
-  (println "Unstaged Changes:")
-  (doseq [x (modified)]
-    (println (str "  " x))))
+  (let [modified (->>  (read-index)
+                       (map :name)
+                       (filter is-file-modified))
+        staged (->>  (read-index)
+                       (map :name)
+                       (filter is-file-staged))]
+  (if-not (empty? modified)
+    (do
+      (println "Unstaged Changes:")
+      (doseq [x modified]
+        (println (str "  " x)))))
+
+  (if-not (empty? staged)
+    (do
+      (println "Staged For Commit:")
+      (doseq [x staged]
+        (println (str "  " x)))))
+))

 ; Use the following rules to quickly check for modified files:
 ;         if filesystem mtime matches index           -> return False
@@ -27,11 +43,7 @@
       :else                 (not= (:hash index-entry) (hash-file filename))
     )))

-(defn modified []
-  (->> (read-index)
-       (map :name)
-       (filter is-file-modified)))
-
+; TODO: This is slow! (checking if any files are staged takes a long time..)
 (defn is-file-staged [filename]
   (let [head-tree (tree-to-files (:tree (commit (head))))
         tree-entry      (->> head-tree (filter #(= (:name %) filename)) (first))


add serial no generator

add serial no generator

--- src/codestat/web.clj
+++ src/codestat/web.clj
@@ -3,6 +3,15 @@
   (:use (codestat mysql git)))

 (require '[net.cgrand.enlive-html :as html])
+
+(defprotocol SerialNo
+  (reset [this])
+  (next [this]))
+(deftype SerialNoGenerator [ ^:volatile-mutable serial-no ]
+  SerialNo
+  (reset [this] (set! serial-no 0))
+  (next [this] (set! serial-no (inc serial-no))))
+

 (html/deftemplate add-project-templ "templates/add-project.html"
   [{:keys [path]}]
@@ -11,48 +20,53 @@
 ;;; fill the second :tr with project list
 (html/deftemplate list-project-templ "templates/list-project.html"
   [recs ]
-  [:body :table [:tr (html/nth-of-type 2)]]
-  (html/clone-for [rec recs ](html/html-content
-                               (str "
"
-                                    "" (:id rec) "	"
-                                    "" (:project_name rec) "	"
-                                    "" (:project_desc rec) "	"
-                                    "" (:vcs_url rec) "	"
-                                    "" (:issue_url rec) "	"
-                                    "
"))))
+  [:body :table [:tr (html/nth-of-type 2)]]
+  (let [sg (->SerialNoGenerator 0)]
+    (html/clone-for [rec recs ](html/html-content
+                                 (str "
"
+                                      "" (.next sg) "	"
+                                      "" (:project_name rec) "	"
+                                      "" (:project_desc rec) "	"
+                                      "" (:vcs_url rec) "	"
+                                      "" (:issue_url rec) "	"
+                                      "
")))))

 (defn sort-by-count
   [coll]
   (sort #(compare (first (vals %2)) (first (vals %1)))
         coll))

+
 ;;; count aspect of projects
 (html/deftemplate count-project-templ "templates/count-project.html"
   [project-recs commit-recs changeline-recs]
   [:body :table#count_project_by_author [:tr (html/nth-of-type 2)]]
-  (html/clone-for [prec (sort-by-count project-recs)]
-    (html/html-content
-      (str "
"
-           ""           "	"
-           "" (first (keys prec)) "	"
-           "" (first (vals prec)) "	"
-           "
")))
+  (let [sg (->SerialNoGenerator 0)]
+    (html/clone-for [prec (sort-by-count project-recs)]
+                    (html/html-content
+                      (str "
"
+                           ""  (.next sg)         "	"
+                           "" (first (keys prec)) "	"
+                           "" (first (vals prec)) "	"
+                           "
"))))
   [:body :table#count_commit_by_author [:tr (html/nth-of-type 2)]]
-  (html/clone-for [crec (sort-by-count commit-recs)]
-    (html/html-content
-      (str "
"
-           ""           "	"
-           "" (first (keys crec)) "	"
-           "" (first (vals crec)) "	"
-           "
")))
+  (let [sg1 (->SerialNoGenerator 0)]
+    (html/clone-for [crec (sort-by-count commit-recs)]
+                    (html/html-content
+                      (str "
"
+                           ""  (.next sg1)         "	"
+                           "" (first (keys crec)) "	"
+                           "" (first (vals crec)) "	"
+                           "
"))))
   [:body :table#count_change_line_by_author [:tr (html/nth-of-type 2)]]
-  (html/clone-for [cl-rec (sort-by-count changeline-recs)]
-    (html/html-content
-      (str "
"
-           ""           "	"
-           "" (first (keys cl-rec)) "	"
-           "" (first (vals cl-rec)) "	"
-           "
"))))
+  (let [sg2 (->SerialNoGenerator 0)]
+    (html/clone-for [cl-rec (sort-by-count changeline-recs)]
+                    (html/html-content
+                      (str "
"
+                           ""  (.next sg2)         "	"
+                           "" (first (keys cl-rec)) "	"
+                           "" (first (vals cl-rec)) "	"
+                           "
")))))

 ;;;
 ;;; web interface for code stat


more test cases

more test cases

--- test/hackerrank/compare_the_triplets_test.clj
+++ test/hackerrank/compare_the_triplets_test.clj
@@ -18,4 +18,7 @@
     (is (= (compare 7 10) -1)))

   (testing "compare-triplets"
-    (is (compare-triplets "5 6 7" "3 6 10") "1 1")))
+    (is (compare-triplets "5 6 7" "3 6 10") "1 1")
+    (is (compare-triplets "5 6 7" "5 6 7") "1 1")
+    (is (compare-triplets "5 6 7" "1 2 3") "3 0")
+    (is (compare-triplets "1 2 3" "5 6 7") "3 0")))


More clojure way

More clojure way

--- src/control/core.clj
+++ src/control/core.clj
@@ -42,7 +42,6 @@
      (str bash-greenbold ~@content bash-reset)
      (str ~@content)))

-
 (defstruct ^:private ExecProcess  :stdout :stderr :status)

 (defn gen-log [host tag content]
@@ -51,7 +50,7 @@
        (join " " content)))

 (defn-  log-with-tag [host tag & content]
-  (if (and *enable-logging* (not (blank? (join " " content))))
+  (when (and *enable-logging* (not (blank? (join " " content))))
     (println (gen-log host tag content))))

 (defn  ^:dynamic  exec [host user cmdcol]
@@ -67,7 +66,7 @@

 (defn ssh-client [host user]
   (let [user (or user (:user @*global-options*))]
-    (if (not user)
+    (when-not user
       (throw (IllegalArgumentException. "user is nil")))
     (str user "@" host)) )

@@ -184,14 +183,14 @@
     (check-valid-options m :scp-options :sudo :mode :ssh-options)
     (log-with-tag host "scp" scp-options
       (join " " (concat files [ " ==> " tmp])))
-    (if use-tmp
+    (when use-tmp
       (ssh host user cluster (str "mkdir -p " tmp)))
     (let [rt (exec host
                    user
                    (make-cmd-array "scp"
                                    scp-options
                                    (concat files [(str (ssh-client host user) ":" tmp)])))]
-      (if mode
+      (when mode
         (apply ssh host user cluster (str "chmod " mode  " " tmp "*") opts))
       (if use-tmp
         (apply ssh host user cluster (str "mv "  tmp "* " remote " ; rm -rf " tmp) opts)
@@ -229,9 +228,9 @@
                                    item))
                                item))
                            body)]
-    (if (not (vector? arguments))
-      (throw (IllegalArgumentException. "Task must have arguments vector")))
-    (if *debug*
+    (when-not (vector? arguments)
+      (throw (IllegalArgumentException. "It's arguments must be a vector")))
+    (when *debug*
       (prn name "new-body:" new-body))
     `(swap! tasks
             assoc
@@ -291,7 +290,7 @@
         ~else)))

 (defn- perform [host user cluster task taskName arguments]
-  (do (if *enable-logging* (println (cli-bash-bold "Performing " (name taskName) " for " (ssh-client host user))))
+  (do (when *enable-logging* (println (cli-bash-bold "Performing " (name taskName) " for " (ssh-client host user))))
       (apply task host user cluster arguments)))

 (defn- arg-count [f]
@@ -331,14 +330,14 @@
                                  " just needs "
                                  task-arg-count
                                  " arguments")))
-               (binding [*enable-logging* (if (nil? log) true log)
+               (binding [*enable-logging* (or log true)
                          *debug* debug]
-                 (if *enable-logging*
+                 (when *enable-logging*
                    (println  (str bash-bold
                                   "Performing "
                                   (name cluster-name)
                                   bash-reset
-                                  (if parallel
+                                  (when parallel
                                     " in parallel"))))
                  (let [map-fn (if parallel pmap map)
                        a (doall (map-fn (fn [addr] [addr (perform addr user cluster task task-name task-args)])