Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4051A9538 for ; Fri, 27 Jan 2012 22:18:55 +0000 (UTC) Received: (qmail 829 invoked by uid 500); 27 Jan 2012 22:18:53 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 722 invoked by uid 500); 27 Jan 2012 22:18:52 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 713 invoked by uid 99); 27 Jan 2012 22:18:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jan 2012 22:18:52 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of doppler@gmail.com designates 209.85.216.180 as permitted sender) Received: from [209.85.216.180] (HELO mail-qy0-f180.google.com) (209.85.216.180) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jan 2012 22:18:46 +0000 Received: by qcsc2 with SMTP id c2so1290358qcs.11 for ; Fri, 27 Jan 2012 14:18:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=9T8vlFiZPrmrMHcXaCUpAgqQEQzksIApxKgqtwvI6F0=; b=BT/yK3nX7ltw2mNVor8p84yg7Fw4bRxdqygPSgDbUqxZ44/A70x5Gpt/lRXp4QcZdK is7nwI8/8uC9l3HsCP59oMZ6gP9sDL5cGai7RuUcHrBXPfegy9wx+kPUS4tn3lPW827b AzlmkJsxOec9fEupAPlfbbd+E+q+IRAVRF2QI= MIME-Version: 1.0 Received: by 10.224.116.201 with SMTP id n9mr11120607qaq.16.1327702705255; Fri, 27 Jan 2012 14:18:25 -0800 (PST) Received: by 10.229.214.74 with HTTP; Fri, 27 Jan 2012 14:18:25 -0800 (PST) In-Reply-To: <4F23199B.5010104@gmail.com> References: <4F22108B.6040302@bardubitzki.com> <4F2224BB.6010800@bardubitzki.com> <47A595EA-F205-43C1-90AF-7FABAD9D85E2@couchbase.com> <4F22331B.9050202@bardubitzki.com> <4F23199B.5010104@gmail.com> Date: Fri, 27 Jan 2012 16:18:25 -0600 Message-ID: Subject: Re: re couchapp with node From: David Rose To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable couchapp.loadAttachments(ddoc, path.join(__dirname, 'attachments')); adds all files under the directory "attachments" as attachments to the design doc. ddoc.views.lib =3D couchapp.loadFiles('./lib'); adds any js files in the "./lib" directory as commonjs modules to your views, which you can then use in your views. Here's a snippet from one of mine: ddoc.views.alpha =3D { map : function(doc) { if(doc.type =3D=3D 'event') { var skey =3D require('views/lib/util').sanitizedKeyData(doc); var cvalue =3D require('views/lib/util').commonEmitValue(doc); emit(skey.name, cvalue); } }, reduce : "_count"=09 } ./lib/utils.js looks like this: exports.commonEmitValue =3D function(doc) { return({...}); } exports.sanitizedKeyData =3D function(doc) { // set vars and manipulate stuff return({...}); } You can also define ddoc filters in a similar fashion: ddoc.filters =3D couchapp.loadFiles('./filters'); Hope this somewhat incoherent reply helps point you in the right direction. David Rose On Fri, Jan 27, 2012 at 3:39 PM, john.tiger wr= ote: > I posted this with node google group but then realized I might get a > response from this group with more couchapp users. > > we're trying to use node.couchapp.js but since it's not very documented > having trouble figuring out whether base files such as index.html, app.cs= s, > etc should get added as either: > a) put under attachments folder and get loaded with loadAttachment > b) or listed under ddoc and loaded with loadFile > > > we have tried both the python version of couchapp which gave all sorts of > errors and seems overly complicated =A0and at Kelso - a node version of > couchapp which also has way too many dependencies making it quite > complicated as well - we are hoping to clean up, better document and even > simplify node.couchapp without dependencies. >