Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2019-1-OpenSourceSW
/
WhoAreYou
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
서주원
2018-12-05 19:57:46 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4f6c3fba6fc1ef1df01b14d366093b6d055fca0c
4f6c3fba
1 parent
3f1a2bd3
implement decklists
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
134 additions
and
5 deletions
api/deck/getDeck.js
api/deck/index.js
api/deck/newDeck.js
app.js
package-lock.json
package.json
views/ejs/decklist.ejs
api/deck/getDeck.js
0 → 100644
View file @
4f6c3fb
const
mysql
=
require
(
'../../database/mysql'
)
exports
.
GetDeck
=
(
res
,
req
)
=>
{
const
userId
=
'test'
const
getDeck
=
()
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
mysql
.
getConnection
((
err
,
connection
)
=>
{
if
(
err
)
throw
err
connection
.
query
(
`select id,deckTitle from deck where deckOwner=\'
${
userId
}
\'`
,(
err
,
results
,
fields
)
=>
{
if
(
err
)
throw
err
console
.
log
(
JSON
.
stringify
(
results
))
resolve
(
JSON
.
stringify
(
results
))
})
connection
.
release
()
})
})
}
getDeck
()
.
then
((
results
)
=>
{
return
res
.
status
(
200
).
json
(
results
)
})
.
catch
((
err
)
=>
{
//return res.status(500).json(err||err.message)
})
}
\ No newline at end of file
api/deck/index.js
View file @
4f6c3fb
...
...
@@ -2,7 +2,9 @@ const express=require('express')
const
router
=
express
.
Router
()
const
newDeck
=
require
(
'./newDeck'
)
const
getDeck
=
require
(
'./getDeck'
)
router
.
post
(
'/newdeck'
,
newDeck
.
NewDeck
)
router
.
get
(
'/getdeck'
,
getDeck
.
GetDeck
)
module
.
exports
=
router
\ No newline at end of file
...
...
api/deck/newDeck.js
View file @
4f6c3fb
const
rp
=
require
(
'request-promise'
)
const
mysql
=
require
(
'../../database/mysql'
)
const
crawler
=
require
(
'./crawler'
)
const
cheerio
=
require
(
'cheerio'
)
const
addCards
=
require
(
'../card/addCards'
)
...
...
app.js
View file @
4f6c3fb
...
...
@@ -8,6 +8,8 @@ const rp=require('request-promise')
const
morgan
=
require
(
'morgan'
)
const
cheerio
=
require
(
'cheerio'
)
const
mysqlApostrophe
=
require
(
'mysql-apostrophe'
)
const
ejs
=
require
(
'ejs'
)
const
mysql
=
require
(
'./database/mysql'
)
require
(
'dotenv'
).
config
()
const
app
=
express
()
...
...
@@ -83,9 +85,22 @@ app.get('/decklist',(req,res)=>{
if
(
!
req
.
session
.
sid
)
res
.
redirect
(
'/login'
)
else
{
fs
.
readFile
(
'./views/html/decklist.html'
,(
err
,
data
)
=>
{
res
.
writeHead
(
200
,{
'Content-Type'
:
'text/html'
})
res
.
end
(
data
)
mysql
.
getConnection
((
err
,
connection
)
=>
{
if
(
err
)
throw
err
connection
.
query
(
`select id,deckTitle from deck where deckOwner=\'
${
req
.
session
.
sid
}
\'`
,(
err
,
results
,
fields
)
=>
{
if
(
err
)
throw
err
else
{
console
.
log
(
results
)
console
.
log
(
'length : '
+
results
.
length
)
fs
.
readFile
(
'./views/ejs/decklist.ejs'
,
'utf-8'
,(
err
,
data
)
=>
{
res
.
writeHead
(
200
,{
'Content-Type'
:
'text/html'
})
res
.
end
(
ejs
.
render
(
data
,{
decks
:
results
,
}))
})
}
})
connection
.
release
()
})
}
...
...
package-lock.json
View file @
4f6c3fb
...
...
@@ -295,6 +295,11 @@
"resolved"
:
"https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz"
,
"integrity"
:
"sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
"ejs"
:
{
"version"
:
"2.6.1"
,
"resolved"
:
"https://registry.npmjs.org/ejs/-/ejs-2.6.1.tgz"
,
"integrity"
:
"sha512-0xy4A/twfrRCnkhfk8ErDi5DqdAsAqeGxht4xkCUrsvhhbQNs7E+4jV0CN7+NKIY0aHE72+XvqtBIXzD31ZbXQ=="
},
"encodeurl"
:
{
"version"
:
"1.0.2"
,
"resolved"
:
"https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz"
,
...
...
package.json
View file @
4f6c3fb
...
...
@@ -18,6 +18,7 @@
"charset"
:
"^1.0.1"
,
"cheerio"
:
"^1.0.0-rc.2"
,
"dotenv"
:
"^6.1.0"
,
"ejs"
:
"^2.6.1"
,
"express"
:
"^4.16.4"
,
"express-session"
:
"^1.15.6"
,
"fs"
:
"0.0.1-security"
,
...
...
views/ejs/decklist.ejs
0 → 100644
View file @
4f6c3fb
<!DOCTYPE html>
<html
lang=
"ko"
>
<head>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<title>
Who Are You? - 하스스톤 멀리건 도우미
</title>
<!-- 부트스트랩 -->
<link
href=
"../../static/bootstrap-3.3.2-dist/css/bootstrap.min.css?ver=1"
rel=
"stylesheet"
>
<link
href=
"../../static/main.css"
rel=
"stylesheet"
>
<!-- IE8 에서 HTML5 요소와 미디어 쿼리를 위한 HTML5 shim 와 Respond.js -->
<!-- WARNING: Respond.js 는 당신이 file:// 을 통해 페이지를 볼 때는 동작하지 않습니다. -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"
></script>
<script>
$
(
document
).
ready
(
function
(){
$
(
'#logoutButton'
).
click
(
function
(){
$
.
ajax
({
type
:
'POST'
,
url
:
'/logout'
,
success
:
function
(
result
){
alert
(
'로그아웃 성공!'
)
window
.
location
.
href
=
'/main'
},
error
:
function
(
result
){
alert
(
'로그아웃 실패!'
)
return
false
}
})
})
})
</script>
</head>
<body>
<nav
class=
"navbar-default navbar-fixed-top"
>
<div
class=
"container"
>
<div
class=
"navbar-header"
>
<button
class=
"navbar-toggle collapsed"
aria-expanded=
"false"
aria-controls=
"navbar"
type=
"button"
data-toggle=
"collapse"
data-target=
"#navbar"
>
<span
class=
"sr-only"
>
Toggle navigation
</span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
</button>
<a
class=
"navbar-brand"
href=
"/main"
>
Who Are You?
</a>
</div>
<div
class=
"navbar-collapse collapse"
id=
"navbar"
aria-expanded=
"false"
style=
"height: 1px;"
>
<ul
class=
"nav navbar-nav"
>
</ul>
<div
class=
"navbar-right"
>
<input
type=
"button"
class=
"btn navbar-btn"
id=
"logoutButton"
style=
"color:#000;"
value=
"로그아웃"
/>
</div>
</div>
</div>
</nav>
<div
class=
"container show-grid"
>
<div
class=
"padding"
style=
"width:100px"
></div>
<div
class=
"container"
style=
"width:50%;"
>
<div
class=
"row"
>
<h3
class=
"form-signin-heading col-md-10"
style=
"text-align: left;"
>
내 덱 리스트
</h3>
<a
href=
"/newdeck"
><input
type=
"button"
class=
"btn col-md-2"
value=
"+"
style=
"margin-top: 18px;"
/></a>
</div>
<br>
<table
class=
"table"
>
<
% for ( var i=0;i
<decks
.
length
;
i
++)
{
%
>
<tr><td
style=
"text-align: center;"
><a
class=
"list-group-item"
href=
"/ingame?deck=<%= decks[i].id %>"
>
<
%= decks[i].deckTitle %>
</a></td></tr>
<
% } %>
</table>
</div>
</div>
<!-- jQuery (부트스트랩의 자바스크립트 플러그인을 위해 필요합니다) -->
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"
></script>
<!-- 모든 컴파일된 플러그인을 포함합니다 (아래), 원하지 않는다면 필요한 각각의 파일을 포함하세요 -->
<script
src=
"../../static/bootstrap-3.3.2-dist/js/bootstrap.min.js"
></script>
</body>
</html>
\ No newline at end of file
Please
register
or
login
to post a comment