incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Lenahan <michael.lena...@gmail.com>
Subject Re: georss atom feed
Date Tue, 28 Sep 2010 14:45:23 GMT
Dear all

I have completed the MSc project I've been working on during the summer.

It examines how to use CouchDB to output GeoRSS documents, and is pitched at
a fairly introductory level.

I hope some of you find it useful - here it is: http://klena02.wordpress.com
.

Best wishes

Michael
http://uk.linkedin.com/pub/michael-lenahan/25/533/a3b


On 24 July 2010 21:07, Michael Lenahan <michael.lenahan@gmail.com> wrote:

> 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 <michael.lenahan@gmail.com> 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 <jchris@gmail.com> 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=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
> >>>
> >>
> >> 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
> pushing 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 = function(data) {
> >>>  //
> >>>  //var f = <feed xmlns="http://www.w3.org/2005/Atom"/>;
> >>>  var f = <feed xmlns="http://www.w3.org/2005/Atom"
> >>> 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/>;
> >>>  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 = <author><name>{data.author}</name></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 "</feed>";
> >>>  });
> >>> };
> >>>
> >>> (I also made the following rudimentary changes to templates/edit.html)
> >>>
> >>>    <!-- form to create a post -->
> >>>    <form id="new-post" action="new.html" method="post">
> >>>      <h1>{{pageTitle}}</h1>
> >>>        <!-- amended for geosofa -->
> >>>        <p><label>Place Name</label>
> >>>          <input type="text" size="50" name="title" value=""></p>
> >>>        <p><label>Latitude</label>
> >>>          <input type="text" size="50" name="latitude" value=""></p>
> >>>        <p><label>Longitude</label>
> >>>          <input type="text" size="50" name="longitude" value=""></p>
> >>>        <!-- -->
> >>>
> >>> 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 <jchris@couch.io> 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
> >>>>
> >>>>
> >>
> >>
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message