incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From AL <newslett...@alexandreleray.com>
Subject Re: Using underscorejs in a couchapp list
Date Fri, 17 Aug 2012 23:05:02 GMT
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 <jim.klo@sri.com> 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
>>
>>
>>
>

Mime
View raw message