Toggle navigation
Toggle navigation
This project
Loading...
Sign in
유희정
/
Reminder-Talk
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
유희정
2019-12-04 15:37:12 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c2639dba445259ca807ee3a4bb2431c6059dc88b
c2639dba
1 parent
a5a9c285
change color
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
62 additions
and
69 deletions
app.js
routes/calendar.js
routes/events.js
routes/index.js
routes/login.js
views/calendar.ejs
views/events.ejs
views/index.ejs
app.js
View file @
c2639db
...
...
@@ -9,7 +9,6 @@ var index = require('./routes/index');
var
users
=
require
(
'./routes/users'
);
var
calendar
=
require
(
'./routes/calendar'
);
var
events
=
require
(
'./routes/events'
);
var
login
=
require
(
'./routes/login'
)
passport
.
serializeUser
(
function
(
user
,
done
)
{
console
.
log
(
'serialized'
);
...
...
@@ -45,7 +44,6 @@ app.use('/', index);
app
.
use
(
'/users'
,
users
);
app
.
use
(
'/calendar'
,
calendar
);
app
.
use
(
'/events'
,
events
);
app
.
use
(
'/login'
,
login
);
// catch 404 and forward to error handler
app
.
use
(
function
(
req
,
res
,
next
)
{
...
...
routes/calendar.js
View file @
c2639db
...
...
@@ -6,15 +6,6 @@ router.post('/calendar',function(req,res,next){
var
id
=
req
.
body
.
id
;
res
.
render
(
'calendar'
,{
id
:
id
});
});
//router.get('/',function(req,res,next){
//var accessToken = req.session.access_token;
//gcal(accessToken).calendarList.list(function(err,data){
//if(err) return res.send(err);
//return res.render('calendar',{calendars : data});
//});
//res.render('calendar',{id:1});
console
.
log
(
1
);
//})
calList
=
new
Array
();
...
...
@@ -29,13 +20,10 @@ router.get('/', function(req, res, next) {
if
(
err
)
return
console
.
log
(
err
);
else
{
calList
=
data
.
items
;
//console.log(calList);
res
.
render
(
'calendar'
,{
calList
:
calList
,
googleToken
:
googleToken
,
kakaoToken
:
kakaoToken
});
}
});
});
module
.
exports
=
router
;
//db에서 calendar id에 해당하는 이벤트 출력
\ No newline at end of file
module
.
exports
=
router
;
\ No newline at end of file
...
...
routes/events.js
View file @
c2639db
...
...
@@ -79,8 +79,6 @@ router.post('/add', function(req, res, next) {
router
.
post
(
'/remove'
,
function
(
req
,
res
,
next
)
{
var
eId
=
req
.
body
.
eId
;
console
.
log
(
id
);
console
.
log
(
eId
);
gcal
(
googleToken
).
events
.
delete
(
id
,
eId
,
function
(
err
,
data
)
{
if
(
err
)
return
res
.
send
(
err
);
return
res
.
redirect
(
'/events'
);
...
...
@@ -114,9 +112,7 @@ var timestamp = function (date) {
function
checkEvents
(){
var
nDate
=
new
Date
();
console
.
log
(
nDate
);
for
(
var
i
=
0
;
i
<
events
.
length
;
i
++
){
console
.
log
(
events
[
i
].
start
.
dateTime
)
var
time
=
events
[
i
].
start
.
dateTime
.
split
(
/
[
-:+T
]
/
);
var
tDate
=
new
Date
(
time
[
0
],
time
[
1
]
-
1
,
time
[
2
],
time
[
3
],
time
[
4
],
time
[
5
]);
if
(
nDate
.
getFullYear
()
==
tDate
.
getFullYear
()
&&
nDate
.
getMonth
()
==
tDate
.
getMonth
()
&&
nDate
.
getDate
()
==
tDate
.
getDate
()){
...
...
@@ -135,12 +131,10 @@ var timestamp = function (date) {
};
function
sendMessage
(
event
,
minute
){
console
.
log
(
event
);
console
.
log
(
minute
);
let
template_objectObj
=
{
"object_type"
:
'text'
,
"text"
:
"
Reminder Talk\n"
+
event
.
summary
+
"\n"
+
event
.
start
.
dateTime
+
" ~
"
+
event
.
end
.
dateTime
+
"\n일정시작까지 "
+
minute
+
"분 남았습니다!"
,
"text"
:
"
[Reminder Talk]\n"
+
"일정 : "
+
event
.
summary
+
"\n시작 : "
+
event
.
start
.
dateTime
+
"\n종료 :
"
+
event
.
end
.
dateTime
+
"\n일정시작까지 "
+
minute
+
"분 남았습니다!"
,
"link"
:{
"web_url"
:
'https://developers.kakao.com'
,
"mobile_web_url"
:
'https://developers.kakao.com'
,
...
...
@@ -175,6 +169,4 @@ var timestamp = function (date) {
setInterval
(
checkEvents
,
5
*
60
*
1000
);
//5분에 한 번 수행
module
.
exports
=
router
;
//timestamp(new Date(1983, 4, 9, 11, 5, 17));
\ No newline at end of file
module
.
exports
=
router
;
\ No newline at end of file
...
...
routes/index.js
View file @
c2639db
...
...
@@ -3,8 +3,8 @@ var router = express.Router();
const
KakaoStrategy
=
require
(
"passport-kakao"
).
Strategy
;
var
passport
=
require
(
'passport'
);
var
GoogleStrategy
=
require
(
'passport-google-oauth'
).
OAuth2Strategy
;
var
googleLogin
=
false
;
var
kakaoLogin
=
false
;
//구글 로그인
passport
.
use
(
new
GoogleStrategy
({
clientID
:
'978869138601-u3euf0c04sbdor68r30m599gilvjn91e.apps.googleusercontent.com'
,
clientSecret
:
'9ERYhDZJK-CrX3moES2z11ol'
,
...
...
@@ -23,11 +23,11 @@ router.get('/auth/google/callback',passport.authenticate('google',{
failureRedirect
:
'/'
}),
function
(
req
,
res
)
{
req
.
session
.
googleToken
=
req
.
user
.
accessToken
;
googleLogin
=
true
;
if
(
!
req
.
session
.
kakaoToken
)
return
res
.
redirect
(
'/'
);
else
return
res
.
redirect
(
'/calendar'
);
});
//카카오 로그인
const
kakaoKey
=
{
clientID
:
"cf6ae2286a1b022bafa454588f32878b"
,
callbackURL
:
"/oauth/callback"
...
...
@@ -36,7 +36,6 @@ const kakaoKey = {
passport
.
use
(
"kakao-login"
,
new
KakaoStrategy
(
kakaoKey
,
(
accessToken
,
refreshToken
,
profile
,
done
)
=>
{
console
.
log
(
profile
);
profile
.
accessToken
=
accessToken
;
return
done
(
null
,
profile
);
})
...
...
@@ -46,25 +45,20 @@ router.get(
"/oauth/callback"
,
passport
.
authenticate
(
"kakao-login"
,{
failureRedirect
:
'/'
}),
function
(
req
,
res
)
{
req
.
session
.
kakaoToken
=
req
.
user
.
accessToken
;
kakaoLogin
=
true
;
if
(
!
req
.
session
.
googleToken
)
return
res
.
redirect
(
'/'
);
else
return
res
.
redirect
(
'/calendar'
);
});
router
.
get
(
'/'
,
function
(
req
,
res
,
next
){
res
.
render
(
'index'
,{
title
:
'Reminder-Talk'
,
google
:
googleLogin
,
kakao
:
kakaoLogin
});
res
.
render
(
'index'
,{
title
:
'Reminder-Talk'
});
});
router
.
get
(
'/logout'
,
function
(
req
,
res
)
{
req
.
logout
();
console
.
log
(
req
.
session
);
req
.
session
=
null
;
res
.
redirect
(
'/'
);
});
module
.
exports
=
router
;
//db에 id 별 이벤트 저장하고 calendar page 에서 출력해주자!
//문제점 : 비동기식 진행이어서 getAllcalendarID 함수 실행 후 바로 list 출력 안됨. console.log 먼저 출력됨
...
...
routes/login.js
deleted
100644 → 0
View file @
a5a9c28
var
express
=
require
(
'express'
);
var
router
=
express
.
Router
();
/* GET users listing. */
router
.
get
(
'/'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
"accepted"
);
});
module
.
exports
=
router
;
views/calendar.ejs
View file @
c2639db
...
...
@@ -2,20 +2,41 @@
<html>
<head>
<link
rel=
'stylesheet'
href=
'/stylesheets/style.css'
/>
<link
rel=
"stylesheet"
href=
"https://fonts.googleapis.com/css?family=Jua|Nanum+Brush+Script|Yeon+Sung&display=swap&subset=korean"
>
<style>
#d
{
background-color
:
none
;
border
:
1px
solid
#772f9c
;
line-height
:
1
;
font-size
:
17px
;
width
:
65%
;
padding
:
10px
15px
;
display
:
block
;
box-sizing
:
border-box
;
border-radius
:
60px
;
color
:
#772f9c
;
font-weight
:
100
;
letter-spacing
:
0.01em
;
position
:
relative
;
z-index
:
1
;
margin-left
:
100px
;
}
}
</style>
<ul><p><a
href=
"/logout"
><font
size=
"4"
>
Logout
</font></a></p></ul>
</head>
<body
bgcolor=
"
#ff4a56
"
>
<body
bgcolor=
"
e7ded9
"
>
<center>
<br>
<h1>
Calendar ID Lists
</h1>
<p>
<form
action=
"/events"
method=
"POST"
>
<input
type=
hidden
name=
"googleToken"
value=
<%=
googleToken
%
>
>
<input
id=
'd'
type=
hidden
name=
"googleToken"
value=
<%=
googleToken
%
>
>
<br><br>
<input
type=
hidden
name=
"kakaoToken"
value=
<%=
kakaoToken
%
>
>
<input
id=
'd'
type=
hidden
name=
"kakaoToken"
value=
<%=
kakaoToken
%
>
>
<br><br>
<
% calList.forEach(function(val){ %>
<input
type=
submit
name=
"id"
value=
<%=
val
.
id
%
>
>
<input
id=
'd'
type=
submit
name=
"id"
value=
<%=
val
.
id
%
>
>
<br><br>
<
% }) %>
</form>
...
...
views/events.ejs
View file @
c2639db
...
...
@@ -3,6 +3,7 @@
<head>
<link
rel=
'stylesheet'
href=
'/stylesheets/style.css'
/>
<link
rel=
"stylesheet"
href=
"https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"
/>
<link
rel=
"stylesheet"
href=
"https://fonts.googleapis.com/css?family=Jua|Nanum+Brush+Script|Yeon+Sung&display=swap&subset=korean"
>
<style>
/* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */
.transition
,
form
button
,
form
.question
label
,
form
.question
input
[
type
=
"text"
]
{
...
...
@@ -13,17 +14,17 @@
}
*
{
font-family
:
Helvetica
,
sans-serif
;
font-weight
:
light
;
-webkit-font-smoothing
:
antialiased
;
}
html
{
background-color
:
#
ff4a56
;
background-color
:
#
e7ded9
;
}
h
2
{
h
1
{
margin-left
:
20px
;
font-family
:
'Jua'
,
sans-serif
;
}
form
{
...
...
@@ -31,8 +32,9 @@ form {
display
:
inline-block
;
max-width
:
300
x
;
box-sizing
:
border-box
;
padding
:
30px
25
px
;
padding
:
20px
20
px
;
background-color
:
white
;
border
:
2px
solid
#772f9c
;
border-radius
:
40px
;
left
:
30%
;
margin
:
50px
;
...
...
@@ -40,34 +42,37 @@ form {
-ms-transform
:
translate
(
-50%
,
0
);
-webkit-transform
:
translate
(
-50%
,
0
);
transform
:
translate
(
-50%
,
0
);
font-family
:
'Yeon Sung'
,
cursive
;
}
form
h
1
{
color
:
#
ff4a56
;
form
h
2
{
color
:
#
772f9c
;
font-weight
:
100
;
letter-spacing
:
0.01em
;
margin-left
:
15px
;
margin-bottom
:
35px
;
text-transform
:
uppercase
;
font-family
:
'Jua'
,
sans-serif
;
}
form
button
{
margin-top
:
35px
;
background-color
:
white
;
border
:
1px
solid
#
ff4a56
;
border
:
1px
solid
#
772f9c
;
line-height
:
0
;
font-size
:
17px
;
display
:
inline-block
;
box-sizing
:
border-box
;
padding
:
20px
15px
;
border-radius
:
60px
;
color
:
#
ff4a56
;
color
:
#
772f9c
;
font-weight
:
100
;
letter-spacing
:
0.01em
;
position
:
relative
;
z-index
:
1
;
align-self
:
flex-end
;
}
form
button
:hover
,
form
button
:focus
{
color
:
white
;
background-color
:
#
ff4a56
;
background-color
:
#
772f9c
;
}
form
.question
{
position
:
relative
;
...
...
@@ -81,7 +86,7 @@ form .question:last-of-type {
}
form
.question
label
{
transform-origin
:
left
center
;
color
:
#
ff4a56
;
color
:
#
772f9c
;
font-weight
:
100
;
letter-spacing
:
0.01em
;
font-size
:
17px
;
...
...
@@ -96,7 +101,7 @@ form .question label {
form
.question
input
[
type
=
"text"
]
{
appearance
:
none
;
background-color
:
none
;
border
:
1px
solid
#
ff4a56
;
border
:
1px
solid
#
772f9c
;
line-height
:
0
;
font-size
:
17px
;
width
:
100%
;
...
...
@@ -104,7 +109,7 @@ form .question input[type="text"] {
box-sizing
:
border-box
;
padding
:
10px
15px
;
border-radius
:
60px
;
color
:
#
ff4a56
;
color
:
#
772f9c
;
font-weight
:
100
;
letter-spacing
:
0.01em
;
position
:
relative
;
...
...
@@ -112,7 +117,7 @@ form .question input[type="text"] {
}
form
.question
input
[
type
=
"text"
]
:focus
{
outline
:
none
;
background
:
#
ff4a56
;
background
:
#
772f9c
;
color
:
white
;
margin-top
:
30px
;
}
...
...
@@ -152,7 +157,7 @@ form .question input[type="text"]:valid ~ label {
}
#ls
{
transform-origin
:
left
center
;
color
:
#
ff4a56
;
color
:
#
772f9c
;
font-weight
:
100
;
letter-spacing
:
0.01em
;
font-size
:
17px
;
...
...
@@ -165,15 +170,15 @@ form .question input[type="text"]:valid ~ label {
}
#d
{
background-color
:
none
;
border
:
1px
solid
#
ff4a56
;
border
:
1px
solid
#
772f9c
;
line-height
:
1
;
font-size
:
17px
;
width
:
70
%
;
width
:
65
%
;
padding
:
10px
15px
;
display
:
block
;
box-sizing
:
border-box
;
border-radius
:
60px
;
color
:
#
ff4a56
;
color
:
#
772f9c
;
font-weight
:
100
;
letter-spacing
:
0.01em
;
position
:
relative
;
...
...
@@ -183,17 +188,21 @@ form .question input[type="text"]:valid ~ label {
#pad
{
padding
:
10px
0
;
}
#title
{
color
:
#772f9c
;
}
</style>
</head>
<body>
<div
id=
"div_root"
>
<div
id=
"div_top"
>
<h1>
Calendar ID :
<
%= id %>
</h1>
<h1
id=
'title'
>
Calendar ID :
<
%= id %>
</h1>
</div>
<div
id=
"div_center"
>
<
% calendars.forEach(function(val){ %>
<form
action=
"/events/remove"
method=
"POST"
>
<p
style=
"font-size:17px"
>
일정
</p>
<p>
summary :
<
%= val.summary %>
</p>
<p>
created :
<
%= val.created %>
</p>
<p>
start :
<
%= val.start.dateTime %>
</p>
...
...
views/index.ejs
View file @
c2639db
<!DOCTYPE html>
<html>
<head>
<
br><br><br><br><br><br
>
<
link
rel=
"stylesheet"
href=
"https://fonts.googleapis.com/css?family=Jua|Nanum+Brush+Script|Yeon+Sung&display=swap&subset=korean"
>
<title>
<
%= title %>
</title>
<link
rel=
'stylesheet'
href=
'/stylesheets/style.css'
/>
</head>
<body
bgcolor=
"#
ff4a56
"
>
<body
bgcolor=
"#
e7ded9
"
>
<div
id=
"container"
>
<center>
<div
id=
'item1'
><p><font
size=
"7"
>
...
...
Please
register
or
login
to post a comment