Ford Fusion rune updates

24 views
Skip to first unread message

Jon Shapiro

unread,
Dec 13, 2020, 1:44:10 PM12/13/20
to urbit-dev
Hey there,

I'm updating an app that was made pre Ford Fusion and wondering what would be the equivalent way of importing all filetypes from a directory. For example:

/= rote-png
/^ (map knot @)
/: /===/app/rote/img /_ /png/

Is this something that Ford Fusion addresses or are we expected to enumerate each import now?

Thanks so much!

Ted Blackman

unread,
Dec 13, 2020, 10:16:13 PM12/13/20
to Jon Shapiro, urbit-dev
For now, you have to import each file individually using the /* rune. It shouldn't be infeasible to add a directory-import rune, though, so if this is a common need, then we should probably add one.


~rovnys-ricfer

Christian Crawford

unread,
Dec 13, 2020, 10:33:09 PM12/13/20
to Ted Blackman, Jon Shapiro, urbit-dev
I'm wondering if this isn't done differently with SPA landscape? isn't file-server used now?

--
To unsubscribe from this group and stop receiving emails from it, send an email to dev+uns...@urbit.org.

Mark

unread,
Dec 15, 2020, 4:27:38 PM12/15/20
to Christian Crawford, Ted Blackman, Jon Shapiro, urbit-dev
Christian is right, landscape uses /app/file-server for most of its file-serving needs these days. Assuming you're trying to serve some content over HTTP, you will probably want to do something similar. Most relevant is this bit:

https://github.com/urbit/urbit/blob/6499eb5fe0bd81c91f12d6f9ebcc6843b2ca7ac7/pkg/arvo/app/file-server.hoon#L209-L229

Instead of compiling the data we serve into the app, it is more common nowadays to scry (using .^) the data out of clay when you need it. Note how, on line 215, we first check if the file we were asked to serve exists. Then, on line 216, we actually get its contents.
(We get its contents from the scry as an atom. If the kind of file (ie, the mark) that you're scrying for contains data of some other shape, you'll want to adjust accordingly.)
Then, starting on line 218, we wrap the content we got into an actual http response.

To answer your original question, note that because we try to serve the files _on demand_, there's no need to find all files in the directory ahead of time.


~palfun-foslup
https://urbit.org

Jon Shapiro

unread,
Dec 16, 2020, 1:23:14 AM12/16/20
to Mark, Christian Crawford, Ted Blackman, urbit-dev
Thanks!

After digging in a little more (still really new here) I realize that the code I'm updating was from the standard create-landscape-app.

If I understand what you're saying, I'll want to remove the ford runes and replace the lines that match assets to the ford imports in `++  poke-handle-http-request` similar to what chat-view and contact-view do in their `++ on-load` arm?

Mark

unread,
Dec 16, 2020, 8:30:57 AM12/16/20
to Jon Shapiro, Christian Crawford, Ted Blackman, urbit-dev
That's probably the easiest way to just serve some files, yes.

https://github.com/urbit/urbit/blob/6499eb5fe0bd81c91f12d6f9ebcc6843b2ca7ac7/pkg/arvo/app/contact-view.hoon#L48-L51
https://github.com/urbit/urbit/blob/6499eb5fe0bd81c91f12d6f9ebcc6843b2ca7ac7/pkg/arvo/sur/file-server.hoon#L4

This says to poke the file-server app, with an action that specifies you want to serve a directory. HTTP requests coming in on /~groups will be served from files in the /app/landscape directory in clay. There's also flags for saying whether you need to be logged in to view the file, and whether or not to serve index.html in place of 404s.


~palfun-foslup
https://urbit.org
Reply all
Reply to author
Forward
0 new messages