-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from nus-mtp/develop
Merge develop to master for Sprint 2 release
- Loading branch information
Showing
50 changed files
with
1,874 additions
and
404 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* PageController | ||
* | ||
* @description :: Server-side logic for managing pages | ||
* @help :: See http://links.sailsjs.org/docs/controllers | ||
* https://github.com/irlnathan/activityoverlord20/blob/master/api/controllers/PageController.js | ||
*/ | ||
|
||
module.exports = { | ||
|
||
showHomePage: function (req, res) { | ||
|
||
// If not logged in, show the public view. | ||
if (!req.session.me) { | ||
//return res.view('homepage'); | ||
return res.view('homepage', { | ||
me: [], | ||
video: [] | ||
}); | ||
} | ||
|
||
// Otherwise, look up the logged-in user and show the logged-in view, | ||
// bootstrapping basic user data in the HTML sent from the server | ||
User.findOne(req.session.me, function (err, user){ | ||
if (err) { | ||
return res.negotiate(err); | ||
} | ||
|
||
if (!user) { | ||
sails.log.verbose('Session refers to a user who no longer exists- did you delete a user, then try to refresh the page with an open tab logged-in as that user?'); | ||
//return res.view('homepage'); | ||
return res.view('homepage', { | ||
me: [], | ||
video: [] | ||
}); | ||
} | ||
|
||
return res.view('dashboard', { | ||
me: user, | ||
video: [] | ||
}); | ||
|
||
}); | ||
}, | ||
|
||
showEditPage: function (req, res) { | ||
|
||
// If not logged in, show the public view. | ||
if (!req.session.me) { | ||
return res.view('homepage'); | ||
} | ||
|
||
// Otherwise, look up the logged-in user and show the logged-in view, | ||
// bootstrapping basic user data in the HTML sent from the server | ||
User.findOne(req.session.me, function (err, user){ | ||
if (err) { | ||
return res.negotiate(err); | ||
} | ||
|
||
if (!user) { | ||
sails.log.verbose('Session refers to a user who no longer exists- did you delete a user, then try to refresh the page with an open tab logged-in as that user?'); | ||
return res.view('homepage', { | ||
me: [], | ||
video: [] | ||
}); | ||
} | ||
|
||
// retreive the video object using the id | ||
Video.findOne(req.param('id'), function(err, video){ | ||
if (err) { | ||
// return error | ||
} | ||
|
||
// if successful, return user and video object to frontend | ||
return res.view('edit', { | ||
me: user, | ||
video: video | ||
}); | ||
|
||
}); | ||
}); | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Usage: | ||
* res.backToHomePage(); // (default to 200 "OK" status code) | ||
* res.backToHomePage(400); | ||
* | ||
*/ | ||
|
||
module.exports = function backToHomePage (statusCode){ | ||
|
||
// Get access to `req` and `res` | ||
// (since the arguments are up to us) | ||
var req = this.req; | ||
var res = this.res; | ||
|
||
// All done- either send back an empty response w/ just the status code | ||
// (e.g. for AJAX requests) | ||
if (req.wantsJSON) { | ||
return res.send(statusCode||200); | ||
} | ||
// or redirect to the home page | ||
return res.redirect('/'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* 409 (Conflict) Handler | ||
* | ||
* Usage: | ||
* res.emailAddressInUse(); | ||
* | ||
* @reference: https://github.com/irlnathan/activityoverlord20/blob/master/api/responses/emailAddressInUse.js | ||
*/ | ||
|
||
module.exports = function emailAddressInUse (){ | ||
|
||
// Get access to `res` | ||
// (since the arguments are up to us) | ||
var res = this.res; | ||
|
||
return res.send(409, 'Email address is already taken by another user.'); | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.