Fork me on GitHub

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 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

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)


I think you might need to do:

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


I think the ^ is putting the metadata on the symbol


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


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


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


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


@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

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

❤️ 1
🤯 1

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


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...).


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

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.


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 should be able to send any serializable value to a version of portal hosted elsewhere.


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

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.


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


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.


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?


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.


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. are the commands I used to make sure it works.


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:


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. :)


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


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


(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.


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


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 🙂


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