incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark J. Reed" <markjr...@gmail.com>
Subject Re: georss atom feed
Date Fri, 23 Jul 2010 22:40:51 GMT
In JavaScript, foo.bar is just shorthand for foo['bar'].  You can only
use the dot syntax for keys that are simple identifiers known at
compile time,but you can use the bracket syntax with any string
expression.  So entry['georss::point'] works for cases where you need
such a key.

On Friday, July 23, 2010, Andy Ennamorato <virtualandy@gmail.com> wrote:
> 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 <michael.lenahan@gmail.com> wrote:
>
>
> (Resending because I forgot to add a section I amended in templates/edit.html)
>
>
> ---------- Forwarded message ----------
> From: Michael Lenahan <michael.lenahan@gmail.com>
> 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://mick.couchone.com/blog/_design/geosofa/_list/index/recent-posts?descending=true&limit=10&format=atom
>
> 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>
>        <!-- -->
>
> (... 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 <jchris@couch.io> wrote:
>
>
> On Jul 22, 2010, at 1:27 PM, Mich
>

-- 
Mark J. Reed <markjreed@gmail.com>

Mime
View raw message