#1959 FWT Images in JS

SlimerDude Wed 18 Jul 2012

Just a quick question...

In my JS app, where do the FWT Images come from / get served from?

Steve.

andy Wed 18 Jul 2012

You are responsible for serving those up from the server. See js examples: /doc/examples/js-demo.html

SlimerDude Thu 19 Jul 2012

My question is because the following:

fwt::Image.make(`fan://mypod/res/images/explosion.png`)

just works!

I'm not serving up anything in particular, just the pod files. I'm not seeing any image data in the compiled .js data, so I'm wondering where the image comes from!??

andy Thu 19 Jul 2012

If you implemented like the example - you are serving them in this method:

Void onPodFile()
{
  // serve up pod resources
  File file := ("fan://" + req.uri[1..-1]).toUri.get
  if (!file.exists) { res.sendErr(404); return }
  FileWeblet(file).onService
}

The JavaScript runtime internally handles mapping that to a proper URI - which by default is: fan://xxx -> /pod/xxx. To change the URI used - specify an env var in your jsMain:

jsMain(out, "myPod::MyClass", ["sys.uriPodBase":"/some/other/base/"])

SlimerDude Thu 19 Jul 2012

Cool, that explains it.

Cheers.

Login or Signup to reply.