Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion doc/resources/doc/sources/built-in-libraries.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions lib/edge.ig.yada/src/edge/yada/ig.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down