clerk

Nick McAvoy 2024-11-19T01:14:23.500489Z

Hi there 👋 ; first time with Clerk here. I'm trying a variation on the https://book.clerk.vision/#vega-lite. I am trying to use a local csv file for the secondary data source in the example. I found mention of Clerk serving local files https://clojurians.slack.com/archives/C035GRLJEP8/p1696673633562989?thread_ts=1696669747.621369&cid=C035GRLJEP8 and https://github.com/nextjournal/clerk/blob/d9cab25aae62029557cff3346e7bd06e878999cd/src/nextjournal/clerk/webserver.clj#L338, but I'm having trouble getting that to work. My clerk notebook is being served from notebooks/sunrise_us.clj. I've got the file in _fs/data/sunrise-times.csv. But when I navigate to localhost:7777/data/sunrise-times.csv, I get a 404, and I don't see it listed in Clerk home. What am I missing? Thanks.

borkdude 2024-11-19T08:42:22.670709Z

How I understand when I read this: The file should be in data/sunrise.csv in your project, but the url in your browser should be /_fs/data/sunrise.csv

💡 1
Nick McAvoy 2024-11-19T13:55:30.672939Z

Of course! I’ll try this shortly, but that definitely looks right.

Nick McAvoy 2024-11-19T18:14:14.536309Z

Still a work in progress, but I'm really enjoying this! Thanks for the help.

🎉 1
Nick McAvoy 2024-11-19T18:25:21.403149Z

I don't see the file serving behavior documented in the Book of Clerk; I'd be happy to submit a PR if you think that'd be helpful.

👍 1
henrik42 2024-11-19T16:21:59.134869Z

Hey 👋 Clerk newbie here. I'd like to make my Clerk notebook a little more interactive by using (sci/react?) input elements and either call server-side functions via the Clerk web-socket and/or set! refs in sci and have them sync'ed to the server. I've searched through the Clerk source but I'm pretty much lost. Any pointers/ideas?

teodorlu 2024-11-19T17:57:03.291379Z

Have you seen the book section on how to write your own viewers? https://book.clerk.vision/#render

henrik42 2024-11-19T18:11:27.987439Z

Ah yes - didn't get that. That lets me create input things and refs. 👍 But how can I communicate back to the server?

teodorlu 2024-11-19T18:42:37.261999Z

I think the idea is to create a "synced atom". https://book.clerk.vision/#clerk-sync

henrik42 2024-11-19T20:02:22.384199Z

I understood synced atoms as being synced from the server to the client. I want the orher way. But will try. Thank you.

borkdude 2024-11-19T20:02:56.230599Z

they sync both ways

henrik42 2024-11-19T20:04:35.966539Z

Perfect 🎉 🚀 !!

henrik42 2024-11-19T20:06:42.618709Z

@borkdude and any chance to call server-side functions from the client/sci through the clerk web-socket?

borkdude 2024-11-19T20:10:56.406209Z

I don't think #clerk has this feature yet. Perhaps @mkvlr has thoughts about it

mkvlr 2024-11-19T20:17:45.038199Z

@henrikheine yes, you can call (nextjournal.clerk.render/clerk-eval expression-to-eval) to eval things on the JVM, returns a promise with the result

🎉 2
henrik42 2024-11-19T21:06:18.083969Z

Excelent! Clerk & sci are awsome!!

🖤 2