Merge remote-tracking branch 'origin/mob-session' into mob-session2
This commit is contained in:
commit
025b5c16a7
5 changed files with 25 additions and 19 deletions
|
@ -10,6 +10,16 @@
|
||||||
(:require [clojure.java.io :as io]
|
(:require [clojure.java.io :as io]
|
||||||
[clojure.string :as s]))
|
[clojure.string :as s]))
|
||||||
|
|
||||||
|
(def public "resources/public")
|
||||||
|
|
||||||
|
(defn path
|
||||||
|
"Creates path from given parts, ignore empty elements"
|
||||||
|
[& path-parts]
|
||||||
|
(->> path-parts
|
||||||
|
(remove s/blank?)
|
||||||
|
(s/join "/")
|
||||||
|
(#(s/replace % #"/+" "/"))))
|
||||||
|
|
||||||
(defn filter-for-ignore-patterns
|
(defn filter-for-ignore-patterns
|
||||||
[ignore-patterns source-list]
|
[ignore-patterns source-list]
|
||||||
(filter #(not (re-matches ignore-patterns %)) source-list))
|
(filter #(not (re-matches ignore-patterns %)) source-list))
|
||||||
|
@ -54,12 +64,12 @@
|
||||||
(file-from-cp resource-path))))
|
(file-from-cp resource-path))))
|
||||||
|
|
||||||
(defn copy-file
|
(defn copy-file
|
||||||
[source-file ;first element of (.list source-dir)
|
[source-file
|
||||||
target-file]
|
target-file]
|
||||||
(do (io/make-parents target-file)
|
(do (io/make-parents target-file)
|
||||||
(io/copy source-file target-file)))
|
(io/copy source-file target-file)))
|
||||||
|
|
||||||
(defn copy-dir
|
(defn do-copy
|
||||||
[source-dir target-dir ignore-patterns]
|
[source-dir target-dir ignore-patterns]
|
||||||
(loop [source-list (.list source-dir)
|
(loop [source-list (.list source-dir)
|
||||||
file-path-prefix [""]]
|
file-path-prefix [""]]
|
||||||
|
@ -82,20 +92,13 @@
|
||||||
(let [source-file (file-from-cp-or-filesystem fs-prefix source-path)
|
(let [source-file (file-from-cp-or-filesystem fs-prefix source-path)
|
||||||
target-file (io/file target-path source-path)
|
target-file (io/file target-path source-path)
|
||||||
is-source-dir? (.isDirectory source-file)]
|
is-source-dir? (.isDirectory source-file)]
|
||||||
(cond
|
(if (nil? source-file)
|
||||||
(nil? source-file)
|
|
||||||
(throw (IllegalArgumentException. (str "resource " source-path " not found")))
|
(throw (IllegalArgumentException. (str "resource " source-path " not found")))
|
||||||
is-source-dir?
|
(do-copy source-file target-file ignore-patterns))))
|
||||||
(copy-dir source-file target-file ignore-patterns)
|
|
||||||
:else (copy-file source-file target-file)
|
|
||||||
;; TODO: Call copy-file fct. - take care on parameter.
|
|
||||||
)))
|
|
||||||
|
|
||||||
|
|
||||||
(defn copy-resources-from-theme
|
(defn copy-resources-from-theme
|
||||||
[fs-prefix theme target-path]
|
[fs-prefix theme target-path ignore-patterns]
|
||||||
(let [theme-path (str "templates/themes/" theme)]
|
(let [theme-path (str "templates/themes/" theme)]
|
||||||
(copy-resources fs-prefix (str theme-path "/css") target-path "")
|
(copy-resources fs-prefix (str theme-path "/css") target-path ignore-patterns)
|
||||||
(copy-resources fs-prefix (str theme-path "/js") target-path "")
|
(copy-resources fs-prefix (str theme-path "/js") target-path ignore-patterns)
|
||||||
(copy-resources fs-prefix (str theme-path "/html/404.html") target-path "")))
|
(copy-resources fs-prefix (str theme-path "/html/") target-path ignore-patterns)))
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
[selmer.util :refer [set-custom-resource-path!]]
|
[selmer.util :refer [set-custom-resource-path!]]
|
||||||
[text-decoration.core :refer :all]
|
[text-decoration.core :refer :all]
|
||||||
[cryogen-core.io :as cryogen-io]
|
[cryogen-core.io :as cryogen-io]
|
||||||
|
[cryogen-core.classpath-able-io :as cp-io]
|
||||||
[cryogen-core.klipse :as klipse]
|
[cryogen-core.klipse :as klipse]
|
||||||
[cryogen-core.markup :as m]
|
[cryogen-core.markup :as m]
|
||||||
[cryogen-core.rss :as rss]
|
[cryogen-core.rss :as rss]
|
||||||
|
@ -533,8 +534,10 @@
|
||||||
(set-custom-resource-path! (str "file:resources/templates/themes/" theme))
|
(set-custom-resource-path! (str "file:resources/templates/themes/" theme))
|
||||||
(cryogen-io/wipe-public-folder keep-files)
|
(cryogen-io/wipe-public-folder keep-files)
|
||||||
(println (blue "copying theme resources"))
|
(println (blue "copying theme resources"))
|
||||||
;; TODO: adjust for reading from jar
|
(cp-io/copy-resources-from-theme "resources/templates/themes/"
|
||||||
(cryogen-io/copy-resources-from-theme config)
|
theme
|
||||||
|
(cp-io/path "resources/public" blog-prefix)
|
||||||
|
ignored-files)
|
||||||
(println (blue "copying resources"))
|
(println (blue "copying resources"))
|
||||||
(cryogen-io/copy-resources config)
|
(cryogen-io/copy-resources config)
|
||||||
(copy-resources-from-markup-folders config)
|
(copy-resources-from-markup-folders config)
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
|
|
||||||
(deftest test-copy-resources-from-theme
|
(deftest test-copy-resources-from-theme
|
||||||
(is (do
|
(is (do
|
||||||
(sut/copy-resources-from-theme "./" theme target)
|
(sut/copy-resources-from-theme "./" theme target "")
|
||||||
(and (verify-dir-exists
|
(and (verify-dir-exists
|
||||||
(str target "/templates/themes/bootstrap4-test/js"))
|
(str target "/templates/themes/bootstrap4-test/js"))
|
||||||
(verify-file-exists
|
(verify-file-exists
|
||||||
|
|
Loading…
Reference in a new issue