-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Mongoose, Socket.io, Login with Twitter, and Twitter Stream API
- Loading branch information
Showing
8 changed files
with
192 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var baudio = require('baudio'); | ||
|
||
var n = 0; | ||
var b = baudio(function (t) { | ||
var x = Math.sin(t * 262 + Math.sin(n)); | ||
n += Math.sin(t); | ||
return x; | ||
}); | ||
b.play(); |
Submodule violent-theremin
added at
c9e406
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,12 @@ | ||
/** | ||
* Change configuration here.duh. | ||
*/ | ||
module.exports = { | ||
consumer_key: 'twitter_consumer_key', | ||
consumer_secret: 'twitter_consumer_secret', | ||
ac_key:'twitter_access_token_key', | ||
ac_secret:'twitter_access_token_secret', | ||
cb_url:'twitter_callback_url', | ||
db:'mongodb://localhost/dbname', | ||
session_secret:'session_secret' | ||
} |
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,47 @@ | ||
/** | ||
* Conroller module: Logins with passport Twitter and stores new user. | ||
*/ | ||
|
||
var mongoose = require('mongoose'); | ||
var passport = require('passport'); | ||
var TwitterStrategy = require('passport-twitter').Strategy; | ||
var mode = require('./model'); | ||
var config = require('./config'); | ||
|
||
User = mongoose.model('User'); | ||
|
||
var User = mongoose.model('User'); | ||
|
||
passport.use(new TwitterStrategy({ | ||
consumerKey: config.consumer_key, | ||
consumerSecret: config.consumer_secret, | ||
callbackURL: config.cb_url | ||
}, | ||
function(token, tokenSecret, profile, done) { | ||
User.findOne({uid: profile.id}, function(err, user) { | ||
if(user) { | ||
done(null, user); | ||
} else { | ||
var user = new User(); | ||
user.provider = "twitter"; | ||
user.uid = profile.id; | ||
user.name = profile.displayName; | ||
user.image = profile._json.profile_image_url; | ||
user.save(function(err) { | ||
if(err) { throw err; } | ||
done(null, user); | ||
}); | ||
} | ||
}) | ||
} | ||
)); | ||
|
||
passport.serializeUser(function(user, done) { | ||
done(null, user.uid); | ||
}); | ||
|
||
passport.deserializeUser(function(uid, done) { | ||
User.findOne({uid: uid}, function (err, user) { | ||
done(err, user); | ||
}); | ||
}); |
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 @@ | ||
/** | ||
* Model Module: Mongoose: MongoDB ODM. | ||
*/ | ||
|
||
var mongoose = require('mongoose'); | ||
var Schema = mongoose.Schema; | ||
|
||
var UserSchema = new Schema({ | ||
provider: String, | ||
uid: String, | ||
name: String, | ||
image: String, | ||
created: {type: Date, default: Date.now} | ||
}); | ||
|
||
|
||
mongoose.model('User',UserSchema); |
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 |
---|---|---|
@@ -1,8 +1,32 @@ | ||
|
||
/* | ||
* GET home page. | ||
* Das Routes. | ||
*/ | ||
|
||
exports.index = function(req, res){ | ||
res.render('index', { title: 'MMODM' }); | ||
res.render('index', { title: 'MMODM', user: req.user }); | ||
}; | ||
|
||
exports.logout = function(req, res){ | ||
req.logout(); | ||
res.redirect('/'); | ||
} | ||
|
||
exports.auth_cb = function(req, res) { | ||
res.redirect('/'); | ||
} | ||
|
||
exports.auth = function(req, res){ | ||
// The request will be redirected to Twitter for authentication, so this | ||
// function will not be called. | ||
} | ||
|
||
exports.tweet = function(req, res){ | ||
twit.verifyCredentials(function (err, data) { | ||
}) | ||
.updateStatus("#"+req.params.msg+" "+ new Date().getTime(), | ||
function (err, data) { | ||
res.send(200); | ||
} | ||
); | ||
} |