fine control of amber load

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

fine control of amber load

sebastianconcept
Hi guys,

to load my amber apps in dev I usually do something like:

<script type="text/javascript">
amber.load({
files: [
'service/static/lib/app/js/WhateverApp.js'],
prefix: '',
ready: function() {smalltalk.Browser._open()}});
</script>

while inspecting network requests I what I see about the files requested there is something with numbers.

Here is an example:
http://localhost:8080/dealer/static/lib/amber/js/Kernel-Tests.js?_=1363559977599

What is that parameter?

What was the intention of using it?

Any way of NOT using it?

thanks

sebastian

--
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/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: fine control of amber load

Herby Vojčík


Sebastian Sastre wrote:

> Hi guys,
>
> to load my amber apps in dev I usually do something like:
>
> <script type="text/javascript">
> amber.load({
> files: [
> 'service/static/lib/app/js/WhateverApp.js'],
> prefix: '',
> ready: function() {smalltalk.Browser._open()}});
> </script>

The semantics of loader has changed a bit, so I would presume this won't
work anymore (it adds one more 'js' into the path).

If all your code is in service/static/lib/app/{js,st}, I would advice to use
   packages: [ 'WhateverApp' ],
   packageHome: 'service/static/lib/app/'

> while inspecting network requests I what I see about the files requested
> there is something with numbers.
>
> Here is an example:
> http://localhost:8080/dealer/static/lib/amber/js/Kernel-Tests.js?_=1363559977599
>
> What is that parameter?

Timestamp.

> What was the intention of using it?

To stop caching. So you always have actual code.

> Any way of NOT using it?

deploy:true

> thanks
>
> sebastian

Herby

--
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/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: fine control of amber load

sebastianconcept
hey Herby

I've figured that out recently (and undo the additional js with a ../)

what you say works if you have all your app code in that path

but what if you use another piece of amber based software that is not your app but your app uses as foundation? (a framework on top of amber)

For me it's working by now but I still wish I can disable the feature of that parameter

sebastian

o/

On 18/03/2013, at 08:19, Herby Vojčík <[hidden email]> wrote:

>
>
> Sebastian Sastre wrote:
>> Hi guys,
>>
>> to load my amber apps in dev I usually do something like:
>>
>> <script type="text/javascript">
>> amber.load({
>> files: [
>> 'service/static/lib/app/js/WhateverApp.js'],
>> prefix: '',
>> ready: function() {smalltalk.Browser._open()}});
>> </script>
>
> The semantics of loader has changed a bit, so I would presume this won't work anymore (it adds one more 'js' into the path).
>
> If all your code is in service/static/lib/app/{js,st}, I would advice to use
>  packages: [ 'WhateverApp' ],
>  packageHome: 'service/static/lib/app/'
>
>> while inspecting network requests I what I see about the files requested
>> there is something with numbers.
>>
>> Here is an example:
>> http://localhost:8080/dealer/static/lib/amber/js/Kernel-Tests.js?_=1363559977599
>>
>> What is that parameter?
>
> Timestamp.
>
>> What was the intention of using it?
>
> To stop caching. So you always have actual code.
>
>> Any way of NOT using it?
>
> deploy:true
>
>> thanks
>>
>> sebastian
>
> Herby
>
> --
> 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/groups/opt_out.
>
>

--
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/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: fine control of amber load

Herby Vojčík


sebastian wrote:
> hey Herby

Hi!

> I've figured that out recently (and undo the additional js with a
> ../)

Simply do not put it there at all, why have 'js/../' at the end when
'js' is added automatically (in fact, prefix is added, but empty prefix
menas default 'js')?

> what you say works if you have all your app code in that path
>
> but what if you use another piece of amber based software that is not
> your app but your app uses as foundation? (a framework on top of
> amber)

As things stand now (loader will be changed, see wiki page "On Loader
2"), packageHome is place where your code which you develop stays (that
is, if you commit, it is saved there) and also you do not need to
specify path.

For other dependencies, you can simply use paths in packages, like:

   packages: [
     'MyClient', 'MyModel', // load from packageHome
     'http://foo.com/amber/Lib1', // http://foo.com/amber/js/Lib1.js
     '/local/Lib2', // /local/js/Lib2.js at the server of the page
     'sub/Lib3', // <packageHome>/sub/js/Lib3.js
   ]

