Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021_dev-profile
/
dev-profile
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
김채리
2021-05-23 10:18:16 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ec59509174d56bce6f78ab2b0eb6f5c8ae58dda8
ec595091
1 parent
1f36c8a4
added API of trending repos
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
40 deletions
README.md
src/controllers/userController.js
src/routers/userRouter.js
src/views/home.pug
README.md
View file @
ec59509
...
...
@@ -11,6 +11,7 @@ KHU-Hub repo: [khuhub.khu.ac.kr/2018102216/dev-profile](https://khuhub.khu.ac.kr
-
[
x
]
random quotes
**_for developers_**
to motivate you :sparkles:
-
[
]
the amount of commits you've done on
[
GitHub
](
https://github.com/
)
at a glance
-
[
]
your most-contributed project on GitHub
-
[
x
]
today's trending repositories on GitHub
<br>
### Additional Features
...
...
src/controllers/userController.js
View file @
ec59509
...
...
@@ -2,80 +2,144 @@ import axios from "axios";
import
passport
from
"passport"
;
import
User
from
"../models/User"
;
const
getQuote
=
async
(
req
,
res
)
=>
{
const
getQuote
=
async
(
req
,
res
)
=>
{
const
url
=
"http://quotes.stormconsultancy.co.uk/random.json"
;
const
quoteData
=
await
axios
.
get
(
url
).
then
(
function
(
response
)
{
const
quoteData
=
await
axios
.
get
(
url
).
then
(
function
(
response
)
{
return
response
.
data
;
});
const
quote
=
quoteData
.
quote
;
const
author
=
quoteData
.
author
;
return
{
quote
,
author
};
}
return
{
quote
,
author
};
}
;
export
const
handleHome
=
async
(
req
,
res
)
=>
{
const
quote
=
await
getQuote
();
res
.
render
(
"home"
,{
pageTitle
:
"Home"
,
quote
:
quote
.
quote
,
author
:
quote
.
author
});
}
const
gitTrend
=
async
(
req
,
res
)
=>
{
const
url
=
"https://api.trending-github.com/github/repositories?period=daily"
;
const
trendData
=
await
axios
.
get
(
url
).
then
(
function
(
response
)
{
return
response
.
data
;
});
const
name0
=
trendData
[
0
].
name
;
const
description0
=
trendData
[
0
].
description
;
const
Url0
=
trendData
[
0
].
url
;
const
stars0
=
trendData
[
0
].
stars
;
const
name1
=
trendData
[
1
].
name
;
const
description1
=
trendData
[
1
].
description
;
const
Url1
=
trendData
[
1
].
url
;
const
stars1
=
trendData
[
1
].
stars
;
const
name2
=
trendData
[
2
].
name
;
const
description2
=
trendData
[
2
].
description
;
const
Url2
=
trendData
[
2
].
url
;
const
stars2
=
trendData
[
2
].
stars
;
return
{
name0
,
description0
,
Url0
,
stars0
,
name1
,
description1
,
Url1
,
stars1
,
name2
,
description2
,
Url2
,
stars2
,
};
};
export
const
handleHome
=
async
(
req
,
res
)
=>
{
const
quote
=
await
getQuote
();
const
trend
=
await
gitTrend
();
res
.
render
(
"home"
,
{
pageTitle
:
"Home"
,
quote
:
quote
.
quote
,
author
:
quote
.
author
,
name0
:
trend
.
name0
,
description0
:
trend
.
description0
,
Url0
:
trend
.
Url0
,
stars0
:
trend
.
stars0
,
name1
:
trend
.
name1
,
description1
:
trend
.
description1
,
Url1
:
trend
.
Url1
,
stars1
:
trend
.
stars1
,
name2
:
trend
.
name2
,
description2
:
trend
.
description2
,
Url2
:
trend
.
Url2
,
stars2
:
trend
.
stars2
,
});
};
export
const
getUserDetail
=
async
(
req
,
res
)
=>
{
export
const
getUserDetail
=
async
(
req
,
res
)
=>
{
const
quote
=
await
getQuote
();
res
.
render
(
"userDetail"
,{
pagetTitle
:
"User Detail"
,
quote
:
quote
.
quote
,
author
:
quote
.
author
})
}
res
.
render
(
"userDetail"
,
{
pagetTitle
:
"User Detail"
,
quote
:
quote
.
quote
,
author
:
quote
.
author
,
});
};
export
const
getEditProfile
=
(
req
,
res
)
=>
res
.
render
(
"editProfile"
,{
pageTitle
:
"Edit Profile"
});
export
const
getEditProfile
=
(
req
,
res
)
=>
res
.
render
(
"editProfile"
,
{
pageTitle
:
"Edit Profile"
});
export
const
postEditProfile
=
(
req
,
res
)
=>
{
export
const
postEditProfile
=
(
req
,
res
)
=>
{
console
.
log
(
req
.
body
);
res
.
redirect
(
"/users/edit-profile"
);
};
export
const
getJoin
=
(
req
,
res
)
=>
{
res
.
render
(
"join"
,{
pageTitle
:
"Join"
});
export
const
getJoin
=
(
req
,
res
)
=>
{
res
.
render
(
"join"
,
{
pageTitle
:
"Join"
});
};
export
const
getLogin
=
(
req
,
res
)
=>
{
res
.
render
(
"login"
,{
pageTitle
:
"Login"
});
export
const
getLogin
=
(
req
,
res
)
=>
{
res
.
render
(
"login"
,
{
pageTitle
:
"Login"
});
};
export
const
handleUsers
=
(
req
,
res
)
=>
{
res
.
render
(
"users"
,{
pageTitle
:
"Users"
});
}
export
const
handleUsers
=
(
req
,
res
)
=>
{
res
.
render
(
"users"
,
{
pageTitle
:
"Users"
});
}
;
export
const
githubLogin
=
passport
.
authenticate
(
"github"
,
{
scope
:
[
"user:email"
]});
export
const
githubLogin
=
passport
.
authenticate
(
"github"
,
{
scope
:
[
"user:email"
],
});
export
const
githubLoginCallback
=
async
(
_
,
__
,
profile
,
done
)
=>
{
const
{
_json
:
{
id
:
githubId
,
login
:
githubName
,
avatar_url
:
avatarUrl
,
name
,
email
}}
=
profile
;
export
const
githubLoginCallback
=
async
(
_
,
__
,
profile
,
done
)
=>
{
const
{
_json
:
{
id
:
githubId
,
login
:
githubName
,
avatar_url
:
avatarUrl
,
name
,
email
,
},
}
=
profile
;
try
{
const
user
=
await
User
.
findOne
({
email
});
if
(
user
){
user
.
githubId
=
githubId
,
user
.
githubName
=
githubName
try
{
const
user
=
await
User
.
findOne
({
email
});
if
(
user
)
{
(
user
.
githubId
=
githubId
),
(
user
.
githubName
=
githubName
);
await
user
.
save
();
return
done
(
null
,
user
);
}
else
{
}
else
{
const
newUser
=
await
User
.
create
({
githubId
,
githubName
,
avatarUrl
,
name
,
email
email
,
});
return
done
(
null
,
newUser
);
}
}
catch
(
error
)
{
}
catch
(
error
)
{
return
done
(
error
);
}
};
export
const
postGithubLogin
=
(
req
,
res
)
=>
{
export
const
postGithubLogin
=
(
req
,
res
)
=>
{
const
userId
=
req
.
user
.
id
;
res
.
redirect
(
`/users/
${
userId
}
`
);
}
}
;
export
const
logout
=
(
req
,
res
)
=>
{
export
const
logout
=
(
req
,
res
)
=>
{
req
.
logout
();
res
.
redirect
(
"/"
);
}
\ No newline at end of file
};
...
...
src/routers/userRouter.js
View file @
ec59509
import
express
from
"express"
;
import
{
getEditProfile
,
getUserDetail
,
handleUsers
,
postEditProfile
}
from
"../controllers/userController"
;
import
{
getEditProfile
,
getUserDetail
,
handleUsers
,
postEditProfile
,
}
from
"../controllers/userController"
;
import
{
onlyPrivate
}
from
"../middlewares"
;
const
userRouter
=
express
.
Router
();
userRouter
.
get
(
"/"
,
handleUsers
);
userRouter
.
get
(
"/"
,
handleUsers
);
userRouter
.
get
(
"/edit-profile"
,
onlyPrivate
,
getEditProfile
);
userRouter
.
post
(
"/edit-profile"
,
onlyPrivate
,
postEditProfile
);
userRouter
.
get
(
"/:id"
,
getUserDetail
);
export
default
userRouter
;
...
...
src/views/home.pug
View file @
ec59509
...
...
@@ -7,6 +7,19 @@ block content
h1 -Developer Profile-
h2=quote
h3=author
button.gotoTrend(style='background-color: white;')
p(style='color: orange;') Trending Repositories:
br
a(href=Url0, style={color:'grey'})
p=name0+": "+description0+" - "+stars0+" stars"
a(href=Url1, style={color:'grey'})
p=name1+": "+description1+" - "+stars1+" stars"
a(href=Url2, style={color:'grey'})
p=name2+": "+description2+" - "+stars2+" stars"
.home-link
a(href="/join") Join
|#{' '}
...
...
Please
register
or
login
to post a comment