Skip to content

Commit 31d4bd2

Browse files
authored
Merge pull request #252 from dimmyjr/bump-deps-and-remove-nsfw
remove the nsfw to avoid transitive deps like congomongo and bump it.
2 parents 96bba95 + c35ee08 commit 31d4bd2

File tree

10 files changed

+1658
-41
lines changed

10 files changed

+1658
-41
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/target
22
/classes
33
/checkouts
4+
/.idea
5+
*.iml
46
pom.xml
57
pom.xml.asc
68
*.jar
@@ -22,3 +24,4 @@ resources/public/clojuredocs-export.json
2224
TAGS
2325

2426
/dev-db
27+
/data

project.clj

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
:test-paths ["test/clj"]
99
:dependencies [[org.clojure/clojure "1.11.1"]
1010
[org.clojure/clojurescript "1.9.946"]
11-
[nsfw "0.11.72" :exclusions
12-
[org.clojure/core.async
13-
org.clojure/clojurescript]]
1411
[ring "1.5.1"]
1512
[compojure "1.1.6"]
1613
[aleph "0.4.2-alpha12"]
@@ -19,16 +16,26 @@
1916
[org.clojure/java.jdbc "0.3.0-beta2"]
2017
[mysql/mysql-connector-java "5.1.25"]
2118
[unk "0.9.1"]
22-
[org.clojure/core.async "1.3.618"]
19+
[org.clojure/core.async "1.6.681"]
2320
[org.clojure/core.logic "0.8.11"]
24-
[org.pegdown/pegdown "1.4.2"]
25-
;;[cljsjs/react "0.13.1-0"]
26-
;;[cljsjs/react-dom "0.14.0-1"]
21+
[com.vladsch.flexmark/flexmark-all "0.64.8"]
2722
[clj-fuzzy "0.1.8"]
2823
[prone "0.6.0"]
2924
[nrepl "0.6.0"]
3025
[javax.xml.bind/jaxb-api "2.4.0-b180830.0359"]
31-
[org.clojure/data.csv "1.0.1"]]
26+
[org.clojure/data.csv "1.0.1"]
27+
[clojure-interop/java.security "1.0.5"]
28+
[garden "1.2.5" :exclusions [org.clojure/clojure]]
29+
[com.cognitect/transit-clj "1.0.333"]
30+
[com.cognitect/transit-cljs "0.8.280"]
31+
[bidi "1.23.1" :exclusions [org.clojure/clojure]]
32+
[slingshot "0.12.2"]
33+
[cheshire "5.5.0"]
34+
[clj-http "3.6.0"]
35+
[camel-snake-kebab "0.3.2"]
36+
[prismatic/dommy "1.1.0"]
37+
[reagent "0.6.0"]
38+
[congomongo "2.6.0"]]
3239
:repl-options {:init (load-file "reup.clj")}
3340
:plugins [[lein-cljsbuild "1.1.5"]
3441
[lein-figwheel "0.5.18"]

src/clj/clojuredocs/api/see_alsos.clj

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
[schema.core :as s]
55
[clojuredocs.util :as util]
66
[clojuredocs.api.common :as c]
7-
[clojuredocs.search :as search]))
7+
[clojuredocs.search :as search])
8+
(:import [org.bson.types ObjectId]))
89

910
;; Schemas
1011

@@ -19,11 +20,11 @@
1920
:library-url s/Str})
2021

2122
(def SeeAlso
22-
{:from-var Var
23-
:to-var Var
24-
:author User
23+
{:from-var Var
24+
:to-var Var
25+
:author User
2526
:created-at s/Int
26-
:_id org.bson.types.ObjectId})
27+
:_id ObjectId})
2728