What's <del>silly</del>uncovenient with existing loader is, you must
always have the same prefix (by default, js). Now that I think about it,
it should be hackable by `prefix: '.'`. In that case, you would always
specify the full path inside packages and packageHome. But if all your
.js files are under `js/` folder, rather use the default.

> For me it's working by now but I still wish I can disable the feature
> of that parameter

Which one? I have replied to you that it is switched off by deploy:true.

> sebastian

Herby

--
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/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: fine control of amber load

sebastianconcept
for the record, this is my structure pattern:

/rootAppDir
/rootAppDir/worker0  <- here is the pharo dev image
/rootAppDir/service/  <- this has the URI / and have files like index.html,  favicon etc
/rootAppDir/service/static/css
/rootAppDir/service/static/css/img
/rootAppDir/service/static/css/lib

/rootAppDir/service/static/css/lib/amber
/rootAppDir/service/static/css/lib/amber/js
/rootAppDir/service/static/css/lib/amber/st
/rootAppDir/service/static/css/lib/amber/... and all the other subdirs of amber

/rootAppDir/service/static/css/lib/bootstrap (with all the subdirs of it)

/rootAppDir/service/static/css/lib/app
/rootAppDir/service/static/css/lib/app/js
/rootAppDir/service/static/css/lib/app/st

so far so good, now.. here is the 2 frameworks that run on top of amber and that are requisites of the app I need

/rootAppDir/service/static/css/lib/framework1
/rootAppDir/service/static/css/lib/ramework1/js
/rootAppDir/service/static/css/lib/ramework1/st

/rootAppDir/service/static/css/lib/framework2
/rootAppDir/service/static/css/lib/ramework2/js
/rootAppDir/service/static/css/lib/ramework2/st

in the dev.html file I'm loading like this, and as hackish as it looks, it works:

 <script type="text/javascript">
amber.load({
files: [
'../../../../../service/static/lib/framework1/js/../framework1.js',
'../../../../../service/static/lib/app/js/../App.js'],
prefix: '',
ready: function() {smalltalk.Browser._open()}});
 </script>

if you have a suggestion to do it better it would be nice to hear it


PD:
I've tried setting '../../../../../service/static/lib/' as prefix because is the common root for all amber software (frameworks + app) but the requests where weird and I've ended up the way I've described here










On Mar 18, 2013, at 8:59 AM, Herby Vojčík wrote:



sebastian wrote:
hey Herby

Hi!

I've figured that out recently (and undo the additional js with a
../)

Simply do not put it there at all, why have 'js/../' at the end when
'js' is added automatically (in fact, prefix is added, but empty prefix
menas default 'js')?

what you say works if you have all your app code in that path

but what if you use another piece of amber based software that is not
your app but your app uses as foundation? (a framework on top of
amber)

As things stand now (loader will be changed, see wiki page "On Loader 2"), packageHome is place where your code which you develop stays (that is, if you commit, it is saved there) and also you do not need to specify path.

For other dependencies, you can simply use paths in packages, like:

 packages: [
   'MyClient', 'MyModel', // load from packageHome
   'http://foo.com/amber/Lib1', // http://foo.com/amber/js/Lib1.js
   '/local/Lib2', // /local/js/Lib2.js at the server of the page
   'sub/Lib3', // <packageHome>/sub/js/Lib3.js
 ]

What's <del>silly</del>uncovenient with existing loader is, you must always have the same prefix (by default, js). Now that I think about it, it should be hackable by `prefix: '.'`. In that case, you would always specify the full path inside packages and packageHome. But if all your .js files are under `js/` folder, rather use the default.

For me it's working by now but I still wish I can disable the feature
of that parameter

Which one? I have replied to you that it is switched off by deploy:true.

sebastian

Herby

--
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/groups/opt_out.



--
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/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: fine control of amber load

Herby Vojčík


sebastian wrote:

