mirror of
https://github.com/wahyd4/sohub.git
synced 2026-08-09 04:56:09 +10:00
add google calendar support,half of the functionalities has been done
This commit is contained in:
@@ -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){
|
||||
|
||||
@@ -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);
|
||||
|
||||
});
|
||||
@@ -69,6 +69,10 @@ module.exports.routes = {
|
||||
'get /auth/google': {
|
||||
controller: 'auth',
|
||||
action: 'auth'
|
||||
},
|
||||
'get /calendar': {
|
||||
controller: 'calendar',
|
||||
action: 'index'
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,4 +15,6 @@
|
||||
</ul>
|
||||
<ul class="content weibo-content" style="display:none;">
|
||||
</ul>
|
||||
<ul class="content calendar-content" style="display:none;">
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user