Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 62496 invoked from network); 24 Jul 2010 20:08:36 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 24 Jul 2010 20:08:36 -0000 Received: (qmail 74050 invoked by uid 500); 24 Jul 2010 20:08:35 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 73999 invoked by uid 500); 24 Jul 2010 20:08:34 -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 73991 invoked by uid 99); 24 Jul 2010 20:08:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Jul 2010 20:08:34 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of michael.lenahan@gmail.com designates 209.85.214.52 as permitted sender) Received: from [209.85.214.52] (HELO mail-bw0-f52.google.com) (209.85.214.52) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Jul 2010 20:08:28 +0000 Received: by bwz14 with SMTP id 14so4144789bwz.11 for ; Sat, 24 Jul 2010 13:08:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=92DypkppG2Xd/DQ52YVozo/OOhwx7Y6otpONREyA/SA=; b=m3VoK+mnMjaXvXuhWG6fa16hbvkZcbXAwOw6NBKTv9CtscBoq/arwZ0fm5Fv6uJOCb w9gUvnqCT7Gp4oG+4V7e5zEO7G19cPyT7BZwsWlLdHS0+VRUG+VYMKwMbElk5qjPlllv bptb1ywUoN2W6xZ/cePxkiEvC5SgiGDvJ27IU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=WLwOKPjLgs68z4v48ACU7D6ZWIbD3abnplRG43koHA3Tw8bZhx/bBAQA0ToEqfWkA0 BPlKqXjVr6e8s84QDhxlVT0B+n8wMgY+lwymJkgQOzh0BcJrzIGZsb0ZrZmEt26QpRCS IFmUwIM14OgzQvMTMrLk/7IOJ+ISB2dDOMZMI= Received: by 10.204.141.16 with SMTP id k16mr3848666bku.177.1280002087300; Sat, 24 Jul 2010 13:08:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.119.81 with HTTP; Sat, 24 Jul 2010 13:07:47 -0700 (PDT) In-Reply-To: References: <3D39EBB2-105D-44B7-AB52-676DF24FE1BC@gmail.com> <59926D7E-C40F-4B24-929C-0D62CA297564@gmail.com> From: Michael Lenahan Date: Sat, 24 Jul 2010 21:07:47 +0100 Message-ID: Subject: Re: georss atom feed To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Here's the github page: http://github.com/michaellenahan/sofa I'm very new to this so it's all good learning. The code is the same as described in my earlier email. Some points: 1. Mark - I tried your suggestion entry['georss::point'], entry['georss:point'] and some other variants in vendor/couchapp/lib/atom.js, but with no success - when I try these the point is omitted from the output altogether. 2. Any pointers on how to make latitude and longitude required fields in edit.html? Eventually I'd like to find a way to make it easier for users to choose locations from a dropdown and not enter co-ordinates manually. For now, I'd just like to make the fields compulsory. I'm probably missing something very simple, but I wasn't able to find a way to do that. Thanks! Michael On 24 July 2010 10:33, Michael Lenahan wrote: > Thanks everyone. Looks like my task for today is to learn git: > http://progit.org/book/. > > On 24 July 2010 02:30, J Chris Anderson wrote: >> >> On Jul 23, 2010, at 12:23 PM, Michael Lenahan wrote: >> >>> Thanks, jchris! >>> >>> I now have this: >>> http://mick.couchone.com/blog/_design/geosofa/_list/index/recent-posts?= descending=3Dtrue&limit=3D10&format=3Datom >>> >>> And this is what it looks like in Google Maps: >>> http://maps.google.com/maps?f=3Dq&source=3Ds_q&hl=3Den&geocode=3D&q=3Dh= ttp:%2F%2Fmick.couchone.com%2Fblog%2F_design%2Fgeosofa%2F_list%2Findex%2Fre= cent-posts%3Fdescending%3Dtrue%26limit%3D10%26format%3Datom&sll=3D37.0625,-= 95.677068&sspn=3D35.547176,56.513672&ie=3DUTF8&z=3D3 >>> >> >> This is super amazing. >> >> If you are willing to share your changes back to the world via git, I'm = sure people will dig in and help you refine this even further. >> >> Thanks so much for sharing it makes me really happy to see people pushin= g the boundaries like this. >> >> Chris >> >>> 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 =3D function(data) { >>> =A0// >>> =A0//var f =3D ; >>> =A0var f =3D >> xmlns:georss=3D"http://www.georss.org/georss"/>; >>> =A0// >>> =A0f.title =3D data.title; >>> =A0f.id =3D data.feed_id; >>> =A0f.link.@href =3D data.feed_link; >>> =A0f.link.@rel =3D "self"; >>> =A0f.generator =3D "CouchApp on CouchDB"; >>> =A0f.updated =3D rfc3339(data.updated); >>> =A0return f.toXMLString().replace(/\<\/feed\>/,''); >>> }; >>> >>> exports.entry =3D function(data) { >>> =A0var entry =3D ; >>> =A0entry.id =3D data.entry_id; >>> =A0entry.title =3D data.title; >>> =A0entry.content =3D data.content; >>> =A0entry.content.@type =3D (data.content_type || 'html'); >>> =A0entry.updated =3D rfc3339(data.updated); >>> =A0entry.author =3D {data.author}; >>> =A0entry.link.@href =3D data.alternate; >>> =A0entry.link.@rel =3D "alternate"; >>> =A0// >>> =A0entry.point =3D data.point; >>> =A0// >>> =A0return entry; >>> } >>> >>> (at the end of lists/index.js) >>> >>> =A0 =A0 =A0 =A0 =A0alternate : path.absolute(path.show('post', row.id))= , >>> =A0 =A0 =A0 =A0 =A0// >>> =A0 =A0 =A0 =A0 =A0//point : row.value.loc[1] + " " + row.value.loc[0] >>> =A0 =A0 =A0 =A0 =A0point : row.value.latitude + " " + row.value.longitu= de >>> =A0 =A0 =A0 =A0 =A0// >>> =A0 =A0 =A0 =A0}); >>> =A0 =A0 =A0 =A0// send the entry to client >>> =A0 =A0 =A0 =A0send(feedEntry); >>> =A0 =A0 =A0} while (row =3D getRow()); >>> =A0 =A0} >>> >>> =A0 =A0// close the loop after all rows are rendered >>> =A0 =A0return ""; >>> =A0}); >>> }; >>> >>> (I also made the following rudimentary changes to templates/edit.html) >>> >>> =A0 =A0 >>> =A0 =A0
>>> =A0 =A0 =A0

{{pageTitle}}

>>> =A0 =A0 =A0 =A0 >>> =A0 =A0 =A0 =A0

>>> =A0 =A0 =A0 =A0 =A0

>>> =A0 =A0 =A0 =A0

>>> =A0 =A0 =A0 =A0 =A0

>>> =A0 =A0 =A0 =A0

>>> =A0 =A0 =A0 =A0 =A0

>>> =A0 =A0 =A0 =A0 >>> >>> 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 =3D data.point >>> >>> I tried backslash-escaping, quoting, square brackets etc but with no lu= ck. >>> >>> 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-0= 5-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 (i= n this >>>>> case, a point with latitude and longitude). >>>>> >>>>> I'm taking sofa as my starting point, because it has atom feed capabi= lity >>>>> built in. >>>>> >>>>> So, sofa can generate this: >>>>> http://mick.couchone.com/blog/_design/sofa/_list/index/recent-posts?d= escending=3Dtrue&limit=3D10&format=3Datom >>>>> >>>>> 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: >>>>> >>>>> =A0 =A0 =A0 =A0// generate the entry for this row >>>>> =A0 =A0 =A0 =A0var feedEntry =3D Atom.entry({ >>>>> =A0 =A0 =A0 =A0 =A0entry_id : >>>>> path.absolute('/'+encodeURIComponent(req.info.db_name)+'/'+encodeURIC= omponent( >>>>> row.id)), >>>>> =A0 =A0 =A0 =A0 =A0title : row.value.title, >>>>> =A0 =A0 =A0 =A0 =A0content : html, >>>>> =A0 =A0 =A0 =A0 =A0updated : new Date(row.value.created_at), >>>>> =A0 =A0 =A0 =A0 =A0author : row.value.author, >>>>> =A0 =A0 =A0 =A0 =A0alternate : path.absolute(path.show('post', row.id= )) >>>>> =A0 =A0 =A0 =A0}); >>>>> >>>> >>>> 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 s= hould have put it in vendor in the first place, no other app uses it, I thi= nk). >>>> >>>> I don't know geo rss well enough but if it indeed RSS not Atom you wil= l probably need to use atom.js as a starting point to write your own XML ge= nerator. >>>> >>>> >>>> >>>>> 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 o= f >>>>> including latitude and longitude in my couchdb database, then concate= nating >>>>> 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 the= se db >>>>> elements? >>>>> >>>>> Thanks! >>>>> >>>>> Michael >>>> >>>> >> >> >