portal

markaddleman 2023-10-13T14:22:10.351989Z

I’m sending a bunch of strings to portal that I’d like to be formatted as :portal.view/code by default. Of course, since they’re strings, I can’t attach metadata to them. Is there some metadata-capable container that I can put them in which will display as strings in portal?

djblue 2023-10-13T15:37:27.506199Z

I think you might be looking for this guide https://cljdoc.org/d/djblue/portal/0.48.0/doc/guides/default-viewer. I'm planning on releasing an updated version of the https://github.com/djblue/portal/blob/master/src/portal/viewer.cljc#L14-L26 ns which contains this pattern so you don't have to think about it.

markaddleman 2023-10-13T15:38:13.838039Z

Yeah, I saw this but it seemed like just a bit more work than I was wiling to put in just to save a few mouse clicks.

markaddleman 2023-10-13T15:38:24.600179Z

I shouldn’t be this lazy 🙂 Thanks!

djblue 2023-10-13T15:39:40.190169Z

What do you feel would be an easier approach?

markaddleman 2023-10-13T15:41:05.690149Z

Something like this:

(portal.console/debug ^:portal.viewer/code (portal.console/metadata-container "my code string")

djblue 2023-10-13T15:43:39.034769Z

That might cause issues with the current semantics of the viewer key which is to pass options to the viewer. For example:

{:portal.viewer/default :portal.viewer/table
 :portal.viewer/table {:columns [:a :b :c]}}

markaddleman 2023-10-13T15:59:09.313059Z

Sorry, my example was bad. It should have been :

(portal.console/debug ^{:portal.viewer/default :portal.viewer/code} (portal.console/metadata-container "my code string")

markaddleman 2023-10-13T16:00:06.627679Z

As you can see (I hope), I’m just looking for a container to which I can attach metadata. I’d like the portal viewer to visualize the value within the container

👍 1
seancorfield 2023-10-13T17:09:16.424349Z

Could you put your strings in vectors and attach metadata to that? (I don't know what the code viewer would do with that tho')

markaddleman 2023-10-13T18:04:27.011639Z

ah! that does it

markaddleman 2023-10-13T18:05:02.106119Z

disregard - I got a little too excited

markaddleman 2023-10-13T18:05:19.956269Z

Portal does not display the string in code format

markaddleman 2023-10-13T18:07:18.466279Z

But it occurs to me I could stuff the string into some hiccup and put the metadata on the hiccup vector.

markaddleman 2023-10-13T18:49:48.575649Z

fwiw, my specific use case is generating SQL strings from honey, prettifying them using a formatter, looking at them in portal and copy & pasting the string into my sql editor

markaddleman 2023-10-13T18:50:14.934969Z

It’s a very nice workflow, although I wish I had a way of sending them directly to my sql editor (this has nothing to do with portal, however)