> for the record, this is my structure pattern:
>
> /rootAppDir
> /rootAppDir/worker0 <- here is the pharo dev image
> /rootAppDir/service/ <- this has the URI / and have files like
> index.html, favicon etc
> /rootAppDir/service/static/css
> /rootAppDir/service/static/css/img
> /rootAppDir/service/static/css/lib
>
> /rootAppDir/service/static/css/lib/amber
> /rootAppDir/service/static/css/lib/amber/js
> /rootAppDir/service/static/css/lib/amber/st
> /rootAppDir/service/static/css/lib/amber/... and all the other subdirs
> of amber
>
> /rootAppDir/service/static/css/lib/bootstrap (with all the subdirs of it)
>
> /rootAppDir/service/static/css/lib/app
> /rootAppDir/service/static/css/lib/app/js
> /rootAppDir/service/static/css/lib/app/st
>
> so far so good, now.. here is the 2 frameworks that run on top of amber
> and that are requisites of the app I need
>
> /rootAppDir/service/static/css/lib/framework1
> /rootAppDir/service/static/css/lib/ramework1/js
> /rootAppDir/service/static/css/lib/ramework1/st
>
> /rootAppDir/service/static/css/lib/framework2
> /rootAppDir/service/static/css/lib/ramework2/js
> /rootAppDir/service/static/css/lib/ramework2/st
>
> in the dev.html file I'm loading like this, and as hackish as it looks,
> it works:
>
> <script type="text/javascript">
> amber.load({
> files: [
> '../../../../../service/static/lib/framework1/js/../framework1.js',
> '../../../../../service/static/lib/app/js/../App.js'],
> prefix: '',
> ready: function() {smalltalk.Browser._open()}});
> </script>

Oh, that's too complicated!

> if you have a suggestion to do it better it would be nice to hear it


If really URI / is mapped to /rootAppDir/service, then of course this:

   packageHome: '/static/css/lib/app/',
   packages: ['/static/lib/framework1/Framework1', 'App' ],
   ready: function() {...}

   // NO files, NO prefix!

Alternatively, if you really like '..'s so much / want to be relative
for sake of better relocating, you could possibly use

   packages: [ '../framework1/Framework1', 'App' ],

in the above as well.

FYI, you can have amber and/or dependent libraries deployed in different
domain, if it suits you better (I use different domain
assets.mydomain.com to put such files there, and it works fine, I just
include
   '//assets.mydomain.com/path/without/js/Package-Name',
items in packages and it gets finely loaded ('//...' is normal url that
reuses http/https, you can include urls with specific protocol too, of
course). I load amber from assets server as well.

> sebastian <https://about.me/sebastianconcept>

Herby

P.S.: I would advise not to put lib under css ;-)

P.P.S.: If it is for deployment only (you will not need commit), you can
also do:

   packageHome: '/static/css/lib/',
   packages: [ 'framework1/Framework1', 'app/App' ],
   ready: function () { ... }

--
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/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: fine control of amber load

Doug Stewart
I'm a bit late to this party but judging how long it took me to find this answer, my example, based on Herby's solution, may prove useful to someone:

<!DOCTYPE html>
<html>
  <head>
    <title>My First Amber Project</title>
    <script src="../../js/amber.js" type="text/javascript"></script>
    <script type="text/javascript">
      loadAmber({
        packageHome: '/projects/',
        packages: ['counter/CounterApp', 'helloWorld/HelloWorldApp'],
        ready: function() {
          $(function() {
            smalltalk.HelloWorld._new()._begin();
          });
        }});     
    </script>
  </head>
  <body>
    <article>
      <h1>My First Amber Project</h1>
      <button onclick="smalltalk.Browser._open()">class browser</button>
      <button id="sayHello">say hello</button>
      <button onclick="smalltalk.TCounter._new()._runCounter()">run counter</button>
    </article>
  </body>
</html>

On Monday, March 18, 2013 9:36:20 AM UTC-5, Herby wrote:


sebastian wrote:

