Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns app.core
- (require [clojure.string :as str]
- [clojure.walk :as walk]
- [clj-time.core :as t]
- [com.stuartsierra.component :as component]
- [clojure.core.matrix :as matrix]
- [clojure.data.json :as json]
- [org.httpkit.client :as http]
- [clatrix.core :as clatrix]
- [hiccup.core :refer :all]
- [pl.danieljanus.tagsoup :refer :all]
- [clojure.core.async :refer [go <! >! timeout chan]])
- (:import (java.io File FileOutputStream)))
- (def +path+ "resources/svg/")
- (defn- list-svgs [path]
- (let [files (file-seq (clojure.java.io/file path))
- files (map #(-> {:name (.getName %)
- :path (.getAbsolutePath %)})
- files)
- svg-files (filter #(str/ends-with? (:name %) ".svg") files)
- svg-files (map #(assoc % :contents (slurp (:path %))) svg-files)]
- (into [] svg-files)))
- (defn- svg-to-hiccup [file]
- (assoc file :contents (parse-string (:contents file))))
- (defn- svgs-to-hiccup [files]
- (map svg-to-hiccup files))
- (defn get-svgs [path]
- (svgs-to-hiccup (list-svgs path)))
- (defn create-inline-svg [path inclusion-set]
- (let [svgs (get-svgs path)
- filtered-svgs (filter #(inclusion-set (:name %)) svgs)]
- (apply conj [:div {:display "none"}]
- (into [] (map :contents filtered-svgs)))))
- (defmacro inline-svg [path inclusion-set]
- `(let [svg# (create-inline-svg ~path ~inclusion-set)]
- svg#))
- (println (inline-svg +path+ #{"bussi-24.svg"}))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement