From user-return-11651-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Fri Jul 23 21:12:30 2010 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 36952 invoked from network); 23 Jul 2010 21:12:29 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 23 Jul 2010 21:12:29 -0000 Received: (qmail 13777 invoked by uid 500); 23 Jul 2010 21:12:28 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 13716 invoked by uid 500); 23 Jul 2010 21:12:27 -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 13708 invoked by uid 99); 23 Jul 2010 21:12:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Jul 2010 21:12:27 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of virtualandy@gmail.com designates 209.85.213.52 as permitted sender) Received: from [209.85.213.52] (HELO mail-yw0-f52.google.com) (209.85.213.52) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Jul 2010 21:12:23 +0000 Received: by ywa6 with SMTP id 6so213312ywa.11 for ; Fri, 23 Jul 2010 14:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:x-mailer :mime-version:subject:date:references; bh=HtBgKwBUzaS3MFRLShhl4sFR88p5xFWS99uHMbixy5w=; b=nOx5b4nDFlCvokHAbfaBPbNIVYePMgvS/qtis2yqF8fwdj82q+WUGj1DcrcU18E3VJ tcd3FSjE+iKom50FHy+D8eQZf8VCg+ETQ5o0dKdXl5Wwp9IB1FncFC/eDwloIoKEd+S6 i3kQ7ebx8bzsaxRnnR6zto9meLnvbTju/Q4Jc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:x-mailer:mime-version:subject:date :references; b=dbuHxHC1ZuZPuENOxBO1KhmJW2M/sCsE7mw0oEHly11yQTAgyA+bc1ZuYSwFVQBkCK lFwB5U2FAzDiBhLHrnhHcRCTq5fBESD3BHdnWOxpqBB7oDPosteozGirvSrLo3GSOCHg fl4GakEe3fSsnySXGxgx1gAE/B0WihIntEGZE= Received: by 10.100.226.13 with SMTP id y13mr4660486ang.216.1279919521780; Fri, 23 Jul 2010 14:12:01 -0700 (PDT) Received: from [10.56.136.66] ([166.205.12.85]) by mx.google.com with ESMTPS id k11sm948697ani.30.2010.07.23.14.11.57 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 23 Jul 2010 14:12:00 -0700 (PDT) Message-Id: <5293379D-5994-4BF0-A5FE-5B319EFC16E1@gmail.com> From: Andy Ennamorato To: "user@couchdb.apache.org" In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Mailer: iPhone Mail (7E18) Mime-Version: 1.0 (iPhone Mail 7E18) Subject: Re: georss atom feed Date: Fri, 23 Jul 2010 15:11:48 -0600 References: <3D39EBB2-105D-44B7-AB52-676DF24FE1BC@gmail.com> Thanks for sharing this info - very similar to what I want to try and do with couchdb. Sent from my iPhone On Jul 23, 2010, at 1:28 PM, Michael Lenahan wrote: > (Resending because I forgot to add a section I amended in templates/ > edit.html) > > > ---------- Forwarded message ---------- > From: Michael Lenahan > Date: 23 July 2010 20:23 > Subject: Re: georss atom feed > To: user@couchdb.apache.org > > > Thanks, jchris! > > I now have this: > http://mick.couchone.com/blog/_design/geosofa/_list/index/recent-posts?descending=true&limit=10&format=atom > > And this is what it looks like in Google Maps: > http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=http:%2F%2Fmick.couchone.com%2Fblog%2F_design%2Fgeosofa%2F_list%2Findex%2Frecent-posts%3Fdescending%3Dtrue%26limit%3D10%26format%3Datom&sll=37.0625,-95.677068&sspn=35.547176,56.513672&ie=UTF8&z=3 > > Here's what I did: > > I copied sofa into a new folder geosofa, and made these changes: > > (at the end of vendor/couchapp/lib/atom.js) > > exports.header = function(data) { > // > //var f = ; > var f = xmlns:georss="http://www.georss.org/georss"/>; > // > f.title = data.title; > f.id = data.feed_id; > f.link.@href = data.feed_link; > f.link.@rel = "self"; > f.generator = "CouchApp on CouchDB"; > f.updated = rfc3339(data.updated); > return f.toXMLString().replace(/\<\/feed\>/,''); > }; > > exports.entry = function(data) { > var entry = ; > entry.id = data.entry_id; > entry.title = data.title; > entry.content = data.content; > entry.content.@type = (data.content_type || 'html'); > entry.updated = rfc3339(data.updated); > entry.author = {data.author}; > entry.link.@href = data.alternate; > entry.link.@rel = "alternate"; > // > entry.point = data.point; > // > return entry; > } > > (at the end of lists/index.js) > > alternate : path.absolute(path.show('post', row.id)), > // > //point : row.value.loc[1] + " " + row.value.loc[0] > point : row.value.latitude + " " + row.value.longitude > // > }); > // send the entry to client > send(feedEntry); > } while (row = getRow()); > } > > // close the loop after all rows are rendered > return ""; > }); > }; > > (I also made the following rudimentary changes to templates/edit.html) > > >
>

{{pageTitle}}

> >

>

>

>

>

>

> > > (... this is further down in templates/edit.html) > > // apply docForm at login. > $("#account").evently({ > loggedIn : function(e,r) { > var userCtx = r.userCtx; > postForm = app.docForm("form#new-post", { > id : {{ docid }}, > //fields : ["title", "body", "tags"], > fields : ["title", "latitude", "longitude", "body", > "tags"], > template : { > type : "post", > format : "markdown", > author : userCtx.name > }, > > Some issues: > > 1. I wasn't able to edit atom.js to make it take account of the full > name for georss:point > > entry.georss:point = data.point > > I tried backslash-escaping, quoting, square brackets etc but with no > luck. > > In the end I settled with "point" (without the namespace). It works > but it's a bit wrong. > > 2. I started by saving the data in an array called "loc", since this > is the way suggested by Volker > (http://vmx.cx/cgi-bin/blog/index.cgi/geocouch-the-future-is-now:2010-05-03:en,CouchDB,Python,Erlang,geo > ) > and more in line with geojson. > > However, I've been tripped up by my lack of knowledge in couchapp - I > don't know how to write from my couchapp into an array, whereas > writing into separate latitude, longitude fields was very easy - just > a matter of adding the text input tags to templates/edit.html > > Thanks very much. Couchapp is simply amazing. > > Michael > > On 22 July 2010 21:34, J Chris Anderson wrote: >> >> On Jul 22, 2010, at 1:27 PM, Michael Lenahan wrote: >> >>> Hi there - I'm looking to find ways to get CouchDB to serve georss >>> (in this >>> case, a point with latitude and longitude). >>> >>> I'm taking sofa as my starting point, because it has atom feed >>> capability >>> built in. >>> >>> So, sofa can generate this: >>> http://mick.couchone.com/blog/_design/sofa/_list/index/recent-posts?descending=true&limit=10&format=atom >>> >>> In the couchapp files on my local machine I'm looking to amend >>> sofa/lists/index.js so that the feed entry includes georss:point as >>> specified here: >>> http://www.georss.org/simple#Point >>> >>> Currently the relevant part of sofa/lists/index.js looks like this: >>> >>> // generate the entry for this row >>> var feedEntry = Atom.entry({ >>> entry_id : >>> path.absolute('/'+encodeURIComponent(req.info.db_name) >>> +'/'+encodeURIComponent( >>> row.id)), >>> title : row.value.title, >>> content : html, >>> updated : new Date(row.value.created_at), >>> author : row.value.author, >>> alternate : path.absolute(path.show('post', row.id)) >>> }); >>> >> >> you will need to modify atom.js to add the proper xml to the output. >> >> http://github.com/jchris/sofa/blob/master/vendor/couchapp/lib/atom.js#L32 >> >> You should just copy this to your app's lib folder (I probably >> never should have put it in vendor in the first place, no other app >> uses it, I think). >> >> I don't know geo rss well enough but if it indeed RSS not Atom you >> will probably need to use atom.js as a starting point to write your >> own XML generator. >> >> >> >>> Has anyone out there done this already? Specifically I wonder how >>> to handle >>> the fact of georss:point containing a colon and getting that to >>> work in the >>> js file. >>> >>> Also - apologies if this is a dumb question - is it simply a >>> matter of >>> including latitude and longitude in my couchdb database, then >>> concatenating >>> these at the correct position in this js file - >>> >>> georss:point : row.value.latitude + ' ' + row.value.longitude >>> >> >> for this, you can quote the keys, like: "georss:point" >> >>> - or are there other things I need to consider before referencing >>> these db >>> elements? >>> >>> Thanks! >>> >>> Michael >> >>