add google calendar support,half of the functionalities has been done

This commit is contained in:
2013-07-19 00:49:53 +08:00
parent eab89a7062
commit 4971682b67
4 changed files with 35 additions and 6 deletions
+3 -6
View File
@@ -1,11 +1,9 @@
var passport = require('passport');
var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
var gcal = require('google-calendar');
var util = require('util');
passport.use(new GoogleStrategy({
clientID: '553555458366-bl2e989fn88t27recf2cgp74b3ogcdc1.apps.googleusercontent.com',
clientSecret: '8TNPb5ehq-t7g1uiwztaHmC7',
clientID: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
callbackURL: "http://127.0.0.1:1337/auth/google"
},function(accessToken, refreshToken, profile, done) {
@@ -32,8 +30,7 @@ passport.deserializeUser(function (obj, done) {
var AuthController = {
index: passport.authenticate('google', { scope: ['https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/userinfo.email'] }),
index: passport.authenticate('google', { scope: ['openid', 'email', 'https://www.googleapis.com/auth/calendar'] }),
auth: passport.authenticate('google',function(req,res){
+26
View File
@@ -150,4 +150,30 @@ $(document).ready(function () {
});
}, interval * 3 - 1000 * 30);
setTimeout(function () {
$.get('/calendar', function (json) {
console.log(json);
var calendarContainer = $('.calendar-content');
for (var i = 0; i < json.length; i++) {
var item = $('<li style="display: none"></li>');
var footprint = $('<div></div>').addClass('footprint');
footprint.append('<p>'+json[i].location+'</p>');
footprint.append('<div>' + json[i].creator.displayName + '发布于' + timeSince(new Date(json[i].created)) + '</div>');
item.append(footprint);
var content = $('<div class="weibo"> </div>');
// if (json[i].original_pic !== undefined) {
// content.append('<img src="' + json[i].original_pic + '"></img>');
// }
content.append('<p>' + json[i].summary + '</p>');
item.append(content);
calendarContainer.append(item);
}
slideDiv(calendarContainer, textMessageCount);
});
}, interval * 4 - 1000 * 30);
});
+4
View File
@@ -69,6 +69,10 @@ module.exports.routes = {
'get /auth/google': {
controller: 'auth',
action: 'auth'
},
'get /calendar': {
controller: 'calendar',
action: 'index'
}
+2
View File
@@ -15,4 +15,6 @@
</ul>
<ul class="content weibo-content" style="display:none;">
</ul>
<ul class="content calendar-content" style="display:none;">
</ul>
</div>