Skip to content

Commit b0413f6

Browse files
committed
Update docs to include binary data
1 parent f1bbe16 commit b0413f6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

dev/tasks/pwa.clj

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[clojure.java.io :as io]
55
[hiccup.core :refer [html]]
66
[portal.colors :as c]
7+
[portal.runtime.cson :as cson]
78
[portal.runtime.json :as json]
89
[tasks.build :refer [install]]
910
[tasks.docs :as docs]
@@ -47,6 +48,13 @@
4748
[:div {:id "root"}]
4849
[:script {:src "main.js"}]]])))
4950

51+
(defmethod print-method (Class/forName "[B") [v ^java.io.Writer w]
52+
(.write w "#portal/bin \"")
53+
(.write w (cson/base64-encode v))
54+
(.write w "\""))
55+
56+
(comment (remove-method print-method (Class/forName "[B")))
57+
5058
(defn- ->edn [v] (binding [*print-meta* true] (pr-str v)))
5159

5260
(defn- get-files [settings]

src/portal/runtime/cson.cljc

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@
213213

214214
(defn tagged-value? [x] (instance? Tagged x))
215215

216-
(defn base64-encode [byte-array]
216+
(defn base64-encode ^String [byte-array]
217217
#?(:clj (.encodeToString (Base64/getEncoder) byte-array)
218218
:cljs (Base64/encodeByteArray byte-array)
219219
:cljr (Convert/ToBase64String byte-array)))

0 commit comments

Comments
 (0)