2009-03-09:
[16:32] <mykes> silly question[16:32] <mykes> how do you control the order your javascripts are loaded into Helma?[16:35] <simono> mykes, what are you trying to do? you don't have much control how they are loaded[16:42] <mykes> I want to load my custom library first[16:42] <mykes> then my app specific scripts[16:42] <mykes> I also want to load my custom library in every script, do I need to do app.addRepository() in every script file?[16:50] <simono> I'm not sure in which order helma loads those things, but this way always worked for me: put all app.addRepository() calls that your code relies on into Global/Global.js[16:50] <simono> a custom library you load with addRepository is then available in the whole helma app[16:53] <mykes> ok[16:53] <mykes> one example might be[16:53] <mykes> mylib.namespace = function(namespace) {[16:54] <mykes> if (!global['namespace']) {[16:54] <mykes> global[namespace] = {};[16:54] <mykes> }[16:54] <mykes> }[16:54] <mykes> so in ALL my .js files[16:54] <mykes> I want to be able to say:[16:54] <mykes> mylib.namespace('myapp');[16:54] <mykes> at the top[16:55] <mykes> the if(!global ... line is wrong, but you get the idea[16:55] <mykes> I guess I can just try your suggestion, Global.js[16:56] <mykes> see if the addRepository() is done in specific order[16:56] <mykes> but...[16:56] <mykes> mylib.namespace would be in Global/namespace.js[16:56] <mykes> something like that[16:56] <mykes> so chicken/egg thing[17:06] <simono> wait, if think this if is the thing that helps u[17:07] <simono> mykes, for example here in jala see the top lines http://dev.orf.at/trac/jala/browser/trunk/code/DnsClient.js[17:07] <mykes> yes[17:07] <mykes> I know to do that[17:08] <mykes> but I want to have mylib.namespace('myapp') as shorthand[17:08] <mykes> this is just the first of many similar things where load order is important[17:08] <simono> oh i see[17:08] <mykes> I am hoping to contribute a lot to Helma from now on[17:08] <mykes> I write javascript all day for my job[17:09] <mykes> for over 2 years[17:09] <mykes> I think I can help work on it[17:09] <simono> awesome[17:10] <simono> writing js code is my dayjob as well...[17:11] <mykes> I am already a big fan of Helma[17:11] <mykes> I wrote my first code in it over the weekend[17:12] <simono> about your load-order-problem: you could load this namespace-function from a seperate repository and load that repository before your actual app-code.[17:13] <mykes> in apps.properties[17:13] <simono> yes[17:13] <mykes> repository.0[17:13] <mykes> repository.1[17:14] <mykes> so it goes in repository0[17:14] <mykes> onRequest()[17:14] <mykes> what if you want to have 2 of those?[17:14] <mykes> or 10?[17:15] <mykes> you need to wrap it[17:15] <mykes> function addDoRequest(fn) {[17:15] <mykes> this.doRequestFns.push(fn);[17:15] <mykes> }[17:15] <mykes> function realDoRequest() {[17:15] <simono> sorry what do do you mean? the ordering of the repository.X is significant - you can overwrite things in later repos[17:15] <mykes> for (var i in this.doRequestFns) {[17:16] <mykes> this.doRequestFns[i]();[17:16] <mykes> }[17:16] <mykes> }[17:16] <mykes> I mean does repo.0 get loaded first[17:16] <simono> yes![17:16] <mykes> aha[17:16] <mykes> makes sense[17:16] <mykes> http://blog.pint.com/2009/03/09/on-server-side-javascript/[17:16] <simono> about onRequest - why do you want multiple of those? per repository or per prototype?[17:16] <mykes> depends on the request, no?[17:17] <mykes> if you're makign a CMS application[17:17] <mykes> maybe for admin you do special onRequest in addition[17:17] <mykes> instead of having lots of logic inside doRequest[17:17] <mykes> if (isAdmin) { do stuff }[17:18] <mykes> if (isEditor) { do stuff }[17:18] <simono> sure, if you want per-prototype onRequest i would proxy those..[17:18] <mykes> example?[17:19] <simono> User.doOnRequest = function() { // custom stuff you want to do on user add } than in Global.onRequest check which object is path[-1] and execute it's doOnRequest[17:19] <mykes> I see[17:19] <mykes> not what I'm thinking tho[17:20] <simono> don't think that's what you want... with the isAdmin etc[17:20] <mykes> right[17:20] <mykes> so you can:[17:21] <simono> btw nice blog post.. your blog?[17:21] <mykes> oops, clicked the wrong thingg :)[17:21] <mykes> in apps.properties[17:21] <mykes> I can:[17:21] <mykes> myapp.repository0=/path/to/some/file.js[17:21] <mykes> myapp.repository1=/path/to/some/other/file.js[17:22] <mykes> and it does the order right[17:22] <simono> it does.[17:22] <mykes> I also want more than one static dir[17:23] <mykes> one for images[17:23] <mykes> one for client js[17:23] <mykes> one for css[17:23] <mykes> I want my html to be like:[17:23] <mykes> <img src="/img/foo.gif">[17:23] <mykes> and not[17:23] <mykes> <img src="/static/img/foo.gif">[17:23] <mykes> (same for js and css)[17:24] <simono> in production use, apache should help you with that. to make the same html-code work in devel as well, we have a staticUrl_macro.. so you really write <img src="<% static "image/foo.gif" " %> or similar[17:25] <mykes> ah[17:25] <mykes> but I won't use skins[17:26] <mykes> my html looks like:[17:26] <mykes> <html><head><script src="extjs.js"></script></head><body</body></html>[17:26] <mykes> so in my extjs code when I create images dynamically in the DOM[17:27] <mykes> I want shorter paths[17:27] <mykes> like /js /img /css[17:27] <mykes> so my client js is smaller[17:27] <simono> what's your deployment environment?[17:27] <mykes> today? we use apache + php on the server, ExtJS for the client (and jQuery)[17:28] <mykes> I would prefer to use Jetty and Helma and nothing else[17:28] <mykes> I'm not a java guy[17:28] <mykes> I hope that's sufficient[17:28] <mykes> I can do 100% of my server programming in JS in helma, I think[17:28] <mykes> most of it is:[17:28] <mykes> query[17:28] <mykes> result['rows'] = query result[17:29] <mykes> res.write(result.toJSON());[17:29] <mykes> res.stop()[17:29] <simono> okay, well we deploy with apache+mod_jk which is fairly easy to setup. in this setup the problem you describe can be solved by mod_rewrite[17:29] <simono> so can't help you much with jetty specific questions, i found this wiki page though http://dev.helma.org/wiki/Configuring+Jetty+in+Helma+1.x/[17:29] <mykes> isn't jetty what comes in the download package?[17:30] <simono> and maybe others reading this will have more to say about jetty deployment (i'm not even sure if its a good idea: serving static files via jetty)[17:30] <simono> yes yes! jetty comes with the download package, and it's very convinient for development[17:30] <mykes> not good for production?[17:31] <simono> ignore what i say about jetty, i don't know[17:31] <mykes> ha![17:32] <simono> though this is really easy: http://dev.helma.org/wiki/Workspace/maks/HelmaWithApache2/[17:32] <mykes> Apache2 is slow[17:32] <simono> works with apach1 too :)[17:32] <mykes> apache1 is slow, too :)[17:32] <mykes> it's meant to be general purpose and feature rich, not to be the fastest[17:32] <simono> well since you already have it, it won't slow you down :)[17:32] <mykes> I would not even want to install it tho[17:32] <simono> maybe until 2morrow someone[17:33] <simono> will insert knowledge about jetty.. gotta go, sorry[17:33] <mykes> ok, thanks[17:33] <mykes> I'll see you on google groups?
In the channel now:
Logs by date: