Permalink
Browse files

Fetch atom feed from friends.

Signed-off-by: François de Metz <fdemetz@af83.com>
  • Loading branch information...
1 parent beb5538 commit fc05935f4cfb87153fcab9796642fdcd8c995cf7 @francois2metz francois2metz committed Apr 15, 2011
Showing with 27 additions and 1 deletion.
  1. +24 −1 server.js
  2. +3 −0 views/home.jade
View
@@ -57,7 +57,16 @@ var app = express.createServer(
app.set('view engine', 'jade');
app.get('/', function(req, res) {
- res.render('home', {user: req.session.user});
+ if (req.session.user) {
+ console.log(req.session.token);
+ getAtomLinks(req.session.token, function(err, atom) {
+ res.render('home', {user: req.session.user,
+ atom: atom});
+ });
+ } else {
+ res.render('home', {user: req.session.user,
+ atom: {items:[]}});
+ }
});
app.post('/user/login', function(req, res) {
@@ -90,3 +99,17 @@ function getOAuth2Endpoint(id, callback) {
return callback('no link found');
});
}
+
+function getAtomLinks(token, callback) {
+ request.get({uri: 'https://auth.af83.com/portable_contacts/@me/@all',
+ headers: {"Authorization" : "OAuth "+ token}},
+ function(err, response, body) {
+ console.log(body);
+ var contacts = JSON.parse(body);
+ contacts.entry.forEach(function(contact) {
+ if (Array.isArray(contact.rss)) {
+ ostatus.as.fromUrl(contact.rss[0].value, callback);
+ }
+ });
+ });
+}
View
@@ -1 +1,4 @@
h1 Turbulence demo
+ul
+- each val in atom.items
+ li #{val.title}

0 comments on commit fc05935

Please sign in to comment.