merge posts image fix

This commit is contained in:
Albert Lai 2015-06-14 18:42:04 +08:00
commit 2119ed52aa
2 changed files with 11 additions and 8 deletions

View file

@ -2,8 +2,7 @@
(:require [selmer.parser :refer [cache-off! render-file]] (:require [selmer.parser :refer [cache-off! render-file]]
[selmer.util :refer [set-custom-resource-path!]] [selmer.util :refer [set-custom-resource-path!]]
[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]]
@ -264,7 +263,6 @@
[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-resources-from-theme (defn copy-resources-from-theme
"Copy resources from theme" "Copy resources from theme"
[config] [config]
@ -274,6 +272,15 @@
{:resources [(str theme-path "/css") {:resources [(str theme-path "/css")
(str theme-path "/js")]})))) (str theme-path "/js")]}))))
(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"
[] []
@ -326,7 +333,7 @@
(copy-resources-from-theme config) (copy-resources-from-theme config)
(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)

View file

@ -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)