JuliaGizmos / Escher.jl

Composable Web UIs in Julia
https://juliagizmos.github.io/Escher.jl
Other
335 stars 63 forks source link

Add access to julia file (work) directory #83

Closed pabloferz closed 8 years ago

pabloferz commented 8 years ago

Fixes https://github.com/shashi/Escher.jl/issues/81

This moves the access to the Escher/assets directory from assets to escher/assets and adds access to the user working path (from where the julia files are loaded) under the assets name.

Now you can load images directly from the directory of your julia file without the need of the Images package, which makes specially easy to load svg files.

For example, if you have a file image.svg in the same path of your escher/julia file, you can load the image as image("assets/image.svg").

shashi commented 8 years ago

I'm wondering why Escher needs to be a special case at all.

pkg/Escher/* sounds OK to me. @mdcfrancis

mdcfrancis commented 8 years ago

@shashi I'm inclined to agree with you - so /assets could be re-purposed for assets relative to the page definition and everything else is explicit based on package.

pabloferz commented 8 years ago

I like that idea as it simplify things.

I made the appropriate changes. Does this look better now?

pabloferz commented 8 years ago

Ok, I think I have to modify escher_make from /src/cli/compile.jl and probably update some of the documentation. Would that be all this is missing?

shashi commented 8 years ago

Yeah, I think that's it. Could you rebase and squash commits?

I'm going to do it in a few hours anyway if no updates here. Thanks for the PR!

pabloferz commented 8 years ago

No problem! I'm happy to help.

neilpanchal commented 8 years ago

Hi all,

I think I still have a problem loading a sample.png file from where my index.jl is.

I've tried the following:

I first launch julia in REPL (cmd windows) and type in the following commands to launch the web server in the directory I want.

using Escher
include(Pkg.dir("Escher", "src", "cli", "serve.jl"))
cd(Pkg.dir("Escher", pwd()))
escher_serve()

Say, my pwd() is located at C:\escher_test

In C:\escher_test, I have an index.jl file which runs when I type in the browser http://localhost:5555

From this index.jl file, I'd like to load an image located at C:\escher_test\sample.png. I've tried using image("assets/sample.png") with no luck.

I have also tried the following methods: image("file:///C:/escher_test/sample.png") image("/escher_test/sample.png") image("C:\\escher_test\sample.png")

Furthermore, checking the Chrome inspection console, the img tag has a src="http://localhost:5555/assets/sample.png"

Where is the localhost running on my disk?

Any help appreciated!

rohitvarkey commented 8 years ago

Just putting it in an assets folder (C:\escher_test\assets in your case) and then using image("assets/sample.png") should work.

neilpanchal commented 8 years ago

@rohitvarkey That worked, Rohit. Thank you. 👍