[lively-kernel] Loading JS files into world
Robert Krahn
robert.krahn at gmail.com
Wed Jan 14 01:06:28 CET 2015
Hi, Marco --
Right clicking for getting a menu should work and it sounds you experience
a bug. I'll investigate. What browser are you using?
Thanks,
Robert
On Tue, Jan 13, 2015 at 1:45 PM, Marco Monteiro <marco at neniu.org> wrote:
> Hi, Marko!
>
> Thanks for your help. The second method you described of adding it to my
> user config worked.
>
> As for the first method (which, as you point out, is what I actually want
> to use so that the
> worlds I create are usable by other users), I have a problem.
>
> When I right click in the module list I just get the morphic halo (the
> same thing I get when I Ctrl+Left-Click).
> If I select the menu from the halo, I cannot see an option to either "add
> to world requirements" or "add new file".
> How can I configure Lively to show the context menu when right clicking?
> Or what other key combination can
> I use to see the context menu?
>
> By going over the Lively-101 again, I can see there that Right click
> should be
> "ignored (some morphs provide a menu on right click)"
> but it's not ignored in my system. Is that makes any difference, I'm on
> Linux.
>
> By the way, I'm using lively for doing presentation slides that require
> showing JavaScript code.
> I've already created one about web messaging. I'm trying to clean it up so
> that I can share it on lively-web.org.
>
> The great thing about lively for this use case is that I can create a
> slide that embeds some code
> that I can run while doing the presentation; and then I can show the code.
> It's great.
>
> I'm using the PresentationController part. I saw the Lively2Lively world
> from Robert's presentation
> (http://lively-web.org/users/robertkrahn/2013-08-17_Lively2Lively.html)
> and knew that I want to use that.
>
> I'm very new to Lively, but not to Morphic. I've spent some time in 2004
> playing with Squeak and reading up on
> Smalltalk. I still have Squeak installed, and boot it up from time to time.
>
> I even played with the original Morphic, in Self, just to see it in the
> environment where it was invented.
> It's very cool.
>
> Funny that Morphic ends up in a language with a heavy inspiration from
> Self (the prototypes, at least)
> even though everyone wants classes instead; even Morphic implementation,
> it seems,
> with it's Object.subclass, etc. :D
>
> Thanks again.
>
> On Tue, Jan 13, 2015 at 5:51 PM, Marko Röder <m.roeder at photon-software.de>
> wrote:
>
>> Hi Marco -
>>
>> I don’t think modify the bootstrap.js is what is necessary here. This is
>> only for real core functionality that you would want in any page (also
>> mine, etc.).
>> Modules are the way to go and as I can see, you already figured out quite
>> a bit. Very good!
>>
>> To create your own module, open the world menu and go to Tools -> System
>> Code Browser. In the SCB, click on the … next to the two arrows (<, >) and
>> go to your directory. Right click on your directory listing, select “add
>> new file” and choose a name for your module. This will give you a JS
>> (module) file that looks similar to the snippet of your original email. And
>> yes, you can load an external library with exactly this additional
>> requiresLibs() call. Additionally, you can add all the JS methods you
>> want to have in all your worlds inside the toRun(function() { … }) body.
>> If you still want to attach it to the (current) world, wrap it with lively.whenLoaded(function(world)
>> { … }) and attach it to world.
>> But you can also create your own classes in that module, add those
>> methods there and reference your class from the calling side.
>>
>> To make your module a requirement in your worlds, there are two ways.
>> 1) In every world you want the code to run, open the SCB (described
>> above), find the module, right click the module in the listing and select
>> “add to world requirements”. Don’t forget to save the page. The code will
>> be loaded immediately and the next time you load this world.
>> 2) Add it to your user config (so that every world you load, no matter
>> its dependencies) will have it. Open the SCB, go to your user directory and
>> edit the config.js. Either put it in as a requirement in
>> requires('user.yourUsername.YourModule') or inside the toRun function do
>> module('user.yourUsername.YourModule').load(true); (true = synchronous
>> loading).
>> The drawback here is that only you will run your user config and if
>> someone else tries to load your worlds, those dependencies will be missing.
>> (So I encourage you to use (1) even though it means that you will have to
>> add this dependency to all of your worlds manually.)
>>
>> You can find some additional information on modules, classes, etc. in:
>>
>> http://lively-web.org/users/mroeder/lively-concepts.html
>> http://lively-web.org/users/robertkrahn/lively-cheat-sheet.html
>>
>> And, of course, let us know if you need any more help and keep us posted
>> on what you are trying to build with Lively :-)!
>>
>> Best,
>>
>> - Marko ;-)
>>
>>
>> PS: I guess you have also seen
>> http://lively-web.org/users/robertkrahn/Lively-101.html. It does not
>> really cover "low-level stuff” can be of good help!
>>
>>
>> On Jan 13, 2015, at 2:50 AM, Marco Monteiro <marco at neniu.org> wrote:
>>
>> Hello!
>>
>> I've recently started playing with Lively and I have a couple of
>> questions.
>>
>> I have some helper JS methods that I want to use in different worlds.
>> Currently I install the methods in the world morph and use $world.<method>
>> in my code. I would like to extract these methods into a JS library file
>> and import it into different worlds. By reading other posts in the mailing
>> list, I found that, for example,
>> http://lively-web.org/users/larswassermann/relax.html, loads the
>> http://lively-web.org/users/larswassermann/relax.js file. I want to do
>> the same thing in my worlds. How can I do that?
>>
>> I've been exploring and found the Preferences window. In that, I see a
>> bootstrap group, which seems could be something that would allow me to add
>> files JS files to the bootstrap, but when I try to edit the bootstrapFiles
>> property, I get '["core/lively/Migration.js","core/liv...' in the editor,
>> instead of the entire array.
>>
>> Also, how can I load a generic JS library (for example
>> https://sdk.amazonaws.com/js/aws-sdk-2.1.5.min.js) into the world and
>> have AWS (defined as a global variable in the library) be a global variable
>> in my world?
>>
>> I think I read in the mailing list an answer to this:
>>
>> module(<my-module>).requires().requiresLib({
>> url: "https://sdk.amazonaws.com/js/aws-sdk-2.1.5.min.js", loadTest:
>> function() { return !!window.AWS; }
>> }).toRun(function() {
>>
>> });
>>
>> if I can load my own library (earlier question).
>>
>> Is there any documentation or other resources for this kind of (lower
>> level) stuff? For example, how the bootstrap process works, etc.
>>
>> Thanks.
>> _______________________________________________
>> lively-kernel mailing list
>> lively-kernel at hpi.uni-potsdam.de
>> http://lists.hpi.uni-potsdam.de/listinfo/lively-kernel
>>
>>
>>
>
> _______________________________________________
> lively-kernel mailing list
> lively-kernel at hpi.uni-potsdam.de
> http://lists.hpi.uni-potsdam.de/listinfo/lively-kernel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hpi.uni-potsdam.de/archive/lively-kernel/attachments/20150113/ba1daef8/attachment.html>
More information about the lively-kernel
mailing list