2829
(defn prevent-duplicates [{:keys [from-var to-var]}]
2930
(when-let [existing (mon/fetch-one :see-alsos :where {:from-var from-var :to-var to-var})]
@@ -44,7 +45,7 @@
4445
[:ns :name :library-url])
4546
:author user
4647
:created-at (util/now)
47-
:_id (org.bson.types.ObjectId.)}]
48+
:_id (ObjectId.)}]
4849
(when-not to-var
4950
(throw+
5051
{:status 404
@@ -62,12 +63,9 @@
6263
(defn delete-see-also-handler [id]
6364
(fn [{:keys [edn-body user]}]
6465
(c/require-login! user)
65-
(let [_id (org.bson.types.ObjectId. id)
66+
(let [_id (ObjectId. (str id))
6667
sa (mon/fetch-one :see-alsos :where {:_id _id})]
6768
(c/validate! sa [(is-author? user)])
68-
#_(mon/update! :see-alsos
69-
{:_id _id}
70-
(assoc sa :deleted-at (util/now)))
7169
(mon/destroy! :see-alsos {:_id _id})
7270
{:status 200
7371
:body sa})))

src/clj/clojuredocs/api/server.clj

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
(ns clojuredocs.api.server
2-
(:require [compojure.core :refer (defroutes GET POST PUT DELETE ANY PATCH) :as cc]
3-
[compojure.route :refer (not-found)]
4-
[somnium.congomongo :as mon]
5-
[clout.core :as clout]
6-
[slingshot.slingshot :refer [try+ throw+]]
7-
[clojuredocs.util :as util]
8-
[clojuredocs.api.examples :as examples]
9-
[clojuredocs.api.see-alsos :as see-alsos]
2+
(:require [clojuredocs.api.examples :as examples]
103
[clojuredocs.api.notes :as notes]
4+
[clojuredocs.api.see-alsos :as see-alsos]
5+
[compojure.core :refer [DELETE GET PATCH POST defroutes]]
6+
[compojure.route :refer [not-found]]
117
[fogus.unk :as unk]
12-
[nsfw.util :as nu]))
8+
[nsfw.util :as nu]
9+
[slingshot.slingshot :refer [throw+ try+]]
10+
[somnium.congomongo :as mon])
11+
(:import [org.bson.types ObjectId]))
1312

1413
(defn all-see-alsos-relations-map []
1514
(->> (mon/fetch
@@ -71,7 +70,7 @@
7170
(fn [r]
7271
(let [{:keys [body] :as res} (h r)
7372
_id (:_id body)]
74-
(if (and _id (instance? org.bson.types.ObjectId _id))
73+
(if (and _id (instance? ObjectId _id))
7574
(update-in res [:body :_id] str)
7675
res))))
7776

@@ -80,8 +79,8 @@
8079
(let [{:keys [_id] :as res} (h r)]
8180
(if (and _id (string? _id))
8281
(try
83-
(assoc res :_id (org.bson.types.ObjectId. _id))
84-
(catch java.lang.IllegalArgumentException e
82+
(assoc res :_id (ObjectId. (str _id)))
83+
(catch IllegalArgumentException e
8584
(throw+
8685
{:status 400
8786
:body {:message (str "Error parsing Mongo ID: " _id)}})))

src/clj/nsfw/reup.clj

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
(ns nsfw.reup
2+
"Utilities for supporting a clojure.tools.namespace reloading dev
3+
lifecycle.
4+
5+
Add the following to your project.clj
6+
7+
`:repl-options {:init (load-file \"reup.clj\")}`"
8+
(:require [clojure.tools.namespace.repl :as repl]
9+
[clojure.tools.namespace.find :as ns-find]
10+
[clojure.java.classpath :as cp]
11+
[clojure.string :as str]))
12+
13+
(defn exception? [e]
14+
(isa? (type e) Exception))
15+
16+
(defn ns-for-sym [sym]
17+
(when (.contains (str sym) "/")
18+
(-> sym
19+
str
20+
(str/split #"/")
21+
first
22+
symbol)))
23+
24+
(defn setup
25+
"Helper for initializing a clojure.tools.namespace dev
26+
lifecycle. See
27+
http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded
28+
for more info.
29+
30+
This will return a function that, when called, will stop the
31+
current environment, reload all namespaces, and start a new
32+
environment.
33+
34+
Params:
35+
* `start-app-sym` -- FQ symbol of a no-arg function which
36+
starts the environment
37+
* `stop-app-sym` -- FQ symbol of a 1-arg
38+
function which stops the environment. The result of calling the
39+
start app function is passed in as it's first parameter
40+
* `tests-regex` -- Run tests after reload for all namespaces matching"
41+
42+
[{:keys [start-app-sym stop-app-sym tests-regex]}]
43+
(when start-app-sym
44+
(when-not (resolve 'user/reup-app)
45+
(intern 'user 'reup-app nil))
46+
(when-not (resolve 'user/after-reup)
47+
(intern 'user 'after-reup
48+
(fn []
49+
(when start-app-sym
50+
(binding [*ns* (find-ns 'user)]
51+
(alter-var-root (resolve 'user/reup-app)
52+
(constantly (when-let [a (resolve start-app-sym)]
53+
(let [f (deref a)]
54+
(f))))))))))
55+
56+
(require (ns-for-sym start-app-sym) :reload)
57+
(require (ns-for-sym stop-app-sym) :reload)
58+
59+
(when-not (resolve start-app-sym)
60+
(throw (Exception. (str "Can't resolve start-app-sym: " start-app-sym))))
61+
62+
(when-not (resolve stop-app-sym)
63+
(throw (Exception. (str "Can't resolve stop-app-sym: " stop-app-sym)))))
64+
65+
(fn []
66+
(time
67+
(do
68+
(when start-app-sym
69+
(binding [*ns* (find-ns 'user)]
70+
(do
71+
(try
72+
(@(resolve stop-app-sym) @(resolve 'user/reup-app))
73+
(catch Exception e
74+
(println "Exception stopping app:" e)))))
75+
(alter-var-root (resolve 'user/reup-app) (constantly nil)))
76+
(let [res (if start-app-sym
77+
(repl/refresh :after 'user/after-reup)
78+
(repl/refresh))]
79+
(when (exception? res)
80+
(throw res)))
81+
82+
(when tests-regex
83+
(doseq [ns-sym (->> (cp/classpath-directories)
84+
ns-find/find-namespaces
85+
(filter #(re-find tests-regex (str %))))]
86+
(require ns-sym))
87+
(clojure.test/run-all-tests tests-regex))))))

src/cljc/clojuredocs/util.cljc

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88

99

1010
#? (:clj
11-
(:import [org.pegdown PegDownProcessor]
12-
[org.pegdown Parser]
13-
[org.pegdown Extensions])))
11+
(:import [java.net URLEncoder]
12+
[org.bson.types ObjectId]
13+
[com.vladsch.flexmark.html HtmlRenderer]
14+
[com.vladsch.flexmark.parser Parser]
15+
[com.vladsch.flexmark.profile.pegdown Extensions]
16+
[com.vladsch.flexmark.profile.pegdown PegdownOptionsAdapter]
17+
[com.vladsch.flexmark.util.data DataHolder])))
1418

1519
#? (:clj
1620
(do
1721
(defn url-encode [s]
1822
(when s
19-
(java.net.URLEncoder/encode s)))
23+
(URLEncoder/encode s)))
2024

2125

2226
(defn url-decode [s]
@@ -94,11 +98,11 @@
9498
#? (:clj
9599
(defn markdown [s]
96100
(when s
97-
(let [pd (PegDownProcessor. (int (bit-or
98-
Extensions/AUTOLINKS
99-
Extensions/FENCED_CODE_BLOCKS
100-
Extensions/TABLES)))]
101-
(.markdownToHtml pd s)))))
101+
(let [OPTIONS (PegdownOptionsAdapter/flexmarkOptions Extensions/ALL
102+
(make-array com.vladsch.flexmark.util.misc.Extension 0))
103+
PARSER (-> (Parser/builder OPTIONS) .build)
104+
RENDERER (-> (HtmlRenderer/builder OPTIONS) .build)]
105+
(->> s (str) (.parse PARSER) (.render RENDERER))))))
102106

103107
(defn pluralize [n single plural]
104108
(str n " " (if (= 1 n) single plural)))
@@ -166,9 +170,9 @@
166170
#? (:clj
167171
(defn bson-id
168172
([]
169-
(org.bson.types.ObjectId.))
173+
(ObjectId.))
170174
([id-or-str]
171-
(org.bson.types.ObjectId/massageToObjectId id-or-str))))
175+
(ObjectId. (str id-or-str)))))
172176

173177
#? (:clj
174178
(defn uuid []

0 commit comments

Comments
 (0)