From 34f723a55c3a6b70b8f0b272287561b0518ff588 Mon Sep 17 00:00:00 2001 From: jem Date: Wed, 11 Dec 2019 17:53:34 +0100 Subject: [PATCH] "Mob Session DONE [ci-skip]" --- src/cryogen_core/classpath_able_io.clj | 65 ++++++------------- .../themes/bootstrap4-test/css/dummy.css | 0 .../themes/bootstrap4-test/html/404.html | 0 test/cryogen_core/classpath_able_io_test.clj | 4 ++ 4 files changed, 23 insertions(+), 46 deletions(-) create mode 100644 test-resources/templates/themes/bootstrap4-test/css/dummy.css create mode 100644 test-resources/templates/themes/bootstrap4-test/html/404.html diff --git a/src/cryogen_core/classpath_able_io.clj b/src/cryogen_core/classpath_able_io.clj index b11568c..da1ea7a 100644 --- a/src/cryogen_core/classpath_able_io.clj +++ b/src/cryogen_core/classpath_able_io.clj @@ -39,52 +39,23 @@ from-fs (file-from-cp resource-path)))) -; TODO: fix recursion as we put function calls on callstack here -(defn copy-dir-2 - [source-dir target-dir ignore-patterns] - (loop [source-list (.list source-dir)] - (when (not (nil? (first source-list))) - (let [f (first source-list) - target-file (io/file target-dir f) - source-file (io/file source-dir f)] - (println (str "frsit f: " f)) - (if (.isFile source-file) - (do - (println (str "source file: " source-file)) - (io/make-parents target-file) - (io/copy f target-file) - (recur (drop 1 source-list))) - (do - (println source-file) - (recur (concat (drop 1 source-list) (.list source-file))))) - )))) - -(defn copy-dir-3 - [source-dir target-dir ignore-patterns] - (loop [source-list (.list source-dir) - f (first source-list) - source-file (io/file source-dir f) - target-file (io/file target-dir f)] - (if (.isFile source-file) - (do - (println source-file) - (io/make-parents target-file) - (io/copy f target-file) - (recur (drop 1 source-list) (second source-list) (io/file source-dir f))) - (copy-dir source-file target-file ignore-patterns)))) - (defn copy-dir [source-dir target-dir ignore-patterns] - (let [source-list (.list source-dir)] - (doseq [f source-list] - (let [target-file (io/file target-dir f) - source-file (io/file source-dir f)] - (if (.isFile source-file) - (do - (println source-file) - (io/make-parents target-file) - (io/copy f target-file)) - (copy-dir source-file target-file ignore-patterns)))))) + (loop [l-source-list (.list source-dir) + l-source-dir source-dir + l-target-dir target-dir] + (let [f (first l-source-list) + target-file (io/file target-dir f) + source-file (io/file source-dir f)] + (if (.isFile source-file) + (do + (println source-file) + (io/make-parents target-file) + (io/copy f target-file) + ;; continue copying files + (recur (drop 1 source-list) source-dir target-dir)) + ;; recur down to contained directory + (recur (drop 1 source-list) source-file target-file))))) (defn copy-resources [fs-prefix source-path target-path ignore-patterns] @@ -103,6 +74,8 @@ (defn copy-resources-from-theme [fs-prefix theme target-path] - (let [source-path (str "templates/themes/" theme "/js")] - (copy-resources fs-prefix source-path target-path ""))) + (let [theme-path (str "templates/themes/" theme)] + (copy-resources fs-prefix (str theme-path "/css") target-path "") + (copy-resources fs-prefix (str theme-path "/js") target-path "") + (copy-resources fs-prefix (str theme-path "/html/404.html") target-path ""))) diff --git a/test-resources/templates/themes/bootstrap4-test/css/dummy.css b/test-resources/templates/themes/bootstrap4-test/css/dummy.css new file mode 100644 index 0000000..e69de29 diff --git a/test-resources/templates/themes/bootstrap4-test/html/404.html b/test-resources/templates/themes/bootstrap4-test/html/404.html new file mode 100644 index 0000000..e69de29 diff --git a/test/cryogen_core/classpath_able_io_test.clj b/test/cryogen_core/classpath_able_io_test.clj index 1755c96..044c2f1 100644 --- a/test/cryogen_core/classpath_able_io_test.clj +++ b/test/cryogen_core/classpath_able_io_test.clj @@ -51,4 +51,8 @@ (str target "/templates/themes/bootstrap4-test/js/subdir")) (verify-file-exists (str target "/templates/themes/bootstrap4-test/js/subdir/subdummy.js")) + (verify-file-exists + (str target "/templates/themes/bootstrap4-test/css/dummy.css")) + (verify-file-exists + (str target "/templates/themes/bootstrap4-test/html/404.html")) )))) \ No newline at end of file