Fork me on GitHub
#portal
<
2023-08-04
>
djblue06:08:05

Would people be interested in a Portal development / internals talk? If so, any specific topics?

👍 20
👎 2
4
Daniel Slutsky11:08:08

That would be fantastic. 💜 Two topics that would be lovely to hear about: • creating new viewers with cljs or js dependencies ◦ (maybe demonstrated through what https://github.com/mentat-collective/emmy-viewers/ does?) • creating extensions (embedding portal in other pieces of tooling) ◦ e.g., is there a recommended way to embed a (standalone) portal viewer in a blog post?

2
☝️ 2
djblue03:08:04

@U066L8B18 I have some https://github.com/djblue/portal/compare/master...clerk-vs-code-notebook stuff I made for clerk. Would love to collaborate to see if the API's make sense for embedding in other contexts, such as blog posts or https://github.com/scicloj/kind-portal.

Daniel Slutsky05:08:56

Ohh wonderful! I'll look 🙏

❤️ 2
Daniel Slutsky13:09:47

@U1G869VNV I finally tried the approach above (by building the clerk-vs-code-notebook branch locally). Really nice!! The image below shows a couple of code examples rendered through https://scicloj.github.io/clay/ + https://quarto.org/. This means we can have Portal viewers in our notebooks, docs, books, blog posts, etc. cc @UPGS9BS0L @U06S1EJPL Are you planning to merge clerk-vs-code-notebook ? (it is not a pressing for me, just curious about the plans)

djblue17:09:16

I think I still had some issues I needed to work through, but I do intend to merge it 👍

🙏 2
djblue20:09:18

Do you have any links I can use to see how the integration was done to achieve this? I want to make sure I keep things working as I fix issues with that branch.

Daniel Slutsky02:09:48

Thanks! Haven't pushed it yet. I'll write an example, hopefully today.

Daniel Slutsky19:09:59

BTW the image above demonstrates wrong behaviour, due to a mistake of mine. Instead of passing {:x (0 1 2)} to portal, I am transforming it internally to something else, and that is why it is displayed that way.

Daniel Slutsky20:09:45

@U1G869VNV here is a small example demonstrating the use of embedded portal (similar to what I'm hoping to use in Clay & Quarto): This commit includes two files: • example.html - an HTML document calling Portal using #C034FQN490Esrc/examples/scittle.clj - a Clojure namespace to generate that document. https://github.com/daslu/portal/commit/e127f9a83ec95b51a9bdc2923670eb40994fce45

djblue02:09:16

I got around to merging the required changes to get the scittle example working https://github.com/djblue/portal/commit/5f8d51a435f4be4e8e146d700622c2f95f4e031a. The api is located in a different place but is the same. I update the example to use the new api.

djblue02:09:56

Also, updated the standalone js bundle deployed at https://djblue.github.io/portal/main.js to also provide this api 👍

djblue02:09:00

If you pull from the standalone version, you can't lock to a specific version. I could see deploying <version>/main.js if this is useful :thinking_face:

djblue02:09:36

Also, it might be kinda cool if loading the bundle.js, registered a scittle namespace kinda like reagent :thinking_face:

djblue02:09:33

Although, because these are two different shadow-cljs builds, the code probably can't interop very well since each have their own version of cljs.

Daniel Slutsky04:09:19

Great! I'll use it soon. 🙏 The current use case (embedding Portal views in a notebook/blogpost/book) will not require interop. It will even be simpler than the Scittle-based example I shared earlier. As @U06S1EJPL pointed out to me, the simplest thing to do would be to just use Portal from a Javascript snippet with the Clojure value converted to JSON. One practical question, I guess, will be how to set up custom Portal viewers (like the https://github.com/mentat-collective/emmy-viewers collection).

djblue05:09:47

Good to know 👍 I think there will be a couple of different problems getting emmy-viewers setup in this type of environment. The first couple that come to mind are npm dependencies and loading the cljs for the viewer. Also, I'm not sure how the clj bits of emmy interact with the cljs bits.

👍 1
djblue03:09:07

Ok, js/portal_api is now available with the https://github.com/djblue/portal/releases/tag/0.48.0 release.

👍 1