Issue with .js paths

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue with .js paths

Spyryto
Hello.

I'm rewriting all of a website's JS code in Amber. I managed to load the home page without errors, everything works smoothly.
The problem is with the other pages.

While the home page can be accessed at the domain's root folder ( / ), the other pages have URLs like these:
  • /team/
  • /about/
  • /case-study/
  • ...

The original JS website is in pre-production here, though I don't think you're gonna make use of this. However, you can see how part of the JS is used when vertically resizing the window. I hoped of developing the remaining functionality (swipe responsivity and so on using Amber).

What happens is the proper JS files can't be loaded, the first one being /devel.js. When loading the /team/ page, the requested path (analyzed via Firebug) is /team/devel.js. That is, it seems that the app tries to load devel.js (and every other Amber JS file in the root folder) by providing a path relative to the current folder, instead of a path relative to the root folder ( I mean: ./devel.js instead of /devel.js).

I thought I could get around to it, so I remapped every request to a non-existent js file to the provided path without the first piece/.

The loaded code is correct, all 42 requested JS files (IDE.js, etc.) get loaded, but now I get another error:

Error: Load timeout for modules: codemirror/lib/codemirror,require-css/css!amber-attic/resources/amber_unnormalized2,etc.

I'm not gonna fix it, because who gonna know what there is next?

Too bad I'm not familiar at all with a tool like bower, if that's the culprit.

Do you have any advice? If I can't fix it by today, I'm gonna go back to the original JS version (and I like Amber way better). Any help appreciated.


I'm gonna take this opportunity to thank Sebastian Sastre, Nicolas Petton, Matthias Springer, Herby and everybody who is contributing to Amber and Smalltalk projects for the great job.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with .js paths

Herby Vojčík
In pages that are in deeper levels, you must include

  require.config({baseUrl: '../..'}); // this sample 2lvl deep

before the require(['app'], ...) call. Otherwise, everything is the same (of course, loading the.js needs ../../the.js instead, but that you already did, I presume).

Herby

Spyryto wrote:

> Hello.
>
> I'm rewriting all of a website's JS code in Amber. I managed to load
> the home page without errors, everything works smoothly.
> The problem is with the other pages.
>
> While the home page can be accessed at the domain's root folder ( / ),
> the other pages have URLs like these:
>
>   * /team/
>   * /about/
>   * /case-study/
>   * ...
>
> The original JS website isin pre-production here
> <http://davidmonetti.davidmonetti.com/>, though I don't think you're
> gonna make use of this. However, you can see how part of the JS is
> used when vertically resizing the window. I hoped of developing the
> remaining functionality (swipe responsivity and so on using
 Amber).

>
> What happens is the proper JS files can't be loaded, the first one
> being /devel.js. When loading the /team/ page, the requested path
> (analyzed via Firebug) is /team/devel.js. That is, it seems that the
> app tries to load devel.js (and every other Amber JS file in the root
> folder) by providing a path relative to the current folder, instead of
> a path relative to the root folder ( I mean: ./devel.js instead of
> /devel.js).
>
> I thought I could get around to it, so I remapped every request to a
> non-existent js file to the provided path without the first piece/.
>
> The loaded code is correct, all 42 requested JS files (IDE.js, etc.)
> get loaded, but now I get another error:
>
> Error: Load timeout for modules:
> codemirror/lib/codemirror,require-css/css!amber-attic/resources/amber_unnormalized2,etc.
>
> I'm not gonna fix it, because who gonna know what there is next?
>
> Too bad I'm not familiar at all with a tool like bower, if that's the
> c
ulprit.

>
> Do you have any advice? If I can't fix it by today, I'm gonna go back
> to the original JS version (and I like Amber way better). Any help
> appreciated.
>
>
> I'm gonna take this opportunity to thank Sebastian Sastre, Nicolas
> Petton, Matthias Springer, Herby and everybody who is contributing to
> Amber and Smalltalk projects for the great job.
>
> --
> You received this message because you are subscribed to the Google
> Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [hidden email]
> <mailto:[hidden email]>.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with .js paths

Spyryto
Thanks, Herby.

of course, loading the.js needs ../../the.js instead, but that you already did, I presume).

I used an absolute path:

<script src='/the.js'></script>

In pages that are in deeper levels, you must include

 
require.config({baseUrl: '../..'}); // this sample 2lvl deep

before the require(['app'], ...) call.
 
I see, but the pages are not really deeper, that's just a pretty URL. The underlying PHP gets the /page-name/ as a GET parameter, it's really /router.php?url=page-name/

However, I just used

require.config({baseUrl: '/'});

and it worked! Now I can go on with Smalltalk! It is so fun!

Thank you so much!

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with .js paths

Herby Vojčík


Spyryto wrote:
> Thanks, Herby.
>
>     of course, loading the.js needs ../../the.js instead, but that you
>     already did, I presume).
>
>
> I used an absolute path:

That's wrong for some many reasons.

You've been warned.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.