From user-return-21699-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Mon Aug 6 17:27:22 2012 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 40D0BD7CB for ; Mon, 6 Aug 2012 17:27:22 +0000 (UTC) Received: (qmail 43918 invoked by uid 500); 6 Aug 2012 17:27:20 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 43889 invoked by uid 500); 6 Aug 2012 17:27:20 -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 43878 invoked by uid 99); 6 Aug 2012 17:27:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Aug 2012 17:27:20 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [128.18.84.133] (HELO brightmail-internal4.sri.com) (128.18.84.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Aug 2012 17:27:12 +0000 X-AuditID: 80125485-b7f806d000007ee4-ac-501ffe5969d8 Received: from exchange-hub02.SRI.COM (exchange-hub02.SRI.COM [128.18.23.154]) (using TLS with cipher AES128-SHA (AES128-SHA/128 bits)) (Client did not present a certificate) by brightmail-internal4.sri.com (SRI Internal SMTP Gateway) with SMTP id 84.89.32484.95EFF105; Mon, 6 Aug 2012 10:26:50 -0700 (PDT) Received: from EXCHANGE-DB09.SRI.COM ([fe80::cd39:3d94:b307:e72a]) by exchange-hub02.SRI.COM ([fe80::f097:c52f:a570:8336%12]) with mapi id 14.02.0298.004; Mon, 6 Aug 2012 10:26:47 -0700 From: Jim Klo To: "" Subject: Re: Using underscorejs in a couchapp list Thread-Topic: Using underscorejs in a couchapp list Thread-Index: AQHNc/YdHyTRdKenrUaOQ7KPsizGnJdNfr0A Date: Mon, 6 Aug 2012 17:26:46 +0000 Message-ID: <42876544-51A7-45D0-9679-028DE0ABA077@sri.com> References: <501FFC0F.6070004@alexandreleray.com> In-Reply-To: <501FFC0F.6070004@alexandreleray.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [192.12.16.223] Content-Type: multipart/signed; boundary="Apple-Mail-58-894588486"; protocol="application/pkcs7-signature"; micalg=sha1 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHIsWRmVeSWpSXmKPExsXSICQ+Szfqn3yAwYmtPBade/ayOTB6bPxw nDGAMYrLJiU1J7MstUjfLoEr49v1o0wFd6sqVrx9z9LAeDu3i5GDQ0LARGL5xJQuRk4gU0zi wr31bCC2kMBOJol9s7y7GLmA7L2MEtO+7GAFSbAJyEsc3v6AGcQWEbCUuLXgIwuILSxgJPFz 9hKouLHE77tP2EHmiwDFH7y3AgmzCKhInF3xix3E5hWwkpj0fhs7xC5DiSWTloHZnEDly9tb wG5gBLrn+6k1TCA2s4C4xK0n85kg7hSReHjxNBuELSrx8vE/VghbUaLr0Q1WiPpKiVuzN7BB 7BKUODnzCcsERpFZSEbNQlI2C0kZRNxd4sDcj8wQtrbEsoWvgWwOIFtHYvJCRlRhCPvj+SNQ I00lXh/9CFVjLTHj10E2CFtRYkr3Q/YFjNyrGGWSijLTM0pyEzNzdGFxaaJXXJSpl5yfu4kR HKshrTsYV+wxPMQowMGoxMN7w0A+QIg1say4MvcQowQHs5IIb81CoBBvSmJlVWpRfnxRaU5q 8SFGaQ4WJXHeb+b8/kIC6YklqdmpqQWpRTBZJg5OqQbGfIbj38w7pOXqxbStnm3QePRWYXPH xj9HxPt2ubY9v9wTZNNd33jC8MXe+5mrBMXlN3Cq39TdxZGqvarw4oZnzeuKX311P3eyf+/+ dZOP/7ri4WqR++te/NXnLbN0rL/uzjFLWcvQPdPlv1MLS4nqiWsHhWQC9EzWa7cdqGa7d/j1 lkU312ztU2Ipzkg01GIuKk4EAGOnVVTRAgAA --Apple-Mail-58-894588486 Content-Type: multipart/alternative; boundary=Apple-Mail-57-894588452 --Apple-Mail-57-894588452 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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/thecollect= or-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, >=20 > 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: >=20 > function(doc) { > if (doc.application =3D=3D=3D "publication") { > emit([doc.year, doc.title], doc); > }; > } >=20 > 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. >=20 > My idea was to use underscorejs `_.sortBy` method to reorganize the = data by year into a dictionary, to end up with something like this: >=20 > { > '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', ...}, > {...} > ], > ... > } >=20 > =46rom 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-coucha= pp-list/11817375#11817375). >=20 > 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. >=20 > Thanks a lot, >=20 > Alex >=20 >=20 --Apple-Mail-57-894588452 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii https://github.com/jimkl= o/TheCollector/blob/master/dataservices/thecollector-resources/views/lib/u= nderscore-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 =3D=3D=3D = "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', = ...},
       {...}
=      ],
=      ...
   }

=46rom = 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/1178= 1502/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



= --Apple-Mail-57-894588452-- --Apple-Mail-58-894588486 Content-Disposition: attachment; filename="smime.p7s" Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIJ/zCCBO0w ggRWoAMCAQICEBX3i1OyIZLyYjv7fwx/UYkwDQYJKoZIhvcNAQEFBQAwgdgxCzAJBgNVBAYTAlVT MRowGAYDVQQKExFTUkkgSW50ZXJuYXRpb25hbDEfMB0GA1UECxMWVmVyaVNpZ24gVHJ1c3QgTmV0 d29yazE7MDkGA1UECxMyVGVybXMgb2YgdXNlIGF0IGh0dHBzOi8vd3d3LnZlcmlzaWduLmNvbS9y cGEgKGMpMDIxMDAuBgNVBAsTJ0NsYXNzIDIgT25TaXRlIEluZGl2aWR1YWwgU3Vic2NyaWJlciBD QTEdMBsGA1UEAxMUU1JJIEludGVybmF0aW9uYWwgQ0EwHhcNMTIwMTAzMDAwMDAwWhcNMTMwMTAy MjM1OTU5WjCBwjEaMBgGA1UEChQRU1JJIEludGVybmF0aW9uYWwxKDAmBgNVBAsUH0luZm9ybWF0 aW9uIFRlY2hub2xvZ3kgU2VydmljZXMxRjBEBgNVBAsTPXd3dy52ZXJpc2lnbi5jb20vcmVwb3Np dG9yeS9DUFMgSW5jb3JwLiBieSBSZWYuLExJQUIuTFREKGMpOTkxEjAQBgNVBAMTCUphbWVzIEts bzEeMBwGCSqGSIb3DQEJARYPamltLmtsb0BzcmkuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A MIIBCgKCAQEA2utx7vCP7eb6FitPXlP4Oo4fm2Bsx/lz7X7rHvqZRFdNkLtZjmppsofuWMRdrIMj xCW0lCQb2mvKwA/VSKvoyd4MBSIDYT/jVMz7OeCzNk0VhGKRwqXBlkvl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