Permalink
Browse files

fix bug with artist name not being displayed always, beginning social…

… side
  • Loading branch information...
1 parent f0c05e6 commit 2583aeee8b0437b2d4e4931734118e0a3558004c Keith Norman committed Feb 19, 2012
Showing with 85 additions and 5 deletions.
  1. +17 −3 app.js
  2. +11 −0 app/views/friends.html
  3. +1 −1 app/views/search.html
  4. +7 −0 app/views/user.html
  5. +4 −0 public/css/base.css
  6. +45 −1 public/js/application.js
View
@@ -8,9 +8,6 @@ var express = require('express')
, _ = require('underscore')
, querystring = require('querystring')
, fileify = require('fileify');
-
-var token = 'rkwa3zkamu9h9mfep7uk6mem87mmd2bxzjxhr9xdskh9p7hchm8ad8feddhmch9j';
-var secret = 'PPjCSNFSkKru';
var app = express.createServer();
var AppConfig = {};
@@ -244,6 +241,23 @@ app.get('/users/:id', function(req, res) {
);
});
+app.get('/users/:id/friends', function(req, res) {
+ rdio.api(
+ req.session.oauth_access_token,
+ req.session.oauth_access_token_secret,
+ {
+ method: 'userFollowing',
+ user: req.params.id,
+ type: 'albums',
+ limit: 24,
+ extras: 'lastSongPlayed, lastSongPlayTime, username'
+ },
+ function(err, data, response) {
+ res.send(JSON.parse(data).result);
+ }
+ );
+});
+
var port = process.env.PORT || 3090;
app.listen(port, function() {
console.log("Listening on " + port);
@@ -0,0 +1,11 @@
+<ul class='friends'>
+ {{# friends }}
+ <li>
+ <img src='{{ get "icon" }}'>
+ <h1>{{ get "username" }}</h1>
+ </li>
+ {{/ friends }}
+</ul>
+
+
+
@@ -28,7 +28,7 @@
<li>
<a class='play btn' data-track='{{ json toJSON }}'>
<h2>{{ get "name" }}</h2>
- <h3>By: {{ get "albumArtist" }}</h3>
+ <h3>By: {{ get "artist" }}</h3>
</a>
</li>
{{/ tracks }}
View
@@ -1,3 +1,10 @@
<div class='user_info'>
<h1>Hi, {{ get "firstName" }} {{ get "lastName" }}</h1>
+ <nav>
+ <ul class='user_nav'>
+ <li>
+ <a href='#users/{{ get "key" }}/friends'>Friends</a>
+ </li>
+ </ul>
+ </nav>
</div>
View
@@ -43,6 +43,10 @@ header .container_12 {
font-size: 14px;
}
+.user_nav {
+ display: none;
+}
+
.auth {
background: url('/images/connect.png') no-repeat center;
display: block;
@@ -31,7 +31,8 @@ App.Router = Backbone.Router.extend({
'': 'root',
'search/:query': 'search',
'profile': 'profile',
- 'albums/:id': 'album'
+ 'albums/:id': 'album',
+ 'users/:id/friends': 'friends'
},
root: function() {
@@ -77,6 +78,19 @@ App.Router = Backbone.Router.extend({
});
},
+ friends: function() {
+ var friends = new App.Friends([], {
+ user: App.currentUser
+ });
+ friends.fetch({
+ success: function(friends, resp) {
+ new App.Views.Friends({
+ friends: friends
+ });
+ }
+ });
+ },
+
_renderUserHeavyRotation: function() {
var albums = new App.UsersHeavyRotation();
albums.fetch({
@@ -143,6 +157,19 @@ App.UsersHeavyRotation = App.Albums.extend({
}
});
+App.Friends = Backbone.Collection.extend({
+ model: App.User,
+
+ url: function() {
+ console.log(this);
+ return '/users/' + this.user.get('key') + '/friends';
+ },
+
+ initialize: function(models, options) {
+ this.user = options.user;
+ }
+});
+
App.Views.Application = Backbone.View.extend({
el: 'body',
userTemplate: Templates['user.html'],
@@ -251,6 +278,23 @@ App.Views.Album = Backbone.View.extend({
}
});
+App.Views.Friends = Backbone.View.extend({
+ el: '#body',
+ template: Templates['friends.html'],
+ initialize: function() {
+ this.friends = this.options.friends.models;
+ this.render();
+ },
+
+ render: function() {
+ console.log(this);
+ var template = Handlebars.compile(this.template);
+ this.$el.html(
+ template(this)
+ );
+ }
+});
+
App.Views.Profile = Backbone.View.extend({
el: '#body',
template: Templates['profile.html'],

0 comments on commit 2583aee

Please sign in to comment.