diff --git a/doc/resources/doc/sources/built-in-libraries.adoc b/doc/resources/doc/sources/built-in-libraries.adoc index 97a23e41..5e7bdb07 100644 --- a/doc/resources/doc/sources/built-in-libraries.adoc +++ b/doc/resources/doc/sources/built-in-libraries.adoc @@ -18,7 +18,7 @@ Example::: * `:edge.yada.ig/redirect` Creates a yada redirect resource by calling `yada.yada/redirect`. Parameters::: `:target`:::: The first argument to `yada.yada/redirect`, the `:id` of the resource to route to. -`:opts`:::: The second argument to `yada.yada/redirect` +`:opts`:::: The second argument to `yada.yada/redirect` Example::: + [source,clojure] @@ -44,6 +44,40 @@ Example::: :edge.yada.ig/classpath-name {:name "cljsjs/pikaday/development/pikaday.css"} ---- +* `:edge.yada.ig/directory-resource` ++ +Calls `yada.resources.file-resource/new-directory-resource` on the `io/file` of the `:path` provided and on an `:options` map. +Equivalent to `(yada.resources.file-resource/new-directory-resource (io/file (:path opts)) (:options opts))`. ++ +Parameters::: +`:path`:::: Path of system directory to target +`:options`:::: Map of options +Example::: ++ +[source,clojure] +---- +:edge.yada.ig/directory-resource +{:path "/home/user/target/folder/" + :options {...}} +---- + +* `:edge.yada.ig/file-resource` ++ +Calls `yada.resources.file-resource/new-file-resource` on the `io/file` of the `:path` provided and on an `:options` map. +Equivalent to `(yada.resources.file-resource/new-file-resource (io/file (:path opts)) (:options opts))`. ++ +Parameters::: +`:path`:::: Path of the file to target +`:options`:::: Map of options +Example::: ++ +[source,clojure] +---- +:edge.yada.ig/file-resource +{:path "/home/user/target/folder/file.txt" + :options {...}} +---- + * `:edge.yada.ig/webjar` + Calls `yada.resources.webjar-resource/new-webjar-resource` with the given options map. diff --git a/lib/edge.ig.yada/src/edge/yada/ig.clj b/lib/edge.ig.yada/src/edge/yada/ig.clj index 6e9f38c9..8962df93 100644 --- a/lib/edge.ig.yada/src/edge/yada/ig.clj +++ b/lib/edge.ig.yada/src/edge/yada/ig.clj @@ -26,6 +26,18 @@ id (assoc :id id))) +(defmethod ig/init-key ::directory-resource + [_ {:keys [path options]}] + (@(requiring-resolve 'yada.resources.file-resource/new-directory-resource) + (io/file path) + options)) + +(defmethod ig/init-key ::file-resource + [_ {:keys [path options]}] + (@(requiring-resolve 'yada.resources.file-resource/new-file-resource) + (io/file path) + options)) + (defmethod ig/init-key ::classpath-name [_ {:keys [name]}] (yada/as-resource (io/resource name)))