Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular and Playlists only (resolved) #52

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c09065a
Add a bunch of comments for better documentation
unusualbob Jul 19, 2013
9675775
Convert basically everything to angular
unusualbob Jul 21, 2013
147e1a8
Fix render bug on chrome due to initial values being blank
unusualbob Jul 21, 2013
549fa57
Move youtube logic into angular logic, swap for the iframe version wh…
unusualbob Jul 22, 2013
b2caeed
Merge branch 'master' of https://github.com/martindale/soundtrack.io …
unusualbob Jul 22, 2013
1343f06
Make users list bold the current curator
unusualbob Jul 22, 2013
5b8ae26
Merge branch 'master' of https://github.com/martindale/soundtrack.io …
unusualbob Jul 22, 2013
653e220
Merge branch 'master' of https://github.com/martindale/soundtrack.io …
unusualbob Jul 22, 2013
ef18d35
Fix curator display bug, cleanup and comment all angular
unusualbob Jul 22, 2013
f8bb3ef
Merge branch 'master' of https://github.com/martindale/soundtrack.io …
unusualbob Jul 22, 2013
25d4fc0
cleanup unecessary youtube listeners, prevent video from pausing
unusualbob Jul 23, 2013
c22565c
cleaner logs, no youtube annotations
unusualbob Jul 23, 2013
a63bf18
Merge branch 'master' of https://github.com/martindale/soundtrack.io …
unusualbob Jul 23, 2013
9b40969
Refactor soundtrack into separate controllers, add playlist functiona…
unusualbob Jul 23, 2013
f60b31a
Merge branch 'master' of https://github.com/martindale/soundtrack.io …
unusualbob Jul 23, 2013
f24b844
Allow for playlist creation via angular, fix artist display bug, remo…
unusualbob Jul 23, 2013
ffccc6e
Add basic socket listener API
unusualbob Jul 24, 2013
95a9c60
Merge branch 'master' of https://github.com/martindale/soundtrack.io …
unusualbob Jul 24, 2013
0a808b4
Increase documentation, handle incomming chat in angular, beep for me…
unusualbob Jul 25, 2013
36b1440
Merge branch 'master' of https://github.com/martindale/soundtrack.io …
unusualbob Jul 25, 2013
514fcd6
Merge branch 'angular-chat' into angular-merge
unusualbob Jul 25, 2013
e1ef2f2
Reorganize a few controls into a new MainController, chat mention bee…
unusualbob Jul 25, 2013
db3cd94
convert a few logs to use debug check
unusualbob Jul 25, 2013
dc87584
Fix opera render bug, fix visual playlist bug if user has no playlists
unusualbob Jul 25, 2013
7b79297
Add support for skip messages
unusualbob Jul 25, 2013
477daa1
update script tag for new jade format, tweak chat scroll timing
unusualbob Jul 25, 2013
0917f49
remove iframe player
unusualbob Jul 26, 2013
a006641
remove mention beeps, chat link target, settings panel
unusualbob Jul 26, 2013
c75a5ca
Merge branch 'master' of github.com:martindale/soundtrack.io into HEAD
unusualbob Aug 2, 2013
0b5a35d
Include initial page view data inside index to reduce requests
unusualbob Aug 3, 2013
aed1e37
Merge branch 'master' of github.com:martindale/soundtrack.io into ang…
unusualbob Aug 3, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions controllers/pages.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
var async = require('async');

module.exports = {
index: function(req, res, next) {
Chat.find({}).limit(10).sort('-created').populate('_author').exec(function(err, messages) {
Chat.find({}).lean().limit(20).sort('-created').populate('_author', {hash: 0, salt:0}).exec(function(err, messages) {
Playlist.find({ _creator: ((req.user) ? req.user._id : undefined) }).sort('name').exec(function(err, playlists) {

if (err) { console.log(err); }
console.log(playlists);

res.render('index', {
messages: messages.reverse()
, backup: []
, playlists: playlists
, room: req.app.room
// Render messages
async.map(messages, function(message, callback) {
res.render('partials/message', {
message: message.message
}, function(err, html) {
message.formatted = html;
callback(err, message);
});
}, function(err, chats) {;
res.render('index', {
messages: messages.reverse()
, backup: []
, playlists: playlists
, room: req.app.room
, chats: chats
});
});

});

});
Expand Down
30 changes: 29 additions & 1 deletion controllers/playlists.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var _ = require('underscore')
, async = require('async');

module.exports = {
view: function(req, res, next) {
Expand Down Expand Up @@ -41,12 +42,16 @@ module.exports = {
});
},
create: function(req, res, next) {

var playlist = new Playlist({
name: req.param('name')
, description: req.param('description')
, _creator: req.user._id
, public: (req.param('public') == 'true') ? true : false
});

// Search for the trackID, if not found proceed to next route
// otherwise create the playlist
Track.findOne({ _id: req.param('trackID') }).exec(function(err, track) {
if (!track) { return next(); }

Expand All @@ -58,6 +63,7 @@ module.exports = {
, results: {
_id: playlist._id
, name: playlist.name
, description: playlist.description
, tracks: [ track ]
}
});
Expand Down Expand Up @@ -109,5 +115,27 @@ module.exports = {
});

});
}
},
getPlaylists: function(req, res, next) {
Playlist.find({ _creator: req.user._id }).lean().exec(function(err, playlists) {
if (!playlists.length) { return next(); }

async.map(playlists, function(playlist, callback) {
Track.find({ _id: {$in : playlist._tracks }}).populate('_artist').exec(function(err, tracks) {
playlist._tracks = tracks;
callback(err, playlist);
});
}
, function(err, results) {
console.log(playlists);
res.send({
status: 'success'
, results: {
playlists: results
}
});
});

});
},
};
Loading