2020-01-07 12:47:34 +00:00
|
|
|
; Copyright (c) meissa. 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 cryogen-core.new-io
|
|
|
|
(:require
|
|
|
|
[clojure.java.io :as io]
|
|
|
|
[cryogen-core.classpath-able-io :as cp-io]))
|
|
|
|
|
2020-01-07 13:20:21 +00:00
|
|
|
(def delete-resource-recursive! cp-io/delete-resource-recursive!)
|
|
|
|
|
|
|
|
(defn copy-resources-from-templates!
|
2020-01-07 12:47:34 +00:00
|
|
|
[fs-prefix resources target-path ignore-patterns]
|
|
|
|
(let [resource-path "templates"]
|
|
|
|
(cp-io/copy-resources! fs-prefix resource-path resources
|
|
|
|
target-path ignore-patterns)))
|
|
|
|
|
|
|
|
(defn copy-resources-from-theme!
|
|
|
|
[fs-prefix theme target-path ignore-patterns]
|
|
|
|
(let [theme-path (str "templates/themes/" theme)]
|
|
|
|
(cp-io/copy-resources! fs-prefix theme-path ["css" "js"]
|
|
|
|
target-path ignore-patterns)
|
|
|
|
(cp-io/copy-resources! fs-prefix (str theme-path "/html") ["404.html"]
|
|
|
|
target-path ignore-patterns)))
|
|
|
|
|
2020-01-07 14:24:57 +00:00
|
|
|
(defn copy-html-from-theme!
|
|
|
|
[fs-prefix theme target-path ignore-patterns]
|
|
|
|
(let [theme-path (str "templates/themes/" theme)]
|
|
|
|
(cp-io/copy-resources! fs-prefix theme-path ["html"]
|
|
|
|
target-path ignore-patterns)))
|
|
|
|
|
2020-01-07 12:47:34 +00:00
|
|
|
(defn get-distinct-markup-dirs
|
|
|
|
[fs-prefix posts pages ignore-patterns]
|
|
|
|
(let [base-path "templates/md"
|
|
|
|
resources (cp-io/get-resources-recursive
|
|
|
|
fs-prefix base-path [pages posts])
|
|
|
|
filtered-resources (->> (filter #(= (:resource-type %) :dir) resources)
|
|
|
|
(cp-io/distinct-resources-by-path))]
|
|
|
|
filtered-resources))
|
|
|
|
|
|
|
|
(defn create-dirs-from-markup-folders!
|
|
|
|
"Copy resources from markup folders. This does not copy the markup entries."
|
|
|
|
[fs-prefix posts pages target-path ignore-patterns]
|
|
|
|
(let [resources (get-distinct-markup-dirs fs-prefix posts pages
|
|
|
|
ignore-patterns)]
|
|
|
|
(doseq [resource resources]
|
2020-01-17 13:50:42 +00:00
|
|
|
(io/make-parents (io/file (str target-path "/" (:short-path resource))))
|
|
|
|
(.mkdir (io/file (str target-path "/" (:short-path resource)))))))
|