fix issue #24 image handling in Post is generally broken
This commit is contained in:
parent
717b2dc370
commit
bc62c8a790
2 changed files with 12 additions and 8 deletions
|
@ -1,8 +1,7 @@
|
||||||
(ns cryogen-core.compiler
|
(ns cryogen-core.compiler
|
||||||
(:require [selmer.parser :refer [cache-off! render-file]]
|
(:require [selmer.parser :refer [cache-off! render-file]]
|
||||||
[cryogen-core.io :refer
|
[cryogen-core.io :refer
|
||||||
[get-resource find-assets create-folder wipe-public-folder copy-resources
|
[get-resource find-assets create-folder wipe-public-folder copy-resources]]
|
||||||
copy-images-from-markdown-folders]]
|
|
||||||
[cryogen-core.sitemap :as sitemap]
|
[cryogen-core.sitemap :as sitemap]
|
||||||
[cryogen-core.rss :as rss]
|
[cryogen-core.rss :as rss]
|
||||||
[io.aviso.exception :refer [write-exception]]
|
[io.aviso.exception :refer [write-exception]]
|
||||||
|
@ -263,6 +262,15 @@
|
||||||
[posts config]
|
[posts config]
|
||||||
(map #(update-in % [:tags] (partial map (partial tag-info config))) posts))
|
(map #(update-in % [:tags] (partial map (partial tag-info config))) posts))
|
||||||
|
|
||||||
|
(defn copy-resoures-from-markup-folders
|
||||||
|
"Copy resources from markup folders"
|
||||||
|
[config]
|
||||||
|
(copy-resources
|
||||||
|
(merge config
|
||||||
|
{:resources (for [mu (m/markups)
|
||||||
|
t ["posts" "pages"]] (str (m/dir mu) "/" t))
|
||||||
|
:ignored-files (map #(re-pattern-from-ext (m/ext %)) (m/markups))})))
|
||||||
|
|
||||||
(defn read-config
|
(defn read-config
|
||||||
"Reads the config file"
|
"Reads the config file"
|
||||||
[]
|
[]
|
||||||
|
@ -311,7 +319,7 @@
|
||||||
(wipe-public-folder keep-files)
|
(wipe-public-folder keep-files)
|
||||||
(println (blue "copying resources"))
|
(println (blue "copying resources"))
|
||||||
(copy-resources config)
|
(copy-resources config)
|
||||||
(copy-images-from-markdown-folders config)
|
(copy-resoures-from-markup-folders config)
|
||||||
(compile-pages params pages)
|
(compile-pages params pages)
|
||||||
(compile-posts params posts)
|
(compile-posts params posts)
|
||||||
(compile-tags params posts-by-tag)
|
(compile-tags params posts-by-tag)
|
||||||
|
|
|
@ -45,10 +45,6 @@
|
||||||
(doseq [path (.listFiles (io/file public) filenamefilter)]
|
(doseq [path (.listFiles (io/file public) filenamefilter)]
|
||||||
(fs/delete-dir path))))
|
(fs/delete-dir path))))
|
||||||
|
|
||||||
(defn copy-images-from-markdown-folders [{:keys [blog-prefix]}]
|
|
||||||
(doseq [asset (fs/find-files "resources/templates/md" #".+(jpg|jpeg|png|gif)")]
|
|
||||||
(io/copy asset (io/file (str public blog-prefix "/img/" (.getName asset))))))
|
|
||||||
|
|
||||||
(defn copy-dir [src target ignored-files]
|
(defn copy-dir [src target ignored-files]
|
||||||
(fs/mkdirs target)
|
(fs/mkdirs target)
|
||||||
(let [filename-filter (apply reject-re-filter ignored-files)
|
(let [filename-filter (apply reject-re-filter ignored-files)
|
||||||
|
@ -62,7 +58,7 @@
|
||||||
(defn copy-resources [{:keys [blog-prefix resources ignored-files]}]
|
(defn copy-resources [{:keys [blog-prefix resources ignored-files]}]
|
||||||
(doseq [resource resources]
|
(doseq [resource resources]
|
||||||
(let [src (str "resources/templates/" resource)
|
(let [src (str "resources/templates/" resource)
|
||||||
target (str public blog-prefix "/" resource)]
|
target (str public blog-prefix "/" (fs/base-name resource))]
|
||||||
(cond
|
(cond
|
||||||
(not (.exists (io/file src)))
|
(not (.exists (io/file src)))
|
||||||
(throw (IllegalArgumentException. (str "resource " src " not found")))
|
(throw (IllegalArgumentException. (str "resource " src " not found")))
|
||||||
|
|
Loading…
Reference in a new issue