ok, I see that it is stated in the FAQ that this is not in your plan, so a pre-processor it is.
Just in case anyone else wants to add generic methods to main.js without polluting their views and needs to import a fairly substantial javascript library to do this you can do this in dos as follows copy x.js + y.js + couch_main.js main.js /Y xcopy main.js %COUCH_HOME%\share\server /Y /Q /R as you can see I am running windows, I have some bug fixes to give back on the c compilation with MSVC is JIRA the best way? thanks, Norman On Wed, Aug 12, 2009 at 3:06 PM, Jan Lehnardt<[email protected]> wrote: > > On 12 Aug 2009, at 22:50, Norman Barker wrote: > >> ok, (sorry should have been clearer) >> >> I am just looking to add generic functions to main.js - and the >> methods will be added to the sandbox to be available in a view, I also >> do not wish to load arbitrary functions in a view. I am not looking >> to add many, but main.js is getting big and it would be more >> manageable if we could use load (at the moment I am using a >> pre-processor to create main.js). >> >> Load will be available in main.js, it will not be available in the >> views - the sandbox takes care of that. >> >> I doubt I will be the only one who wants to add generic functions to a >> server since _show has been implemented and generic functionality from >> external libraries would be useful in this application. >> >> It is easier to maintain if generic functions can be added main.js not >> in views as such there either needs to be a pre-process in couchdb to >> create the main.js (so a windows batch file or shell script) or the >> load() function needs to be enabled or main.js is going to grow and >> grow. >> >> Jan, unless I am mistaken CouchApp does not change main.js? > > No but it injects code into your view, show and list functions which is > exactly > what you want. If you change your function library code, views need to > invalidated, if you don't include the code in the functions, CouchDB has no > way of knowing. > > http://wiki.apache.org/couchdb/Frequently_asked_questions#view_share_code > > Cheers > Jan > -- > > >> >> Norman >> >> On Wed, Aug 12, 2009 at 2:07 PM, Jan Lehnardt<[email protected]> wrote: >>> >>> On 12 Aug 2009, at 21:08, Norman Barker wrote: >>> >>>> Hi, >>>> >>>> I have been looking at the SpiderMonkey shell and the custom couchdb >>>> javascript driver and see that the couchdb driver does not allow the >>>> load(filename) function which is allowed in the shell, is this >>>> intentional? >>> >>> We don't want users to load extra files in their view code :) >>> >>> >>>> I am looking to add functions to main.js without having to paste them >>>> into one file and load() would have been a way around this. The >>>> alternative is to implement a pre-processor to create one file before >>>> deployment which I will use for now. >>> >>> CouchApp* is that preprocessor: >>> >>> http://github.com/couchapp/couchapp/tree/master >>> >>> Cheers >>> Jan >>> -- >>> >>> >> > >
