Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김대철
/
CafeRecommend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김대철
2021-06-07 15:50:17 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
e893491ab51f7277787cc73dd499bcc88066ffdc
e893491a
2 parents
b5cb78d8
55995d87
Merge branch 'detail' of
http://khuhub.khu.ac.kr/2015104153/CafeRecommend
into detail
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
72 additions
and
85 deletions
README.md
routes/index.js
sessions/e7kjBCXJobyGW1wzonYQ38C7nEs40uU6.json
views/index.ejs
views/login.ejs
views/map.ejs
views/review.ejs
README.md
View file @
e893491
...
...
@@ -61,19 +61,24 @@ https://2015104153.oss2021.tk:3000
```
npm install
```
6.
발급받은 구글 로그인 ClientID를
`index.js`
,
`index.ejs`
,
지도 API키를
`map.ejs`
에 각각 넣기
6.
발급받은 구글 로그인 ClientID를
`index.js`
지도 API키를
`map.ejs`
에 각각 넣기
```
var CLIENT_ID = "발급받은 ClientID" // index.js
```
```HTML
<meta name="google-signin-client_id" content="발급받은 ClientID"> // index.ejs
```
```HTML
<script type="text/javascript" src="//dapi.kakao.com/v2/maps/sdk.js?appkey=발급받은API키&libraries=services"></script> // map.ejs
```
7.
MySQL connection 연결 설정 (index.js)
7.
Session File Store 설정 (index.js)
```
session({
secret: "원하는 암호",
resave: false,
saveUninitialized: true,
store: new FileStore(),
})
```
8.
MySQL connection 연결 설정 (index.js)
```
var connection = mysql.createConnection({
host: "IP주소 입력 (localhost 또는 AWS 서버 주소)",
...
...
@@ -82,7 +87,7 @@ https://2015104153.oss2021.tk:3000
database: "스키마이름 입력",
});
```
8
.
프로그램 실행
9
.
프로그램 실행
```
npm run start
```
...
...
routes/index.js
View file @
e893491
...
...
@@ -5,8 +5,8 @@ var bodyParser = require("body-parser");
var
{
OAuth2Client
}
=
require
(
"google-auth-library"
);
var
CLIENT_ID
=
"
94679084723-s5f0686p2porp9mkakrp1p89a48n24nj.apps.googleusercontent.com
"
;
const
CLIENT_ID
=
"
발급받은 ClientID
"
;
var
client
=
new
OAuth2Client
(
CLIENT_ID
);
var
mysql
=
require
(
"mysql"
);
const
session
=
require
(
"express-session"
);
...
...
@@ -16,7 +16,7 @@ router.use(bodyParser.urlencoded({ extended: false })); //url인코딩 x
router
.
use
(
bodyParser
.
json
());
//json방식으로 파싱
router
.
use
(
session
({
secret
:
"
209
"
,
// 암호화
secret
:
"
원하는 암호
"
,
// 암호화
resave
:
false
,
saveUninitialized
:
true
,
store
:
new
FileStore
(),
...
...
@@ -24,22 +24,22 @@ router.use(
);
var
connection
=
mysql
.
createConnection
({
host
:
"
localhost
"
,
user
:
"
root
"
,
password
:
"
g79465
"
,
database
:
"
caferecommend
"
,
host
:
"
IP주소 입력 (localhost 또는 AWS 서버 주소)
"
,
user
:
"
계정 입력
"
,
password
:
"
암호 입력
"
,
database
:
"
스키마이름 입력
"
,
});
connection
.
connect
();
/* GET home page. */
router
.
get
(
"/"
,
function
(
req
,
res
,
next
)
{
res
.
render
(
"index"
,
{
d
:
"94679084723-s5f0686p2porp9mkakrp1p89a48n24nj.apps.googleusercontent.com"
,
client_id
:
CLIENT_ID
,
});
});
router
.
get
(
"/index"
,
function
(
req
,
res
,
next
)
{
res
.
render
(
"index"
,
{
d
:
"94679084723-s5f0686p2porp9mkakrp1p89a48n24nj.apps.googleusercontent.com"
,
client_id
:
CLIENT_ID
,
});
});
...
...
@@ -145,7 +145,9 @@ router.post("/login", (req, res) => {
connection
.
query
(
sql
,
parameter
,
function
(
err
)
{
if
(
err
)
{
console
.
log
(
err
);
return
res
.
render
(
"/"
);
return
res
.
render
(
"/"
,
{
client_id
:
CLIENT_ID
,
});
}
else
{
console
.
log
(
"새로운 user데이터 입력"
);
}
...
...
@@ -162,7 +164,9 @@ router.post("/login", (req, res) => {
connection
.
query
(
sql2
,
parameter2
,
function
(
err
)
{
if
(
err
)
{
console
.
log
(
err
);
return
res
.
render
(
"/"
);
return
res
.
render
(
"/"
,{
client_id
:
CLIENT_ID
,
});
}
else
{
console
.
log
(
"새로운 PREFERENCE데이터 입력"
);
}
...
...
@@ -207,7 +211,9 @@ router.get("/map", function (req, res, next) {
if
(
req
.
session
.
user
)
{
res
.
render
(
"map"
,
{
user
:
req
.
session
.
user
});
}
else
{
res
.
render
(
"/"
);
res
.
render
(
"/"
,{
client_id
:
CLIENT_ID
,
});
}
});
...
...
sessions/e7kjBCXJobyGW1wzonYQ38C7nEs40uU6.json
0 → 100644
View file @
e893491
{
"cookie"
:{
"originalMaxAge"
:
null
,
"expires"
:
null
,
"httpOnly"
:
true
,
"path"
:
"/"
},
"__lastAccess"
:
1622998584246
,
"user"
:{
"email"
:
"cjm104174@gmail.com"
,
"picture"
:
"https://lh3.googleusercontent.com/a-/AOh14Gh3nytGsPbviGhkznR8HIwrL6o7xBIoFL08nIeU=s96-c"
,
"nickname"
:
"Mayf"
,
"age"
:
25
,
"gender"
:
"male"
}}
\ No newline at end of file
views/index.ejs
View file @
e893491
...
...
@@ -3,22 +3,12 @@
<head>
<meta
charset=
"UTF-8"
/>
<script
src=
"https://apis.google.com/js/platform.js"
async
defer
></script>
<meta
name=
"google-signin-client_id"
content=
"94679084723-s5f0686p2porp9mkakrp1p89a48n24nj.apps.googleusercontent.com"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<title>
first
</title>
<link
rel=
"stylesheet"
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css"
integrity=
"undefined"
crossorigin=
"anonymous"
/>
<link
href=
"https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@700&display=swap"
rel=
"stylesheet"
/>
<title>
Cafe Map
</title>
<meta
name=
"google-signin-client_id"
content=
<%=client_id%
>
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<link
rel=
"stylesheet"
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css"
integrity=
"undefined"
crossorigin=
"anonymous"
>
<link
href=
"https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@700&display=swap"
rel=
"stylesheet"
>
<style>
img
{
...
...
@@ -59,9 +49,6 @@
<body>
<nav
class=
"navbar navbar-expand-lg navbar-dark bg-dark"
>
<a
class=
"navbar-brand"
href=
"/"
><img
src=
"images/home.png"
width=
"40"
height=
"40"
alt=
""
/>
</a>
<button
class=
"navbar-toggler"
type=
"button"
...
...
@@ -106,9 +93,26 @@
button
</div>
<br
/><br
/>
</head>
<body>
<nav
class=
"navbar navbar-expand-lg navbar-dark bg-dark"
>
<button
class=
"navbar-toggler"
type=
"button"
data-toggle=
"collapse"
data-target=
"#navbarSupportedContent"
aria-controls=
"navbarSupportedContent"
aria-expanded=
"false"
aria-label=
"Toggle navigation"
>
<span
class=
"navbar-toggler-icon"
></span>
</button>
<div
class=
"collapse navbar-collapse"
id=
"navbarSupportedContent"
>
<a
class=
"navbar-brand"
href=
"/"
style=
"margin-left: 10px"
><strong>
Home
</strong></a>
</div>
</body>
<script
src=
"https://code.jquery.com/jquery-3.1.1.min.js"
></script>
<script
src=
"https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.min.js"
integrity=
"undefined"
crossorigin=
"anonymous"
></script>
<script>
function
onSignIn
(
googleUser
)
{
var
id_token
=
googleUser
.
getAuthResponse
().
id_token
;
...
...
@@ -124,11 +128,11 @@
};
xhr
.
send
(
JSON
.
stringify
({
token
:
id_token
}));
}
</script>
<script
src=
"https://code.jquery.com/jquery-3.1.1.min.js"
></script>
<script
src=
"https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.min.js"
integrity=
"undefined"
crossorigin=
"anonymous"
>
</script>
function
signOut
()
{
var
auth2
=
gapi
.
auth2
.
getAuthInstance
();
auth2
.
signOut
().
then
(
function
()
{
console
.
log
(
"User signed out."
);
});
}
</script>
</html>
...
...
views/login.ejs
View file @
e893491
...
...
@@ -4,7 +4,7 @@
<meta
charset=
"UTF-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<title>
logined
</title>
<title>
Sign Up
</title>
<link
rel=
"stylesheet"
...
...
@@ -37,30 +37,15 @@
h5
{
font-family
:
"Noto Sans KR"
,
sans-serif
;
}
.middle
{
display
:
inline-block
;
vertical-align
:
middle
;
}
</style>
</head>
<body>
<nav
class=
"navbar navbar-expand-lg navbar-dark bg-dark"
>
<a
class=
"navbar-brand"
href=
"/"
><img
src=
"images/home.png"
width=
"40"
height=
"40"
alt=
""
/>
</a>
<button
class=
"navbar-toggler"
type=
"button"
data-toggle=
"collapse"
data-target=
"#navbarSupportedContent"
aria-controls=
"navbarSupportedContent"
aria-expanded=
"false"
aria-label=
"Toggle navigation"
>
<button
class=
"navbar-toggler"
type=
"button"
data-toggle=
"collapse"
data-target=
"#navbarSupportedContent"
aria-controls=
"navbarSupportedContent"
aria-expanded=
"false"
aria-label=
"Toggle navigation"
>
<span
class=
"navbar-toggler-icon"
></span>
</button>
<div
class=
"collapse navbar-collapse"
id=
"navbarSupportedContent"
>
<a
class=
"navbar-brand"
href=
"/"
><strong>
Home
</strong></a>
<a
class=
"navbar-brand"
href=
"/"
style=
"margin-left: 10px"
><strong>
Home
</strong></a>
<ul
class=
"navbar-nav mr-auto mt-2 mt-lg-0"
>
<li
class=
"nav-item active"
>
<a
...
...
views/map.ejs
View file @
e893491
...
...
@@ -9,9 +9,6 @@
/>
<title>
Cafe Map
</title>
<style>
.navbar
{
background-color
:
#1d2124
!important
;
}
.btn-primary
{
color
:
white
!important
;
}
...
...
@@ -103,9 +100,6 @@
</head>
<body>
<nav
class=
"navbar navbar-expand-lg navbar-dark bg-dark"
>
<a
class=
"navbar-brand"
href=
"/"
><img
src=
"images/home.png"
width=
"40"
height=
"40"
alt=
""
/>
</a>
<button
class=
"navbar-toggler"
type=
"button"
...
...
@@ -118,7 +112,7 @@
<span
class=
"navbar-toggler-icon"
></span>
</button>
<div
class=
"collapse navbar-collapse"
id=
"navbarSupportedContent"
>
<a
class=
"navbar-brand"
href=
"/"
><strong>
Home
</strong></a>
<a
class=
"navbar-brand"
href=
"/"
style=
"margin-left: 10px"
><strong>
Home
</strong></a>
<ul
class=
"navbar-nav mr-auto mt-2 mt-lg-0"
>
<li
class=
"nav-item active"
>
<a
...
...
@@ -142,7 +136,7 @@
>
</li>
<li
class=
"nav-item active"
>
<a
class=
"nav-link"
style=
"color: #ffffff"
href=
"
/recommend
"
<a
class=
"nav-link"
style=
"color: #ffffff"
href=
"
javascript:void(0);"
onclick=
"recommend();
"
>
Recommend
<span
class=
"sr-only"
>
(current)
</span>
</a>
...
...
@@ -174,10 +168,7 @@
<p
id=
"recommend"
></p>
</section>
<script
type=
"text/javascript"
src=
"//dapi.kakao.com/v2/maps/sdk.js?appkey=68cbccbcd6f0fef0a213e62ad37393ee&libraries=services"
></script>
<script
type=
"text/javascript"
src=
"//dapi.kakao.com/v2/maps/sdk.js?appkey=발급받은API키&libraries=services"
></script>
<script>
var
lat
=
""
;
var
lon
=
""
;
...
...
@@ -206,6 +197,7 @@
click
=
true
;
removeMarker
();
searchPlaces
();
alert
(
"추천이 활성화 되었습니다."
);
}
}
// 추천 기능 비활성화
else
{
...
...
@@ -214,16 +206,16 @@
click
=
false
;
removeMarker
();
searchPlaces
();
alert
(
"추천이 비활성화 되었습니다."
);
}
},
});
}
// 지도 기본설정
var
mapContainer
=
document
.
getElementById
(
"map"
),
mapOption
=
{
center
:
new
kakao
.
maps
.
LatLng
(
36.2477502
,
127.078164
),
level
:
3
,
level
:
12
,
};
var
map
=
new
kakao
.
maps
.
Map
(
mapContainer
,
mapOption
);
var
ps
=
new
kakao
.
maps
.
services
.
Places
(
map
);
...
...
@@ -376,7 +368,7 @@
' <span class="tel">'
+
place
.
phone
+
"</span>"
+
`<a href="/review/
${
place
.
id
}
"><button>후기 작성</button>`
;
`<a href="/review/
${
place
.
id
}
"><button
type="button" class="btn btn-outline-danger" style="font-size:70%;"
>후기 작성</button>`
;
"</div>"
+
'<div class="after"></div>'
;
contentNode
.
innerHTML
=
content
;
placeOverlay
.
setPosition
(
new
kakao
.
maps
.
LatLng
(
place
.
y
,
place
.
x
));
...
...
views/review.ejs
View file @
e893491
...
...
@@ -33,17 +33,11 @@
h5
{
font-family
:
"Noto Sans KR"
,
sans-serif
;
}
.middle
{
display
:
inline-block
;
vertical-align
:
middle
;
}
</style>
</head>
<body>
<nav
class=
"navbar navbar-expand-lg navbar-dark bg-dark"
>
<a
class=
"navbar-brand"
href=
"/"
><img
src=
"/images/home.png"
width=
"40"
height=
"40"
alt=
""
/>
</a>
<button
class=
"navbar-toggler"
type=
"button"
...
...
@@ -56,7 +50,7 @@
<span
class=
"navbar-toggler-icon"
></span>
</button>
<div
class=
"collapse navbar-collapse"
id=
"navbarSupportedContent"
>
<a
class=
"navbar-brand"
href=
"/"
><strong>
Home
</strong></a>
<a
class=
"navbar-brand"
href=
"/"
style=
"margin-left: 10px"
><strong>
Home
</strong></a>
</div>
</nav>
...
...
Please
register
or
login
to post a comment