<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Marco -<div class=""><br class=""></div><div class="">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.).</div><div class="">Modules are the way to go and as I can see, you already figured out quite a bit. Very good!</div><div class=""><br class=""></div><div class="">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 <font face="Courier New" class="">requiresLibs()</font> call. Additionally, you can add all the JS methods you want to have in all your worlds inside the <font face="Courier New" class="">toRun(function() { … })</font> body.</div><div class="">If you still want to attach it to the (current) world, wrap it with <font face="Courier New" class="">lively.whenLoaded(function(world) { … })</font> and attach it to <font face="Courier New" class="">world</font>.</div><div class="">But you can also create your own classes in that module, add those methods there and reference your class from the calling side.</div><div class=""><br class=""></div><div class="">To make your module a requirement in your worlds, there are two ways.</div><div class="">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.</div><div class="">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 <font face="Courier New" class="">requires('user.yourUsername.YourModule</font><span style="font-family: 'Courier New';" class="">'</span><font face="Courier New" class="">)</font> or inside the toRun function do <font face="Courier New" class="">module('user.yourUsername.YourModule').load(true);</font> (true = synchronous loading).</div><div class="">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.)</div><div class=""><br class=""></div><div class="">You can find some additional information on modules, classes, etc. in:</div><div class=""><br class=""></div><div class=""><a href="http://lively-web.org/users/mroeder/lively-concepts.html" class="">http://lively-web.org/users/mroeder/lively-concepts.html</a></div><div class=""><a href="http://lively-web.org/users/robertkrahn/lively-cheat-sheet.html" class="">http://lively-web.org/users/robertkrahn/lively-cheat-sheet.html</a></div><div class=""><br class=""></div><div class="">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 :-)!</div><div class=""><br class=""></div><div class="">Best,</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>- Marko ;-)</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">PS: I guess you have also seen <a href="http://lively-web.org/users/robertkrahn/Lively-101.html" class="">http://lively-web.org/users/robertkrahn/Lively-101.html</a>. It does not really cover "low-level stuff” can be of good help!</div><div class=""><br class=""></div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Jan 13, 2015, at 2:50 AM, Marco Monteiro <<a href="mailto:marco@neniu.org" class="">marco@neniu.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class="">Hello!<br class=""><br class=""></div>I've recently started playing with Lively and I have a couple of questions.<br class=""><br class="">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, <a href="http://lively-web.org/users/larswassermann/relax.html" class="">http://lively-web.org/users/larswassermann/relax.html</a>, loads the <a href="http://lively-web.org/users/larswassermann/relax.js" class="">http://lively-web.org/users/larswassermann/relax.js</a> file. I want to do the same thing in my worlds. How can I do that? <br class=""><br class="">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.<br class=""></div><br class="">Also, how can I load a generic JS library (for example<code class=""><span class=""><span class=""> <a href="https://sdk.amazonaws.com/js/aws-sdk-2.1.5.min.js" class="">https://sdk.amazonaws.com/js/aws-sdk-2.1.5.min.js</a></span></span></code>) into the world and have AWS (defined as a global variable in the library) be a global variable in my world?<br class=""><br class=""></div>I think I read in the mailing list an answer to this:<br class=""><br class="">module(<my-module>).requires().requiresLib({<br class=""> url: "<a href="https://sdk.amazonaws.com/js/aws-sdk-2.1.5.min.js" class="">https://sdk.amazonaws.com/js/aws-sdk-2.1.5.min.js</a>", loadTest: function() { return !!window.AWS; }<br class="">}).toRun(function() {<br class=""><br class="">});<br class=""><div class=""><div class=""><br class="">if I can load my own library (earlier question).<br class=""><br class="">Is there any documentation or other resources for this kind of (lower level) stuff? For example, how the bootstrap process works, etc.<br class=""><br class=""></div><div class="">Thanks.<br class=""></div></div></div>
_______________________________________________<br class="">lively-kernel mailing list<br class=""><a href="mailto:lively-kernel@hpi.uni-potsdam.de" class="">lively-kernel@hpi.uni-potsdam.de</a><br class="">http://lists.hpi.uni-potsdam.de/listinfo/lively-kernel<br class=""></div></blockquote></div><br class=""></body></html>