> for the record, this is my structure pattern:
>
> /rootAppDir
> /rootAppDir/worker0 <- here is the pharo dev image
> /rootAppDir/service/ <- this has the URI / and have files like
> index.html, favicon etc
> /rootAppDir/service/static/css
> /rootAppDir/service/static/css/img
> /rootAppDir/service/static/css/lib
>
> /rootAppDir/service/static/css/lib/amber
> /rootAppDir/service/static/css/lib/amber/js
> /rootAppDir/service/static/css/lib/amber/st
> /rootAppDir/service/static/css/lib/amber/... and all the other subdirs
> of amber
>
> /rootAppDir/service/static/css/lib/bootstrap (with all the subdirs of it)
>
> /rootAppDir/service/static/css/lib/app
> /rootAppDir/service/static/css/lib/app/js
> /rootAppDir/service/static/css/lib/app/st
>
> so far so good, now.. here is the 2 frameworks that run on top of amber
> and that are requisites of the app I need
>
> /rootAppDir/service/static/css/lib/framework1
> /rootAppDir/service/static/css/lib/ramework1/js
> /rootAppDir/service/static/css/lib/ramework1/st
>
> /rootAppDir/service/static/css/lib/framework2
> /rootAppDir/service/static/css/lib/ramework2/js
> /rootAppDir/service/static/css/lib/ramework2/st
>
> in the dev.html file I'm loading like this, and as hackish as it looks,
> it works:
>
> <script type="text/javascript">
> amber.load({
> files: [
> '../../../../../service/static/lib/framework1/js/../framework1.js',
> '../../../../../service/static/lib/app/js/../App.js'],
> prefix: '',
> ready: function() {smalltalk.Browser._open()}});
> </script>

Oh, that's too complicated!

> if you have a suggestion to do it better it would be nice to hear it


If really URI / is mapped to /rootAppDir/service, then of course this:

   packageHome: '/static/css/lib/app/',
   packages: ['/static/lib/framework1/Framework1', 'App' ],
   ready: function() {...}

   // NO files, NO prefix!

Alternatively, if you really like '..'s so much / want to be relative
for sake of better relocating, you could possibly use

   packages: [ '../framework1/Framework1', 'App' ],

in the above as well.

FYI, you can have amber and/or dependent libraries deployed in different
domain, if it suits you better (I use different domain
assets.mydomain.com to put such files there, and it works fine, I just
include
   '//assets.mydomain.com/path/without/js/Package-Name',
items in packages and it gets finely loaded ('//...' is normal url that
reuses http/https, you can include urls with specific protocol too, of
course). I load amber from assets server as well.

> sebastian <https://about.me/sebastianconcept>

Herby

P.S.: I would advise not to put lib under css ;-)

P.P.S.: If it is for deployment only (you will not need commit), you can
also do:

   packageHome: '/static/css/lib/',
   packages: [ 'framework1/Framework1', 'app/App' ],
   ready: function () { ... }

--
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/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: fine control of amber load

Doug Stewart
Well, there is a limitation and a correction to what I first posted.

Desire: projects : common directory for all projects
helloWorld - directory where my HelloWorldApp should live
counter - directory where my CounterApp should live

Whatever packageHome is set to, is where a "commit" looks for a js subdirectory to save files to. It doesn't get that there are two separate packages with two independent homes.

If I set packageHome to "/projects/" then amber expects there to be a js directory there and that is where all my commits will save.
If I set packageHome to "/projects/counter/" then amber expects there to be a js directory there and that is where all my commit will save.

How does one load two separate projects on one web page while configuring each to commit to their own separate locations?
I've tried many permutations of packageHome & packages or prefix & files, with and without beginning and trailing slashes.

I suppose I'll need to hack amber.js to get what I'm after here.

On Friday, May 17, 2013 5:03:20 PM UTC-5, Doug Stewart wrote:
I'm a bit late to this party but judging how long it took me to find this answer, my example, based on Herby's solution, may prove useful to someone:

<!DOCTYPE html>
<html>
  <head>
    <title>My First Amber Project</title>
    <script src="../../js/amber.js" type="text/javascript"></script>
    <script type="text/javascript">
      loadAmber({
        packageHome: '/projects/',
        packages: ['counter/CounterApp', 'helloWorld/HelloWorldApp'],
        ready: function() {
          $(function() {
            smalltalk.HelloWorld._new()._begin();
          });
        }});     
    </script>
  </head>
  <body>
    <article>
      <h1>My First Amber Project</h1>
      <button onclick="smalltalk.Browser._open()">class browser</button>
      <button id="sayHello">say hello</button>
      <button onclick="smalltalk.TCounter._new()._runCounter()">run counter</button>
    </article>
  </body>
</html>

On Monday, March 18, 2013 9:36:20 AM UTC-5, Herby wrote:


sebastian wrote:

