removed old io
This commit is contained in:
parent
6c1159289d
commit
c6559f8a3e
7 changed files with 86 additions and 81 deletions
|
@ -8,7 +8,6 @@
|
|||
[selmer.util :refer [set-custom-resource-path!]]
|
||||
[text-decoration.core :refer :all]
|
||||
; TODO: remove all cryogen-io occurance
|
||||
[cryogen-core.io :as cryogen-io]
|
||||
[cryogen-core.new-io :as new-io]
|
||||
[cryogen-core.classpath-able-io :as cp-io]
|
||||
[cryogen-core.klipse :as klipse]
|
||||
|
@ -227,8 +226,8 @@
|
|||
"When `clean-urls?` is set, appends `/index.html` before spit; otherwise just spits."
|
||||
[file-uri {:keys [clean-urls?]} data]
|
||||
(if clean-urls?
|
||||
(cryogen-io/create-file-recursive (new-io/path file-uri "index.html") data)
|
||||
(cryogen-io/create-file file-uri data)))
|
||||
(new-io/create-file-recursive (new-io/path file-uri "index.html") data)
|
||||
(new-io/create-file file-uri data)))
|
||||
|
||||
(defn- print-debug-info [data]
|
||||
(println "DEBUG:")
|
||||
|
@ -263,7 +262,7 @@
|
|||
:as params} posts]
|
||||
(when-not (empty? posts)
|
||||
(println (blue "compiling posts"))
|
||||
(cryogen-io/create-folder (new-io/path "/" blog-prefix post-root-uri))
|
||||
(new-io/create-folder (new-io/path "/" blog-prefix post-root-uri))
|
||||
(doseq [{:keys [uri]
|
||||
:as post} posts]
|
||||
(println "-->" (cyan uri))
|
||||
|
@ -285,7 +284,7 @@
|
|||
:as params} posts-by-tag]
|
||||
(when-not (empty? posts-by-tag)
|
||||
(println (blue "compiling tags"))
|
||||
(cryogen-io/create-folder (new-io/path "/" blog-prefix tag-root-uri))
|
||||
(new-io/create-folder (new-io/path "/" blog-prefix tag-root-uri))
|
||||
(doseq [[tag posts] posts-by-tag]
|
||||
(let [{:keys [name uri]} (tag-info params tag)]
|
||||
(println "-->" (cyan uri))
|
||||
|
@ -362,7 +361,7 @@
|
|||
previews (if (> (count previews) 1)
|
||||
(assoc-in previews [1 :prev] (page-uri "index.html" params))
|
||||
previews)]
|
||||
(cryogen-io/create-folder (new-io/path "/" blog-prefix "p"))
|
||||
(new-io/create-folder (new-io/path "/" blog-prefix "p"))
|
||||
(doseq [{:keys [index posts prev next]} previews
|
||||
:let [index-page? (= 1 index)]]
|
||||
(write-html
|
||||
|
@ -418,7 +417,7 @@
|
|||
[{:keys [blog-prefix author-root-uri author]
|
||||
:as params} posts]
|
||||
(println (blue "compiling authors"))
|
||||
(cryogen-io/create-folder (new-io/path "/" blog-prefix author-root-uri))
|
||||
(new-io/create-folder (new-io/path "/" blog-prefix author-root-uri))
|
||||
;; if the post author is empty defaults to config's :author
|
||||
(doseq [{:keys [author posts]} (group-for-author posts author)]
|
||||
(let [uri (page-uri (str author ".html") :author-root-uri params)]
|
||||
|
@ -454,7 +453,7 @@
|
|||
:as config}]
|
||||
(let [folders (->> (markup-entries post-root page-root)
|
||||
(filter template-dir?))]
|
||||
(cryogen-io/copy-resources
|
||||
(new-io/copy-resources
|
||||
(merge config
|
||||
{:resources folders
|
||||
:ignored-files (map #(re-pattern-from-ext (m/ext %)) (m/markups))}))))
|
||||
|
@ -464,7 +463,7 @@
|
|||
[]
|
||||
(try
|
||||
(let [config (-> "templates/config.edn"
|
||||
cryogen-io/get-resource
|
||||
new-io/get-resource
|
||||
slurp
|
||||
read-string
|
||||
(update-in [:blog-prefix] (fnil str ""))
|
||||
|
@ -592,10 +591,10 @@
|
|||
(compile-authors params posts))
|
||||
(println (blue "generating site map"))
|
||||
(->> (sitemap/generate site-url ignored-files)
|
||||
(cryogen-io/create-file (new-io/path "/" blog-prefix "sitemap.xml")))
|
||||
(new-io/create-file (new-io/path "/" blog-prefix "sitemap.xml")))
|
||||
(println (blue "generating main rss"))
|
||||
(->> (rss/make-channel config posts)
|
||||
(cryogen-io/create-file (new-io/path "/" blog-prefix rss-name)))
|
||||
(new-io/create-file (new-io/path "/" blog-prefix rss-name)))
|
||||
(println (blue "generating filtered rss"))
|
||||
(rss/make-filtered-channels config posts-by-tag)
|
||||
(println (blue "compiling sass"))
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
(ns cryogen-core.io
|
||||
(:require [clojure.java.io :as io]
|
||||
[clojure.string :as s]
|
||||
[cryogen-core.new-io :as new-io]
|
||||
[me.raynes.fs :as fs]))
|
||||
|
||||
(def public "resources/public")
|
||||
|
||||
(defn re-filter [bool-fn re & other-res]
|
||||
(let [res (conj other-res re)]
|
||||
(reify java.io.FilenameFilter
|
||||
(accept [this _ name]
|
||||
(bool-fn (some #(re-find % name) res))))))
|
||||
|
||||
(def match-re-filter (partial re-filter some?))
|
||||
(def reject-re-filter (partial re-filter nil?))
|
||||
|
||||
(defn get-resource [resource]
|
||||
(-> resource io/resource io/file))
|
||||
|
||||
(defn ignore [ignored-files]
|
||||
(fn [^java.io.File file]
|
||||
(let [name (.getName file)
|
||||
matches (map #(re-find % name) ignored-files)]
|
||||
(not (some seq matches)))))
|
||||
|
||||
(defn create-folder [folder]
|
||||
(let [loc (io/file (new-io/path public folder))]
|
||||
(when-not (.exists loc)
|
||||
(.mkdirs loc))))
|
||||
|
||||
(defn create-file [file data]
|
||||
(spit (new-io/path public file) data))
|
||||
|
||||
(defn create-file-recursive [file data]
|
||||
(create-folder (.getParent (io/file file)))
|
||||
(create-file file data))
|
||||
|
||||
(defn copy-dir [src target ignored-files]
|
||||
(fs/mkdirs target)
|
||||
(let [^java.io.FilenameFilter filename-filter (apply reject-re-filter ignored-files)
|
||||
files (.listFiles (io/file src) filename-filter)]
|
||||
(doseq [^java.io.File f files]
|
||||
(let [out (io/file target (.getName f))]
|
||||
(if (.isDirectory f)
|
||||
(copy-dir f out ignored-files)
|
||||
(io/copy f out))))))
|
||||
|
||||
(defn copy-resources [{:keys [blog-prefix resources ignored-files]}]
|
||||
(doseq [resource resources]
|
||||
(let [src (str "resources/templates/" resource)
|
||||
target (new-io/path public blog-prefix (fs/base-name resource))]
|
||||
(cond
|
||||
(not (.exists (io/file src)))
|
||||
(throw (IllegalArgumentException. (str "resource " src " not found")))
|
||||
(.isDirectory (io/file src))
|
||||
(copy-dir src target ignored-files)
|
||||
:else
|
||||
(fs/copy src target)))))
|
|
@ -9,7 +9,8 @@
|
|||
(ns cryogen-core.new-io
|
||||
(:require [clojure.string :as st]
|
||||
[clojure.java.io :as io]
|
||||
[cryogen-core.classpath-able-io :as cp-io]))
|
||||
[cryogen-core.classpath-able-io :as cp-io]
|
||||
[me.raynes.fs :as fs]))
|
||||
|
||||
(def delete-resources! cp-io/delete-resources!)
|
||||
|
||||
|
@ -77,3 +78,69 @@ if no, return empty vector."
|
|||
(->> assets
|
||||
filter-file
|
||||
filter-ext)))
|
||||
|
||||
;
|
||||
;
|
||||
; taken from io.clj
|
||||
|
||||
(defn re-filter [bool-fn re & other-res]
|
||||
(let [res (conj other-res re)]
|
||||
(reify java.io.FilenameFilter
|
||||
(accept [this _ name]
|
||||
(bool-fn (some #(re-find % name) res))))))
|
||||
|
||||
(def match-re-filter (partial re-filter some?))
|
||||
(def reject-re-filter (partial re-filter nil?))
|
||||
|
||||
(defn copy-dir [src target ignored-files]
|
||||
(fs/mkdirs target)
|
||||
(let [^java.io.FilenameFilter filename-filter (apply reject-re-filter ignored-files)
|
||||
files (.listFiles (io/file src) filename-filter)]
|
||||
(doseq [^java.io.File f files]
|
||||
(let [out (io/file target (.getName f))]
|
||||
(if (.isDirectory f)
|
||||
(copy-dir f out ignored-files)
|
||||
(io/copy f out))))))
|
||||
|
||||
(defn create-folder [folder]
|
||||
(let [loc (io/file (path public folder))]
|
||||
(when-not (.exists loc)
|
||||
(.mkdirs loc))))
|
||||
|
||||
(defn create-file [file data]
|
||||
(spit (path public file) data))
|
||||
|
||||
(defn create-file-recursive [file data]
|
||||
(create-folder (.getParent (io/file file)))
|
||||
(create-file file data))
|
||||
|
||||
(defn copy-dir [src target ignored-files]
|
||||
(fs/mkdirs target)
|
||||
(let [^java.io.FilenameFilter filename-filter (apply reject-re-filter ignored-files)
|
||||
files (.listFiles (io/file src) filename-filter)]
|
||||
(doseq [^java.io.File f files]
|
||||
(let [out (io/file target (.getName f))]
|
||||
(if (.isDirectory f)
|
||||
(copy-dir f out ignored-files)
|
||||
(io/copy f out))))))
|
||||
|
||||
(defn copy-resources [{:keys [blog-prefix resources ignored-files]}]
|
||||
(doseq [resource resources]
|
||||
(let [src (str "resources/templates/" resource)
|
||||
target (path public blog-prefix (fs/base-name resource))]
|
||||
(cond
|
||||
(not (.exists (io/file src)))
|
||||
(throw (IllegalArgumentException. (str "resource " src " not found")))
|
||||
(.isDirectory (io/file src))
|
||||
(copy-dir src target ignored-files)
|
||||
:else
|
||||
(fs/copy src target)))))
|
||||
|
||||
(defn ignore [ignored-files]
|
||||
(fn [^java.io.File file]
|
||||
(let [name (.getName file)
|
||||
matches (map #(re-find % name) ignored-files)]
|
||||
(not (some seq matches)))))
|
||||
|
||||
(defn get-resource [resource]
|
||||
(-> resource io/resource io/file))
|
|
@ -1,8 +1,7 @@
|
|||
(ns cryogen-core.rss
|
||||
(:require [clj-rss.core :as rss]
|
||||
[cryogen-core.new-io :as new-io]
|
||||
[text-decoration.core :refer :all]
|
||||
[cryogen-core.io :as cryogen-io])
|
||||
[text-decoration.core :refer :all])
|
||||
(:import java.util.Date))
|
||||
|
||||
(defn posts-to-items [^String site-url posts]
|
||||
|
@ -33,4 +32,4 @@
|
|||
(doseq [filter rss-filters]
|
||||
(let [uri (new-io/path "/" blog-prefix (str (name filter) ".xml"))]
|
||||
(println "\t-->" (cyan uri))
|
||||
(cryogen-io/create-file uri (make-channel config (get posts-by-tag filter))))))
|
||||
(new-io/create-file uri (make-channel config (get posts-by-tag filter))))))
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
(:require [clojure.java.io :as io]
|
||||
[clojure.java.shell :as shell]
|
||||
[text-decoration.core :refer :all]
|
||||
[cryogen-core.io :as cryogen-io]))
|
||||
[cryogen-core.new-io :as new-io]))
|
||||
|
||||
(defmacro sh
|
||||
[& args]
|
||||
|
@ -26,10 +26,10 @@
|
|||
"Given a Diretory, gets files, Filtered to those having scss or sass
|
||||
extention. Ignores files matching any ignored regexps."
|
||||
[base-dir dir ignored-files]
|
||||
(let [^java.io.FilenameFilter filename-filter (cryogen-io/match-re-filter #"(?i:s[ca]ss$)")]
|
||||
(let [^java.io.FilenameFilter filename-filter (new-io/match-re-filter #"(?i:s[ca]ss$)")]
|
||||
(->> (.listFiles (io/file base-dir dir) filename-filter)
|
||||
(filter #(not (.isDirectory ^java.io.File %)))
|
||||
(filter (cryogen-io/ignore ignored-files))
|
||||
(filter (new-io/ignore ignored-files))
|
||||
(map #(.getName ^java.io.File %)))))
|
||||
|
||||
(defn compile-sass-file!
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
(ns cryogen-core.sitemap
|
||||
(:require [clojure.xml :refer [emit]]
|
||||
[cryogen-core.io :as cryogen-io]
|
||||
[cryogen-core.new-io :as new-io])
|
||||
(:import java.util.Date))
|
||||
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
[clojure.set :as set]
|
||||
[hawk.core :as hawk]
|
||||
[pandect.algo.md5 :as md5]
|
||||
[cryogen-core.io :as cryogen-io]))
|
||||
[cryogen-core.new-io :as new-io]))
|
||||
|
||||
(defn get-assets [path ignored-files]
|
||||
(->> path
|
||||
io/file
|
||||
file-seq
|
||||
(filter #(not (.isDirectory ^java.io.File %)))
|
||||
(filter (cryogen-io/ignore ignored-files))))
|
||||
(filter (new-io/ignore ignored-files))))
|
||||
|
||||
(defn checksums [path ignored-files]
|
||||
(let [files (get-assets path ignored-files)]
|
||||
|
|
Loading…
Reference in a new issue