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 CF34DD843 for ; Fri, 17 Aug 2012 22:56:23 +0000 (UTC) Received: (qmail 39770 invoked by uid 500); 17 Aug 2012 22:56:22 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 39742 invoked by uid 500); 17 Aug 2012 22:56:22 -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 39734 invoked by uid 99); 17 Aug 2012 22:56:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Aug 2012 22:56:22 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=FSL_RCVD_USER,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [217.70.183.196] (HELO relay4-d.mail.gandi.net) (217.70.183.196) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Aug 2012 22:56:16 +0000 X-Originating-IP: 217.70.178.135 Received: from mfilter6-d.gandi.net (mfilter6-d.gandi.net [217.70.178.135]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id AB917172070 for ; Sat, 18 Aug 2012 00:55:54 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter6-d.gandi.net Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by mfilter6-d.gandi.net (mfilter6-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id AP95t6EdfBuH for ; Sat, 18 Aug 2012 00:55:53 +0200 (CEST) X-Originating-IP: 83.101.33.127 Received: from [192.168.178.35] (ip-83-101-33-127.customer.schedom-europe.net [83.101.33.127]) (Authenticated sender: newsletters@alexandreleray.com) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 1D2EA172077 for ; Sat, 18 Aug 2012 00:55:53 +0200 (CEST) Message-ID: <502ECE1E.9000105@alexandreleray.com> Date: Sat, 18 Aug 2012 01:05:02 +0200 From: AL User-Agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: user@couchdb.apache.org Subject: Re: Using underscorejs in a couchapp list References: <501FFC0F.6070004@alexandreleray.com> <42876544-51A7-45D0-9679-028DE0ABA077@sri.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Thanks Jim and Ryan, kanso seems quite interesting indeed :) I have started a small project based on it, but unfortunately I haven't been able to solve my problem. I was wondering if the folks on the list could have a look at it? I really can't spot the problem... The project is available here: https://github.com/aleray/lgru.couch Visiting the following URL will log variable `_`, which is undefined in my case... http://127.0.0.1:5984/mydb/_design/lgru/_list/publications/publications Thanks a lot, Alex On 06/08/2012 19:40, Ryan Ramage wrote: > Alex, > > If you are making a couchapp, and you want to use underscore, you > should give http://kan.so/ a try. There is a kanso package already for > underscore: > > http://kan.so/packages/details/underscore > > Kanso makes using commonjs modules very easy, and there are lots of > packages already available. > > Ryan > > > On Mon, Aug 6, 2012 at 11:26 AM, Jim Klo wrote: >> Hmm... I'm using underscore.js in my views and lists... maybe snake the >> version I'm using? >> >> https://github.com/jimklo/TheCollector/blob/master/dataservices/thecollector-resources/views/lib/underscore-min.js >> >> Jim Klo >> Senior Software Engineer >> Center for Software Engineering >> SRI International >> t. @nsomnac >> >> On Aug 6, 2012, at 10:17 AM, AL wrote: >> >> Hi all, >> >> I'm running archlinux and couchdb 1.2. I'm trying to develop a couchapp: >> although I could use couchdb only as a database, I like the idea of >> "self-containess" in couchapps. The application I want to build is fairly >> simple, consisting of list and detail views. I have a set of books described >> in a bibtex-like fashion, and I'm trying to serve a webpage that lists the >> whole collection, organized by year. Here is my view map: >> >> function(doc) { >> if (doc.application === "publication") { >> emit([doc.year, doc.title], doc); >> }; >> } >> >> I'd like to get a webpage consisting of several ul tags; one for every year. >> The getrow() function makes it easy to make one big list (1. opening the >> list, 2. creating a list element for every row, 3. closing the list) but for >> what I want to achieve it seems a little bit trickier. >> >> My idea was to use underscorejs `_.sortBy` method to reorganize the data by >> year into a dictionary, to end up with something like this: >> >> { >> '2009': [ >> {'title': ' The Transformer -- Principles of Making Isotype Charts', >> ...}, >> {'title': ' Verbindingen/Jonctions 10, Tracks in Electr(on)ic >> Fields', ...}, >> {...} >> ], >> '2012': [ >> {'title': 'Tying the Story to Data: The graffiti Markup Field >> Recorder Challenged, GML', ...}, >> {'title': 'Inside Photoshop', ...}, >> {...} >> ], >> ... >> } >> >> From there, I'd be able to loop through each key and append to my html >> output an HTML list. Unfortunately, I'm unable to import underscorejs, as it >> seems like they have dropped support for commonjs. There are forks and >> similar libraries that are supposed to work, but whatever I try, it fails >> (see my question here: >> http://stackoverflow.com/questions/11781502/using-underscorejs-in-a-couchapp-list/11817375#11817375). >> >> So I'd like to know whether it is achievable in this way or another, and if >> my direction is correct, how I can use underscorejs (or similar) in a >> couchapp. >> >> Thanks a lot, >> >> Alex >> >> >> >