use cp resources for selmer

This commit is contained in:
jem 2020-01-07 15:24:57 +01:00
parent 4dafe54224
commit 0947504a5f
2 changed files with 25 additions and 9 deletions

View file

@ -18,7 +18,9 @@
[clojure.inspector :as inspector] [clojure.inspector :as inspector]
[cryogen-core.toc :as toc] [cryogen-core.toc :as toc]
[cryogen-core.hierarchic :as hierarchic]) [cryogen-core.hierarchic :as hierarchic])
(:import java.util.Locale)) (:import [java.util Locale]
[java.net URI]
[java.io File]))
(cache-off!) (cache-off!)
@ -540,21 +542,29 @@
:rss-uri (cryogen-io/path "/" blog-prefix rss-name) :rss-uri (cryogen-io/path "/" blog-prefix rss-name)
:site-url (if (.endsWith site-url "/") (.substring site-url 0 (dec (count site-url))) site-url)}) :site-url (if (.endsWith site-url "/") (.substring site-url 0 (dec (count site-url))) site-url)})
file-resource-prefix "resources/" file-resource-prefix "resources/"
file-target-prefix "target/"
resource-prefix (str "templates/themes/" theme) resource-prefix (str "templates/themes/" theme)
file-uri (:uri resource-file-uri (:uri
(cp-io/resource-from-cp-or-fs (cp-io/resource-from-cp-or-fs
file-resource-prefix resource-prefix "" file-resource-prefix resource-prefix ""
:from-cp false))] :from-cp false))
target-file-uri (URI. (str (.toURI (.getParentFile (.getAbsoluteFile (File. "."))))
file-target-prefix resource-prefix "/"))]
(when debug? (when debug?
(println (blue "debug: page-model:")) (println (blue "debug: page-model:"))
(println "\t-->" (cyan page-model)) (println "\t-->" (cyan page-model))
(println (blue "debug: prefixes:")) (println (blue "debug: prefixes:"))
(println "\t-->" (cyan file-uri)) (println "\t-->" (cyan resource-file-uri))
(println "\t-->" (cyan target-file-uri))
(println (blue "debug: home-page:")) (println (blue "debug: home-page:"))
(println "\t-->" (cyan (-> params :home-page)))) (println "\t-->" (cyan (-> params :home-page))))
;; TODO: 1. Copy theme/html from fs & cp -> target/theme/html (new-io/delete-resource-recursive! (.getPath target-file-uri))
;; TODO: 2. use target/theme as custome-resource-path (new-io/copy-html-from-theme! "resources/"
(set-custom-resource-path! (.toString file-uri)) theme
(.getPath target-file-uri)
ignored-files)
;(set-custom-resource-path! (.toString resource-file-uri))
(set-custom-resource-path! (.toString target-file-uri))
;(cryogen-io/wipe-public-folder keep-files) ;(cryogen-io/wipe-public-folder keep-files)
(new-io/delete-resource-recursive! (cp-io/path "resources/public" blog-prefix)) (new-io/delete-resource-recursive! (cp-io/path "resources/public" blog-prefix))
(println (blue "copying theme resources")) (println (blue "copying theme resources"))

View file

@ -27,6 +27,12 @@
(cp-io/copy-resources! fs-prefix (str theme-path "/html") ["404.html"] (cp-io/copy-resources! fs-prefix (str theme-path "/html") ["404.html"]
target-path ignore-patterns))) target-path ignore-patterns)))
(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)))
(defn get-distinct-markup-dirs (defn get-distinct-markup-dirs
[fs-prefix posts pages ignore-patterns] [fs-prefix posts pages ignore-patterns]
(let [base-path "templates/md" (let [base-path "templates/md"