Fork me on GitHub
#yada
<
2016-01-22
>
jethroksy05:01:08

is there a sample yada project out there that serves up static files?

jethroksy05:01:11

I'm kinda stumped

jethroksy05:01:44

oops I could do it with ->ResourcesMaybe in bidi

malcolmsparks09:01:01

if you have a directory of files called 'dir', you can serve them with (yada dir)

malcolmsparks09:01:09

not sure it can be much simpler simple_smile

malcolmsparks09:01:27

there are various options you can give to static directory serving, see here: https://github.com/juxt/yada/blob/master/dev/src/yada/dev/talks.clj

jethroksy09:01:30

Is this documented somewhere

malcolmsparks09:01:58

but it may be out-of-date

malcolmsparks09:01:08

documentation is coming though, I am doing quite a lot of documenting these days

malcolmsparks09:01:15

the user-manual is growing simple_smile

jethroksy09:01:40

That link says coming soon

malcolmsparks09:01:57

scroll down a bit

malcolmsparks09:01:07

but the talks example is the most up to date and you can run it

malcolmsparks09:01:34

whereby .md files are automatically run through a markdown preprocessor

malcolmsparks09:01:40

but other files are statically served

jethroksy09:01:46

Ah okay I see it

malcolmsparks09:01:16

using yada to serve these is far superior to bidi's ResourcesMaybe because you get all the caching and conditional request semantics, etc.

malcolmsparks09:01:22

+ security and so on

jethroksy09:01:43

Really cool stuff going on but its quite a departure from the usual compojure ring stack

malcolmsparks09:01:46

until yada 1.1 is officially released, you'll have to dig into the code examples a little bit

malcolmsparks09:01:12

yes, it's a big departure - partly because the compojure ring stack can't do async (see how pedestal had to depart from ring too)

jethroksy09:01:14

My migration path was kinda hard

malcolmsparks09:01:39

but you can mix-and-match - some resources you can keep as compojure, others you might serve with bidi/yada

jethroksy09:01:41

I happened to be using aleph as a WS client so everything fit perfectly

jethroksy09:01:36

I'll dig around

malcolmsparks09:01:05

sorry that example is a bit out of date but the point is you can return the promise that aleph client returns to you

malcolmsparks09:01:17

it all just works, asynchronously

malcolmsparks09:01:21

or should 😉

jethroksy09:01:28

I am not unfortunately

jethroksy09:01:35

But my connection is a record

jethroksy09:01:47

The only protocols I extended were Components

jethroksy09:01:05

I could probably try this and upload it as an example

jethroksy09:01:40

Oh do SSEs support streams?

jethroksy09:01:53

I've seen examples, but only with chan

malcolmsparks11:01:13

what kind of stream are you looking to support?

malcolmsparks11:01:41

you can support any stream that can be converted to a manifold source, so it should be easy

malcolmsparks11:01:56

if yada doesn't support the exact type of stream you need, extend the yada.body.MessageBody protocol with your own implementation - you can see how the core.async channel is implemented and derive it from that

malcolmsparks11:01:08

but if you tell me what kind of stream you need I'm happy to put it into the next release

malcolmsparks11:01:19

@jethroksy: thanks for your points about the docs, it's on my list to look into to

malcolmsparks11:01:28

just a bit busy with client work today

jethroksy11:01:37

Just the raw manifold stream

jethroksy11:01:59

It's just a question, have yet to try it

jethroksy11:01:04

And you're welcome (: