Dear list --
One very important topic that currently is not specified anywhere is how you can contribute source code to the project. In this post I will explain the system support for modularization and describe how contributions could be created and organized using Lively Wiki. Improvement suggestions are very welcome -- and of course you might want to try it out ;-) Important: Source code contributions should be MIT licensed. Please only upload your code if you are willing to accept this license. Part 1: Modules In Lively Kernel we use so called 'modules' to identify JavaScript and other source code files. On top of most files you will see something like this: module('lively.ide').requires('lively.Tools', 'lively.Ometa').toRun(function() { // Code depending on lively.Tools and lively.Ometa }) // end of module This definition does two things: a) Define the module lively.ide. The module can then be required from somewhere else: require('lively.ide').toRun(function() { new lively.ide.SystemBrowser().open() }) Evaluating this will let the system: 1. Check if lively.ide is loaded. If not then the module name is translated to an URL: {Config.codeBase}/lively/ide.js. That URL will be used to load the file ide.js asynchronously. * 2. When the file is loaded run the code of toRun() b) Define the namespace lively.ide. That means that if the module is there you can access it's members in JavaScript. For example the class lively.ide.SystemBrowser is such a member. ** Part 2: Using modules to add your extensions The first thing you need is some place to store your source code and your data. You can create your own subdirectory in the wiki here: http://www.lively-kernel.org/repository/lively-wiki/CreateUserDirectory.xhtml Your directory includes a WorldTemplate.xhtml that you can clone to create new pages. You can then add new Worlds and add source code in them using the local changes (and the Local code Browser, you find it in the Tools menu). Or you can create your own JavaScript files using the System browser or manually by checking out your directory using SVN and adding/editing files with a TextEditor. The JavaScript files should include a module definition. Example: My users directory in the wiki is /users/robertkrahn/. I can then add a test.js that can be loaded with require('users.robertkrahn.test').toRun(function() { /* code */ }) from anywhere in the wiki. Of course you can also add source code and subdirectories elsewhere. Assuming you want to add audio support you might want add a subdirectory audio to http://www.lively-kernel.org/repository/lively-wiki/. When your extension is stable enough it can be added to the Lively Kernel repository. Bugfixes to existing sources can of course go directly to the kernel repository. Best, Robert * Config.codeBase is a config option and contains the URL to the root directory. It is defined in defaultconfig.js. There it is set to the containing directory of the current document. It can be redefined later if necessary. ** Using the namespace inside a module is NOT enforced. This means if you define a class Object.subclass('SystemBrowser', {...}) it will "extend" the Global namespace. This means that you can access the class via Global.SystemBrowser (or simply with SystemBrowser). Only if you use the namespace explicitly Object.subclass('lively.ide.SystemBrowser', {...}) the namespace will be used and you can access the class via Global.lively.ide.SystemBrowser (or simply lively.ide.SystemBrowser). We might change that in the future to enforce namespace usage.
|
Correction: Important: Source code contributions MUST be MIT licensed. Please only upload your code if you are willing to accept this license. Best, Robert |
In reply to this post by Robert Krahn
Robert Krahn wrote:
> Part 2: Using modules to add your extensions > The first thing you need is some place to store your source code and your > data. You can create your own subdirectory in the wiki > here: http://www.lively-kernel.org/repository/lively-wiki/CreateUserDirectory.xhtml > Your directory includes a WorldTemplate.xhtml that you can clone to create > new pages. You can then add new Worlds and add source code in them using the > local changes (and the Local code Browser, you find it in the Tools menu). > Or you can create your own JavaScript files using the System browser or > manually by checking out your directory using SVN and adding/editing files > with a TextEditor. The JavaScript files should include a module definition. I'm confused about all these different tools. The System Code Browser (which I originally thought would be like a Smalltalk browser, showing me what's in the live image) seems to be showing me what's in the system code *files*. When I first open it up, it says that everything, even the core stuff (Core.js, Text.js, etc.), is "not loaded." Then when I click on the file name, it "loads", which I take to mean that the system is parsing the file and showing me what's in it (rather than showing me the actual code that's in the live image). If I make a change in there and hit Apple-S, it saves the change, and that change is visible if I hit my browser's Reload button or even open the world in another browser. So it obviously saved my change to a file somewhere. Where's the file? The only file in http://www.lively-kernel.org/repository/lively-wiki/users/AdamSpitz/ is the WorldTemplate.xhtml file (I don't see any .js files there), so I hope I didn't just overwrite some important official LK file or something. And then there's the Javascript Code Browser, which I can open by right-clicking any morph and saying "show class in browser." If I make a change *there*, it seems to be only changing the running image - when I reload the page my change is gone. Good, that makes sense to me. Incidentally, I noticed that after I've opened a System Code Browser, the Javascript Code Browser doesn't seem to work anymore - I get an error message in the console saying, "TypeError: Result of expression 'this.methodDicts' [undefined] is not an object." (Did I just cause this error by mucking around with system files?) Is the System Code Browser just meant to be a way of editing .js files? (That is, it doesn't operate on the live image, it's just a bit nicer than Emacs for editing .js files?) Is the idea that most "normal" programming (programming that isn't likely to crash the whole system if you make a typo) should be done in the Javascript Code Browser? > ** Using the namespace inside a module is NOT enforced. This means if you > define a class Object.subclass('SystemBrowser', {...}) it will "extend" the > Global namespace. This means that you can access the class via > Global.SystemBrowser (or simply with SystemBrowser). Only if you use the > namespace explicitly Object.subclass('lively.ide.SystemBrowser', {...}) the > namespace will be used and you can access the class via > Global.lively.ide.SystemBrowser (or simply lively.ide.SystemBrowser). > We might change that in the future to enforce namespace usage. If you do that, will it still be possible for me to write, say, a "set" class and add an asSet method to the Array class? Come to think of it, how does the current system know how to find "extension" methods like that and file them out when you file out the module that they belong to? In Self's module system (and in my port of it to LK), the module object itself keeps track of all the slots belonging to the module. But I don't think I've seen anything like that in LK. (I could easily have missed it, though.) Adam |
Hi, Adam
indeed you changed the code of the wiki with the system browser :-) ( http://www.lively-kernel.org/repository/lively-wiki/lively/) r19492 | AdamSpitz | 2010-04-14 16:49:34 +0200 (Mi, 14 Apr 2010) | 2 lines Autoversioning commit: a non-deltaV client made a change to /lively/Base.js ... Page local changes can be made using the Local code browser: For example the page: http://www.lively-kernel.org/repository/lively-wiki/changelog/changelog.xhtml adds requirements: ['lively.FileUploadWidget', 'cop.Workspace', 'lively.ide'] defines the class JournalEntryMorph and executes some doIts what we meant with user specific modules is the follwing: a page can add modul requirements and modules can also be but in user directories. http://www.lively-kernel.org/repository/lively-wiki/users/AdamSpitz/HereYouGo.xhtml http://www.lively-kernel.org/repository/lively-wiki/users/AdamSpitz/hello.js The System browser does not know about these files yet, but we will support them soon. Best Jens Am 14.04.10 17:19, schrieb Adam Spitz: Robert Krahn wrote:Part 2: Using modules to add your extensions The first thing you need is some place to store your source code and your data. You can create your own subdirectory in the wiki here: http://www.lively-kernel.org/repository/lively-wiki/CreateUserDirectory.xhtml Your directory includes a WorldTemplate.xhtml that you can clone to create new pages. You can then add new Worlds and add source code in them using the local changes (and the Local code Browser, you find it in the Tools menu). Or you can create your own JavaScript files using the System browser or manually by checking out your directory using SVN and adding/editing files with a TextEditor. The JavaScript files should include a module definition.I'm confused about all these different tools. The System Code Browser (which I originally thought would be like a Smalltalk browser, showing me what's in the live image) seems to be showing me what's in the system code *files*. When I first open it up, it says that everything, even the core stuff (Core.js, Text.js, etc.), is "not loaded." Then when I click on the file name, it "loads", which I take to mean that the system is parsing the file and showing me what's in it (rather than showing me the actual code that's in the live image). If I make a change in there and hit Apple-S, it saves the change, and that change is visible if I hit my browser's Reload button or even open the world in another browser. So it obviously saved my change to a file somewhere. Where's the file? The only file in http://www.lively-kernel.org/repository/lively-wiki/users/AdamSpitz/ is the WorldTemplate.xhtml file (I don't see any .js files there), so I hope I didn't just overwrite some important official LK file or something. And then there's the Javascript Code Browser, which I can open by right-clicking any morph and saying "show class in browser." If I make a change *there*, it seems to be only changing the running image - when I reload the page my change is gone. Good, that makes sense to me. Incidentally, I noticed that after I've opened a System Code Browser, the Javascript Code Browser doesn't seem to work anymore - I get an error message in the console saying, "TypeError: Result of expression 'this.methodDicts' [undefined] is not an object." (Did I just cause this error by mucking around with system files?) Is the System Code Browser just meant to be a way of editing .js files? (That is, it doesn't operate on the live image, it's just a bit nicer than Emacs for editing .js files?) Is the idea that most "normal" programming (programming that isn't likely to crash the whole system if you make a typo) should be done in the Javascript Code Browser?** Using the namespace inside a module is NOT enforced. This means if you define a class Object.subclass('SystemBrowser', {...}) it will "extend" the Global namespace. This means that you can access the class via Global.SystemBrowser (or simply with SystemBrowser). Only if you use the namespace explicitly Object.subclass('lively.ide.SystemBrowser', {...}) the namespace will be used and you can access the class via Global.lively.ide.SystemBrowser (or simply lively.ide.SystemBrowser). We might change that in the future to enforce namespace usage.If you do that, will it still be possible for me to write, say, a "set" class and add an asSet method to the Array class? Come to think of it, how does the current system know how to find "extension" methods like that and file them out when you file out the module that they belong to? In Self's module system (and in my port of it to LK), the module object itself keeps track of all the slots belonging to the module. But I don't think I've seen anything like that in LK. (I could easily have missed it, though.) Adam _______________________________________________ lively-kernel mailing list [hidden email] http://lists.hpi.uni-potsdam.de/listinfo/lively-kernel |
Jens Lincke wrote:
> Hi, Adam > > indeed you changed the code of the wiki with the system browser :-) > ( http://www.lively-kernel.org/repository/lively-wiki/lively/) > > r19492 | AdamSpitz | 2010-04-14 16:49:34 +0200 (Mi, 14 Apr 2010) | 2 lines > Autoversioning commit: a non-deltaV client made a change to > /lively/Base.js Cool! And I'm sorry. :) I've reverted a couple of the changes I made, but I might have made one or two more, and I don't even remember what file they might be in. Is there a way for me to find them? I think it's awesome that (in the Smalltalk and wiki tradition) everything is editable by anybody. But I'd suggest adding some sort of clear warning that I'm hopping a fence. And a way to delay the actual fileout until I'm ready. My expectation was that (like in Smalltalk) by mucking around inside the image I might be able to crash my image, but I wouldn't be screwing up the code in the official repository until I actually hit some button labelled "File Out" or something. I was definitely not expecting each individual method to be filed out as soon as I hit "accept changes." (What if I'm not sure my changes will work? I want to play with them in the image until I'm confident that they work, and *then* save them.) Adam |
In reply to this post by Lincke, Jens
> what we meant with user specific modules is the follwing: a page can add
> modul > requirements and modules can also be but in user directories. > > http://www.lively-kernel.org/repository/lively-wiki/users/AdamSpitz/HereYouGo.xhtml > http://www.lively-kernel.org/repository/lively-wiki/users/AdamSpitz/hello.js Oh, I forgot to ask: HereYouGo.xhtml seems to be a static snapshot of a world, rather than a live world itself. Was that intentional? Adam |
In reply to this post by Adam Spitz
Hi, Adam -
Working in the Wiki is a bit different, and we might want to address this. When I work, I check out a copy of LK from the repository, and load from that using a server on my machine via localhost. This gives me the kind of two stage commit you seem to be asking for: when I make changes in the System Browser, they affect my copy of the repo, not the master. When I'm sure I've made a good change or set of changes (and after making sure I'm otherwise up to date), I do an SVN commit in the OS to put my changes in the master sources at HPI. My guess is that there is some way to do that in the Wiki as well; perhaps R&J will have something to say about it. - Dan ----------------------------------- >Jens Lincke wrote: > >> Hi, Adam >> >> indeed you changed the code of the wiki with the system browser :-) >> ( http://www.lively-kernel.org/repository/lively-wiki/lively/) >> >> r19492 | AdamSpitz | 2010-04-14 16:49:34 +0200 (Mi, 14 Apr 2010) | 2 lines >> Autoversioning commit: a non-deltaV client made a change to >> /lively/Base.js > >Cool! And I'm sorry. :) I've reverted a couple of the changes I made, >but I might have made one or two more, and I don't even remember what >file they might be in. Is there a way for me to find them? > >I think it's awesome that (in the Smalltalk and wiki tradition) >everything is editable by anybody. But I'd suggest adding some sort of >clear warning that I'm hopping a fence. And a way to delay the actual >fileout until I'm ready. My expectation was that (like in Smalltalk) >by mucking around inside the image I might be able to crash my image, >but I wouldn't be screwing up the code in the official repository >until I actually hit some button labelled "File Out" or something. I >was definitely not expecting each individual method to be filed out as >soon as I hit "accept changes." (What if I'm not sure my changes will >work? I want to play with them in the image until I'm confident that >they work, and *then* save them.) > > >Adam >_______________________________________________ >lively-kernel mailing list >[hidden email] >http://lists.hpi.uni-potsdam.de/listinfo/lively-kernel |
In reply to this post by Adam Spitz
Hi, Adam
sorry my fault. would you try again http://www.lively-kernel.org/repository/lively-wiki/users/AdamSpitz/HereYouGo.xhtml Best, Jens Am 14.04.10 18:19, schrieb Adam Spitz: >> what we meant with user specific modules is the follwing: a page can add >> modul >> requirements and modules can also be but in user directories. >> >> http://www.lively-kernel.org/repository/lively-wiki/users/AdamSpitz/HereYouGo.xhtml >> http://www.lively-kernel.org/repository/lively-wiki/users/AdamSpitz/hello.js >> > Oh, I forgot to ask: HereYouGo.xhtml seems to be a static snapshot of > a world, rather than a live world itself. Was that intentional? > > > Adam > _______________________________________________ > lively-kernel mailing list > [hidden email] > http://lists.hpi.uni-potsdam.de/listinfo/lively-kernel > |
> sorry my fault. would you try again
> http://www.lively-kernel.org/repository/lively-wiki/users/AdamSpitz/HereYouGo.xhtml Hey, there it goes. :) Cool. Adam |
In reply to this post by Adam Spitz
Hi, Adam --
Thanks for trying it out! I can understand your confusion very well. I think that the problems that occur now are very valuable for us because we can learn from them and know what we have to improve, to communicate, and to document. I encourage you and everybody else to send your experiences and suggestions to the list so we can find solutions for them. Jens, Dan, and I are working in the system for some time now and we have our ways of doing things -- but these are necessarily not the best solutions and discussions about improvements are very welcome. The system already is capable of quite a lot but often it might not be obvious of how to approach a certain task (like creating and editing a file). Background info: Development in Lively was completely file-based in the beginning. This means that the way of writing code was to edit a JavaScript file, start the system, see if the change worked, add another change, restart, and so on. We then added support for editing the files from within Lively. This way it was not necessary anymore to restart the system. The tool that we use for that is the 'System code browser'. Next thing we did was to attach 'changes' to a world. A change is some JavaScript code snippet like a class definition that can be evaluated on world load. Changes aren't stored in a JavaScript file but are currently added to the XHTML data of a world. To edit them we use the 'Local code browser' and the 'Wiki code browser' (to edit changes of other worlds and not only the current one). Sooner or later we might want to abandon files completely but currently the mixture of files and local changes provides a lot of flexibility: If the system is broken for some reason or doesn't have support for something you want to do you can simply use other tools. The way I prefer to develop is the following: - I start to add tests and code to a world as local changes using the 'Local code browser. For code snippets I want to try out I use a text window (similar to a Smalltalk workspace). - When I'm done I merge/push my changes to some module. Currently this is done manually using copy and paste. - If I want to add it to an existing module I open the System browser and edit it. - If I want to create a new module I can do it with the System browser using 'add module' button. If you want to edit files in another directory as the default then you can choose 'Switch System browser directory' in the tools menu. This part is still to complicated and we will improve it soon. To get an impression of how I develop such a world: www.lively-kernel.org/repository/webwerkstatt/!svn/bc/5120/robert/DraftXMLConverter.xhtml. You can also view at the different versions to see the development process. Ah, and don't worry about changes to the core system. It is always possible to find out what was changed (using SVN or the 'Viewer for latest file changes') and additionally the wiki is separated from the kernel repository. We are able to sync them but currently do this semi-automatically: www.lively-kernel.org/repository/webwerkstatt/update.xhtml. I hope I was able to clear up your confusion at least a bit. Best, Robert On Apr 14, 2010, at 5:19 PM, Adam Spitz wrote:
|
Robert,
Thanks! Your explanation helps a lot. For a while now, I've been meaning to put up a screencast demonstrating how my Self-like LK development environment handles this kind of stuff. I'll try to get around to it soon. :) Adam On Wed, Apr 14, 2010 at 6:25 PM, Robert Krahn <[hidden email]> wrote: > Hi, Adam -- > Thanks for trying it out! > I can understand your confusion very well. I think that the problems that > occur now are very valuable for us because we can learn from them and know > what we have to improve, to communicate, and to document. I encourage you > and everybody else to send your experiences and suggestions to the list so > we can find solutions for them. > Jens, Dan, and I are working in the system for some time now and we have our > ways of doing things -- but these are necessarily not the best solutions and > discussions about improvements are very welcome. The system already is > capable of quite a lot but often it might not be obvious of how to approach > a certain task (like creating and editing a file). > Background info: > Development in Lively was completely file-based in the beginning. This means > that the way of writing code was to edit a JavaScript file, start the > system, see if the change worked, add another change, restart, and so on. > We then added support for editing the files from within Lively. This way it > was not necessary anymore to restart the system. The tool that we use for > that is the 'System code browser'. > Next thing we did was to attach 'changes' to a world. A change is some > JavaScript code snippet like a class definition that can be evaluated on > world load. Changes aren't stored in a JavaScript file but are currently > added to the XHTML data of a world. To edit them we use the 'Local code > browser' and the 'Wiki code browser' (to edit changes of other worlds and > not only the current one). > Sooner or later we might want to abandon files completely but currently the > mixture of files and local changes provides a lot of flexibility: If the > system is broken for some reason or doesn't have support for something you > want to do you can simply use other tools. > The way I prefer to develop is the following: > - I start to add tests and code to a world as local changes using the 'Local > code browser. For code snippets I want to try out I use a text window > (similar to a Smalltalk workspace). > - When I'm done I merge/push my changes to some module. Currently this is > done manually using copy and paste. > - If I want to add it to an existing module I open the System browser and > edit it. > - If I want to create a new module I can do it with the System browser using > 'add module' button. If you want to edit files in another directory as the > default then you can choose 'Switch System browser directory' in the tools > menu. This part is still to complicated and we will improve it soon. > To get an impression of how I develop such a > world: www.lively-kernel.org/repository/webwerkstatt/!svn/bc/5120/robert/DraftXMLConverter.xhtml. > You can also view at the different versions to see the development process. > Ah, and don't worry about changes to the core system. It is always possible > to find out what was changed (using SVN or the 'Viewer for latest file > changes') and additionally the wiki is separated from the kernel repository. > We are able to sync them but currently do this > semi-automatically: www.lively-kernel.org/repository/webwerkstatt/update.xhtml. > I hope I was able to clear up your confusion at least a bit. > Best, > Robert > > On Apr 14, 2010, at 5:19 PM, Adam Spitz wrote: > > Robert Krahn wrote: > > Part 2: Using modules to add your extensions > > The first thing you need is some place to store your source code and your > > data. You can create your own subdirectory in the wiki > > here: http://www.lively-kernel.org/repository/lively-wiki/CreateUserDirectory.xhtml > > Your directory includes a WorldTemplate.xhtml that you can clone to create > > new pages. You can then add new Worlds and add source code in them using the > > local changes (and the Local code Browser, you find it in the Tools menu). > > Or you can create your own JavaScript files using the System browser or > > manually by checking out your directory using SVN and adding/editing files > > with a TextEditor. The JavaScript files should include a module definition. > > I'm confused about all these different tools. > > The System Code Browser (which I originally thought would be like a > Smalltalk browser, showing me what's in the live image) seems to be > showing me what's in the system code *files*. When I first open it up, > it says that everything, even the core stuff (Core.js, Text.js, etc.), > is "not loaded." Then when I click on the file name, it "loads", which > I take to mean that the system is parsing the file and showing me > what's in it (rather than showing me the actual code that's in the > live image). If I make a change in there and hit Apple-S, it saves the > change, and that change is visible if I hit my browser's Reload button > or even open the world in another browser. So it obviously saved my > change to a file somewhere. Where's the file? The only file in > http://www.lively-kernel.org/repository/lively-wiki/users/AdamSpitz/ > is the WorldTemplate.xhtml file (I don't see any .js files there), so > I hope I didn't just overwrite some important official LK file or > something. > > And then there's the Javascript Code Browser, which I can open by > right-clicking any morph and saying "show class in browser." If I make > a change *there*, it seems to be only changing the running image - > when I reload the page my change is gone. Good, that makes sense to > me. > > Incidentally, I noticed that after I've opened a System Code Browser, > the Javascript Code Browser doesn't seem to work anymore - I get an > error message in the console saying, "TypeError: Result of expression > 'this.methodDicts' [undefined] is not an object." (Did I just cause > this error by mucking around with system files?) > > Is the System Code Browser just meant to be a way of editing .js > files? (That is, it doesn't operate on the live image, it's just a bit > nicer than Emacs for editing .js files?) Is the idea that most > "normal" programming (programming that isn't likely to crash the whole > system if you make a typo) should be done in the Javascript Code > Browser? > > > > ** Using the namespace inside a module is NOT enforced. This means if you > > define a class Object.subclass('SystemBrowser', {...}) it will "extend" the > > Global namespace. This means that you can access the class via > > Global.SystemBrowser (or simply with SystemBrowser). Only if you use the > > namespace explicitly Object.subclass('lively.ide.SystemBrowser', {...}) the > > namespace will be used and you can access the class via > > Global.lively.ide.SystemBrowser (or simply lively.ide.SystemBrowser). > > We might change that in the future to enforce namespace usage. > > If you do that, will it still be possible for me to write, say, a > "set" class and add an asSet method to the Array class? > > Come to think of it, how does the current system know how to find > "extension" methods like that and file them out when you file out the > module that they belong to? In Self's module system (and in my port of > it to LK), the module object itself keeps track of all the slots > belonging to the module. But I don't think I've seen anything like > that in LK. (I could easily have missed it, though.) > > > > Adam > _______________________________________________ > lively-kernel mailing list > [hidden email] > http://lists.hpi.uni-potsdam.de/listinfo/lively-kernel > > |
Free forum by Nabble | Edit this page |