reduce regexmania while using given java functions
This commit is contained in:
parent
d9951fced1
commit
b84e02c12f
1 changed files with 7 additions and 13 deletions
|
@ -35,6 +35,8 @@
|
||||||
:resource-type ResourceType})
|
:resource-type ResourceType})
|
||||||
|
|
||||||
; ----------------------- Domain functions ------------------------
|
; ----------------------- Domain functions ------------------------
|
||||||
|
(def no-link-option (into-array [LinkOption/NOFOLLOW_LINKS]))
|
||||||
|
|
||||||
(s/defn create-resource :- Resource
|
(s/defn create-resource :- Resource
|
||||||
([short-path :- ShortPath
|
([short-path :- ShortPath
|
||||||
uri :- ResourceUri
|
uri :- ResourceUri
|
||||||
|
@ -67,11 +69,8 @@
|
||||||
(filter #(not (re-matches ignore-patterns %)) source-list))
|
(filter #(not (re-matches ignore-patterns %)) source-list))
|
||||||
|
|
||||||
; ------------------- infra ---------------------------------
|
; ------------------- infra ---------------------------------
|
||||||
|
|
||||||
(def public "resources/public")
|
(def public "resources/public")
|
||||||
|
|
||||||
(def no-link-option (into-array [LinkOption/NOFOLLOW_LINKS]))
|
|
||||||
|
|
||||||
(defn current-path [])
|
(defn current-path [])
|
||||||
|
|
||||||
(defn user-dir []
|
(defn user-dir []
|
||||||
|
@ -79,7 +78,10 @@
|
||||||
|
|
||||||
(defn absolut-path
|
(defn absolut-path
|
||||||
[& path-elements]
|
[& path-elements]
|
||||||
(Paths/get (user-dir) (into-array String path-elements)))
|
(let [path (Paths/get (first path-elements) (into-array String (rest path-elements)))]
|
||||||
|
(if (.isAbsolute path)
|
||||||
|
path
|
||||||
|
(Paths/get (user-dir) (into-array String path-elements)))))
|
||||||
|
|
||||||
(defn path
|
(defn path
|
||||||
"Creates path from given parts, ignore empty elements"
|
"Creates path from given parts, ignore empty elements"
|
||||||
|
@ -118,14 +120,6 @@
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
nil))))
|
nil))))
|
||||||
|
|
||||||
(s/defn construct-full-path
|
|
||||||
[fs-prefix
|
|
||||||
base-path
|
|
||||||
resource-path]
|
|
||||||
(if (st/starts-with? fs-prefix "./")
|
|
||||||
(str (st/replace fs-prefix #"\./" (str (user-dir) "/")) "/" base-path "/" resource-path)
|
|
||||||
(str fs-prefix "/" base-path "/" resource-path)))
|
|
||||||
|
|
||||||
(defn resource-from-cp-or-fs ; :- Resource
|
(defn resource-from-cp-or-fs ; :- Resource
|
||||||
[fs-prefix ; :- Prefix
|
[fs-prefix ; :- Prefix
|
||||||
base-path ; :- ShortPath
|
base-path ; :- ShortPath
|
||||||
|
@ -133,7 +127,7 @@
|
||||||
& {:keys [from-cp from-fs]
|
& {:keys [from-cp from-fs]
|
||||||
:or {from-cp true
|
:or {from-cp true
|
||||||
from-fs true}}]
|
from-fs true}}]
|
||||||
(let [full-path (construct-full-path fs-prefix base-path resource-path)
|
(let [full-path (.toString (absolut-path fs-prefix base-path resource-path))
|
||||||
cp-path (if (empty? base-path)
|
cp-path (if (empty? base-path)
|
||||||
resource-path
|
resource-path
|
||||||
(str base-path "/" resource-path))
|
(str base-path "/" resource-path))
|
||||||
|
|
Loading…
Reference in a new issue