Refactor generate-output-file-map to use ->>

This commit is contained in:
Archie Hilton 2024-11-04 22:14:29 +00:00
parent 709ca93d98
commit 175dae050b
1 changed files with 6 additions and 5 deletions

View File

@ -20,7 +20,6 @@ the filenames as keyword keys"
(let [files (list-files template-dir)] (let [files (list-files template-dir)]
(reduce #(assoc %1 (keyword (.getName %2)) (slurp %2)) {} files))) (reduce #(assoc %1 (keyword (.getName %2)) (slurp %2)) {} files)))
; Generate a string-string map of the new filepaths and the unprocessed contents
(defn generate-output-file-map (defn generate-output-file-map
"Take the input html files, read them, and create a mapping of their paths to "Take the input html files, read them, and create a mapping of their paths to
their contents. their contents.
@ -28,9 +27,11 @@ the filenames as keyword keys"
[html-dir, output-dir] [html-dir, output-dir]
(let [file-listing (list-files html-dir) (let [file-listing (list-files html-dir)
contents (map slurp file-listing) contents (map slurp file-listing)
old-paths (map #(.getPath %) file-listing) new-paths (map #(->> %
rootless-paths (map #(subs % (count html-dir)) old-paths) .getPath
new-paths (map #(string/join [output-dir %]) rootless-paths)] (drop (count html-dir))
(cons output-dir)
(string/join)) file-listing)]
(zipmap new-paths contents))) (zipmap new-paths contents)))
(defn put_file (defn put_file
@ -60,5 +61,5 @@ the filenames as keyword keys"
(for [of output-file-map] (for [of output-file-map]
; of is a key-value pair ; of is a key-value pair
(put_file (insert_templates of template-map)) (put_file (insert_templates of template-map))
;(put_file of) ;(put_file of)
) )