> for the record, this is my structure pattern:
>
> /rootAppDir
> /rootAppDir/worker0 <- here is the pharo dev image
> /rootAppDir/service/ <- this has the URI / and have files like
> index.html, favicon etc
> /rootAppDir/service/static/css
> /rootAppDir/service/static/css/img
> /rootAppDir/service/static/css/lib
>
> /rootAppDir/service/static/css/lib/amber
> /rootAppDir/service/static/css/lib/amber/js
> /rootAppDir/service/static/css/lib/amber/st
> /rootAppDir/service/static/css/lib/amber/... and all the other subdirs
> of amber
>
> /rootAppDir/service/static/css/lib/bootstrap (with all the subdirs of it)
>
> /rootAppDir/service/static/css/lib/app
> /rootAppDir/service/static/css/lib/app/js
> /rootAppDir/service/static/css/lib/app/st
>
> so far so good, now.. here is the 2 frameworks that run on top of amber
> and that are requisites of the app I need
>
> /rootAppDir/service/static/css/lib/framework1
> /rootAppDir/service/static/css/lib/ramework1/js
> /rootAppDir/service/static/css/lib/ramework1/st
>
> /rootAppDir/service/static/css/lib/framework2
> /rootAppDir/service/static/css/lib/ramework2/js
> /rootAppDir/service/static/css/lib/ramework2/st
>
> in the dev.html file I'm loading like this, and as hackish as it looks,
> it works:
>
> <script type="text/javascript">
> amber.load({
> files: [
> '../../../../../service/static/lib/framework1/js/../framework1.js',
> '../../../../../service/static/lib/app/js/../App.js'],
> prefix: '',
> ready: function() {smalltalk.Browser._open()}});
> </script>

Oh, that's too complicated!

> if you have a suggestion to do it better it would be nice to hear it


If really URI / is mapped to /rootAppDir/service, then of course this:

   packageHome: '/static/css/lib/app/',
   packages: ['/static/lib/framework1/Framework1', 'App' ],
   ready: function() {...}

   // NO files, NO prefix!

Alternatively, if you really like '..'s so much / want to be relative
for sake of better relocating, you could possibly use

   packages: [ '../framework1/Framework1', 'App' ],

in the above as well.

FYI, you can have amber and/or dependent libraries deployed in different
domain, if it suits you better (I use different domain
assets.mydomain.com to put such files there, and it works fine, I just
include
   '//assets.mydomain.com/path/without/js/Package-Name',
items in packages and it gets finely loaded ('//...' is normal url that
reuses http/https, you can include urls with specific protocol too, of
course). I load amber from assets server as well.

> sebastian <https://about.me/sebastianconcept>

Herby

P.S.: I would advise not to put lib under css ;-)

P.P.S.: If it is for deployment only (you will not need commit), you can
also do:

   packageHome: '/static/css/lib/',
   packages: [ 'framework1/Framework1', 'app/App' ],
   ready: function () { ... }

--
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/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: fine control of amber load

Herby Vojčík


Doug Stewart wrote:

> Well, there is a limitation and a correction to what I first posted.
>
> Desire: projects : common directory for all projects
> helloWorld - directory where my HelloWorldApp should live
> counter - directory where my CounterApp should live
>
> Whatever packageHome is set to, is where a "commit" looks for a js
> subdirectory to save files to. It doesn't get that there are two
> separate packages with two independent homes.
>
> If I set packageHome to "/projects/" then amber expects there to be a js
> directory there and that is where all my commits will save.
> If I set packageHome to "/projects/counter/" then amber expects there to
> be a js directory there and that is where all my commit will save.
>
> How does one load two separate projects on one web page while
> configuring each to commit to their own separate locations?

Impossible with current loader. Commit directory only one, the
packageHome (which also serves as base path for resolving package paths;
IOW, only pathless packages should be committed to be rewritten).

As for more apps at the same time, I see no point for that, just have
seperate page where you load this or that app.

As for having "libraries" and "main app" at the same time - it is an
incovenience, but I sort of got used to it and have different html for
libraries and different one for the app itself, open at different tabs.

> I've tried many permutations of packageHome & packages or prefix &

Do not combine packageHome and prefix, it can lead to strange cases.
files and packages are the same. I recommend use packages since it has
more highlevel perspective.

> files, with and without beginning and trailing slashes.
>
> I suppose I'll need to hack amber.js to get what I'm after here.

Or wait until next version where the loader will be better, or probably
completely different (we're considering let require.js take care).

Herby

--
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/groups/opt_out.