Fork me on GitHub
#portal
<
2021-11-20
>
genekim00:11:20

Is there a way to have Portal default to a specific viewer? I’m always having to mouse into the window, select the first output, switch to table view, etc. Thank you! PS: holy smokes, @djblue, having Portal inside of IntelliJ is a total game changer — for the first time, I’m using it in my daily work. I love that the window is always there!

❤️ 3
djblue00:11:51

https://github.com/djblue/portal#viewers Is what you are looking for. Specifically:

^{:portal.viewer/default :portal.viewer/hiccup} [:h1 "hello, world"]

R.A. Porter00:11:47

I was just about to post that link! 😂

gotta_go_fast 2
genekim01:11:00

I think I’ve almost got it — put the metadata in the tap> command? (still showing up as before…). Thx!!!

(tap> ^{:portal.viewer/default :portal.viewer/table} lastsrs)

djblue01:11:37

I think you might need to do:

(tap> (with-meta lastsrs {:portal.viewer/default :portal.viewer/table}))

djblue01:11:01

I think the ^ is putting the metadata on the symbol

seancorfield01:11:40

I'll +100 on the game changing aspect of having Portal in your editor!

wilkerlucio17:11:36

yes, having on the editor makes a ton of difference 👍

wilkerlucio17:11:48

one tip about expanding the items, I recently found out if you focus the element and type e you toggle the expanded state

genekim21:11:15

Thank you, @djblue!! It works! (and @U066U8JQJ!)

genekim21:11:22

@djblue tap> with meta working so wonderfully — not having to mouse into the window, or use keyboard to change the inspector. This is amazing. Thank you for writing this!

❤️ 1
seancorfield21:11:58

A Portal action to render a URL as HTML inside Portal itself leverages the metadata trick (thanks to @djblue for that!).

❤️ 1
🤯 1
djblue21:11:09

Also, FYI this will work recursively on any nested value that has metadata 👌

seancorfield21:11:08

I use it with my "javadoc" and "clojuredocs" Clover tasks that produce URLs. I'm toying with the idea of automating that the whole way (`slurp` and then render as HTML, as part of the URL processing...).

seancorfield22:11:18

done 🙂 Now I can have my mouse on a regex literal, hit ctrl-; j and get the JavaDocs for java.util.regex.Pattern rendered into Portal, so I can look up docs with a hot key without needing a browser. And the same for any Clojure functions via ClojureDocs! ctrl-; ?

awesome 1
🤯 1
pez09:11:42

What's in the way for getting portal show up in the editors also for ClojureScript? Asking for a friend. 😀 Not. My workdays are spent in cljs land.

djblue21:11:26

The web version of portal uses parent / child rpc which isn't possible because vs-code can't host a child window for your browser (chrome/firefox/safari). If you don't need access to the js runtime, the recently added https://github.com/djblue/portal#remote-api should be able to send any serializable value to a version of portal hosted elsewhere.

djblue21:11:40

You just have to make sure to synchronize which port is being used. I plan on adding something to shadow-cljs to do this automatically but haven't had the time.

🙂 1
djblue21:11:05

If you are talking about node cljs land, it's just a matter of porting some clj to cljs and then node would be able to launch it's UI is vs-code.

djblue21:11:22

If you can provide me more details about your setup, I might have some more useful info 👌

pez17:01:12

I have totally missed your attempts to talk to me here, @djblue. Sorry about that. Where I am coming from here is that I want to make it super easy to use portal from Calva. Some kind of explicit support. I have a branch where I experimented with this. It detects the presence of the portal extension and enables some commands and such. I paused the work with this when I couldn’t get it to work with both Clojure and ClojureScript. I realize this is not giving you the details you ask for, but anyway.

djblue20:01:27

So I think the hardest part will always be instrumenting the users runtime. The reason is that there are many ways to get data into a portal inspector with various tradeoffs. Do you mind linking the branch so I can play around with it?

djblue20:01:09

The easiest way to reduce the number of variables you have to worry about is to have the portal backend hosted by vs-code itself. Then instrument all runtimes to simply pipe their data via the remote-api to the vs-code instance. This strategy would work for jvm/node/web identically. The main advantage is ease of use for the user and the main disadvantage is losing access to runtime objects. This could be a reasonable tradeoff for getting people started.

djblue20:01:42

The vs-code hosted portal already works but isn't available outside of development because I didn't have a use case, but this might be one. https://github.com/djblue/portal/blob/master/extension-vscode/package.json#L23-L32 are the commands I used to make sure it works.

djblue20:01:53

And since calva has direct access to the runtime via the nrepl connection, it could easily tie the knot between the remote vs-code portal and the user's runtime. Let me know if any of this is confusing or if you would like some help :thumbsup:

genekim21:11:35

Is there a way to change the size of the text in the Portal window? I’m usually looking at lists of hundreds of maps, and would love to fit more on the screen. (Right now, I’m looking at one with 38K elements in a table. :)

djblue21:11:57

I usually use the browser zoom-in/out feature. I would give cmd - a shot and see if that works.

genekim00:11:41

Alas, that doesn’t work, no matter where I focus / click into. No worries — thanks!

genekim21:11:19

(Jeez. For the first time I’m seeing in full glory all the nil values I’ve accidentally put into my database. :face_palm: I’d post a screenshot, but I fear I’d mortally offend @seancorfield. 😆 Nils in dates, nils in ordinal data. Horrors. Seriously, Portal is amazing, @djblue. I’m seeing things I’ve never seen before, in a dataset I’ve been working with for almost 7 years.

djblue21:11:43

This is awesome! I'm so glad Portal was able to do this for you!

seancorfield21:11:58

Oh, don't worry: we have lots of nullable columns in our DB (and lots of nulls) but we just try to keep them out of our Clojure code as much as possible 🙂

seancorfield21:11:22

(`next.jdbc.optional` provides a way to read DB rows and omit columns with null values, if you care enough)