Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이세진
/
dev-profile
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
10
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Lee SeJin
2021-06-07 23:43:16 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bd5da55a81f6e1e9fbf903c8b8d5c820119b613a
bd5da55a
1 parent
06d58532
Update getting user repository
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
66 additions
and
59 deletions
.gitignore
src/client/js/getTrend.js
src/client/js/githubInfo.js
src/client/scss/screens/editProfile.scss
src/client/scss/screens/home.scss
src/client/scss/screens/userDetail.scss
src/controllers/userController.js
src/routers/userRouter.js
src/views/home.pug
src/views/userDetail.pug
.gitignore
View file @
bd5da55
...
...
@@ -119,4 +119,5 @@ dist
package-lock.json
/uploads
/assets
build
\ No newline at end of file
build
.vscode
\ No newline at end of file
...
...
src/client/js/getTrend.js
View file @
bd5da55
...
...
@@ -9,7 +9,7 @@ const handleRepo = (list) =>{
list
.
forEach
(
element
=>
{
const
anchor
=
document
.
createElement
(
"a"
);
anchor
.
href
=
element
.
url
;
anchor
.
target
=
"_blank"
anchor
.
target
=
"_blank"
;
anchor
.
innerHTML
=
`<span class="repoName">
${
element
.
name
}
</span> :
${
element
.
description
}
- <span class="repoStar">
${
element
.
stars
}
stars</span>`
trendRepoBox
.
appendChild
(
anchor
);
});
...
...
src/client/js/githubInfo.js
View file @
bd5da55
...
...
@@ -6,8 +6,7 @@ const totalContributionIndicator = document.getElementById(
);
const
userCharacterBox
=
document
.
querySelector
(
".user-status__character"
);
const
userRepoBox
=
document
.
querySelector
(
".user-repo"
);
const
URL
=
"https://api.github.com/users/lsj8706/repos?sort=updated&per_page=2"
;
const
githubNickname
=
document
.
getElementById
(
"jsGithubNickname"
);
const
handleImage
=
()
=>
{
const
total
=
totalContributionIndicator
.
innerText
;
...
...
@@ -41,16 +40,16 @@ const handleRepo = (list) => {
});
};
const
getGithubRepo
=
()
=>
{
const
response
=
fetch
(
URL
)
.
then
(
function
(
response
)
{
return
response
.
json
();
})
.
then
(
function
(
data
)
{
const
trendRepoList
=
data
.
slice
(
0
,
2
);
handleRepo
(
trendRepoList
);
});
}
;
const
getGithubRepo
=
()
=>
{
const
nickname
=
githubNickname
.
innerText
;
const
userId
=
window
.
location
.
href
.
split
(
"/users/"
)[
1
];
const
response
=
fetch
(
`/users/
${
userId
}
/repo`
,{
headers
:{
nickname
}}).
then
(
function
(
reponse
){
const
data
=
reponse
.
json
();
return
data
}).
then
(
function
(
data
){
handleRepo
(
data
);
})
}
const
init
=
()
=>
{
handleImage
();
...
...
src/client/scss/screens/editProfile.scss
View file @
bd5da55
...
...
@@ -4,9 +4,9 @@
flex-direction
:
column
;
padding
:
30px
;
img
{
width
:
1
00
px
;
height
:
10
0px
;
object-fit
:
co
ver
;
width
:
1
76
px
;
height
:
22
0px
;
object-fit
:
co
ntain
;
}
.fileUpload
{
display
:
flex
;
...
...
src/client/scss/screens/home.scss
View file @
bd5da55
...
...
@@ -96,16 +96,21 @@
font-size
:
1
.2rem
;
overflow-x
:
scroll
;
}
i
{
background
:
transparent
;
button
{
border
:
none
;
background
:
none
;
padding
:
0
;
i
{
font-size
:
1
.5rem
;
margin
:
3px
;
background
:
transparent
;
border
:
none
;
i
{
font-size
:
1
.5rem
;
margin
:
3px
;
}
}
i
:hover
{
cursor
:
pointer
;
}
}
i
:hover
{
cursor
:
pointer
;
}
}
.home-search__form
:hover
{
...
...
src/client/scss/screens/userDetail.scss
View file @
bd5da55
...
...
@@ -48,7 +48,6 @@
}
.boxEffect
{
z-index
:
-1
;
content
:
""
;
bottom
:
15px
;
right
:
10px
;
...
...
@@ -85,9 +84,9 @@
.user-profile__column
{
img
{
width
:
1
20
px
;
height
:
1
20px
;
object-fit
:
co
ver
;
width
:
1
76
px
;
height
:
2
20px
;
object-fit
:
co
ntain
;
margin
:
5px
;
}
.user-profile__link
{
...
...
@@ -117,6 +116,12 @@
.user-profile__tech
{
display
:
flex
;
}
.user-profile__introduction
{
width
:
100%
;
overflow
:
hidden
;
word-wrap
:
break-word
;
word-break
:
break-all
;
}
ul
{
display
:
flex
;
flex-direction
:
column
;
...
...
@@ -212,7 +217,7 @@
max-width
:
200px
;
height
:
auto
;
object-fit
:
cover
;
margin-top
:
px
;
margin-top
:
20
px
;
}
}
}
...
...
src/controllers/userController.js
View file @
bd5da55
...
...
@@ -27,18 +27,13 @@ export const getUserDetail = async (req, res) => {
const
id
=
req
.
params
.
id
;
const
quote
=
await
getQuote
();
const
user
=
await
User
.
findById
(
id
);
const
repo
=
await
getRepos
();
const
totalCon
=
await
getContributions
(
user
.
githubName
);
res
.
render
(
"userDetail"
,
{
pagetTitle
:
"User Detail"
,
quote
:
quote
.
quote
,
author
:
quote
.
author
,
user
,
fitstRepoName
:
repo
.
fitstRepoName
,
firstRepoUrl
:
repo
.
firstRepoUrl
,
secondRepoName
:
repo
.
secondRepoName
,
secondRepoUrl
:
repo
.
secondRepoUrl
,
totalContributions
:
totalCon
,
totalContributions
:
totalCon
});
}
catch
(
error
)
{
console
.
log
(
error
);
...
...
@@ -87,7 +82,7 @@ export const postEditProfile = async (req, res) => {
);
req
.
session
.
passport
.
user
=
updatedUser
;
//console.log(updatedUser);
res
.
redirect
(
"/users/edit-profile"
);
res
.
redirect
(
`/users/
${
id
}
`
);
}
catch
(
error
)
{
console
.
log
(
error
);
res
.
redirect
(
"/"
);
...
...
@@ -135,7 +130,7 @@ export const githubLoginCallback = async (_, __, profile, done) => {
avatarUrl
,
githubUrl
,
name
,
email
,
email
});
return
done
(
null
,
newUser
);
}
...
...
@@ -154,25 +149,6 @@ export const logout = (req, res) => {
res
.
redirect
(
"/"
);
};
const
getRepos
=
async
()
=>
{
const
url
=
"https://api.github.com/users/lsj8706/repos?sort=updated&per_page=2"
;
const
latelyRepos
=
await
axios
.
get
(
url
).
then
(
function
(
response
)
{
return
response
.
data
;
});
const
fitstRepoName
=
latelyRepos
[
0
].
name
;
const
secondRepoName
=
latelyRepos
[
1
].
name
;
const
firstRepoUrl
=
latelyRepos
[
0
].
html_url
;
const
secondRepoUrl
=
latelyRepos
[
1
].
html_url
;
return
{
fitstRepoName
,
firstRepoUrl
,
secondRepoName
,
secondRepoUrl
,
};
};
const
getContributions
=
async
(
username
)
=>
{
const
token
=
process
.
env
.
GH_SECRET_SH
;
const
headers
=
{
...
...
@@ -192,3 +168,21 @@ const getContributions = async (username) => {
.
totalContributions
;
return
total
;
};
export
const
getRepos
=
async
(
req
,
res
)
=>
{
try
{
const
githubNickname
=
req
.
headers
.
nickname
const
URL
=
`https://api.github.com/users/
${
githubNickname
}
/repos?sort=updated&per_page=2`
;
const
response
=
await
fetch
(
URL
,{
headers
:
{
authorization
:
`token
${
process
.
env
.
GH_SECRET_SH
}
`
}
}).
then
(
function
(
response
)
{
return
response
.
json
();
}).
then
(
function
(
data
)
{
return
res
.
send
(
data
);
});
}
catch
(
error
){
console
.
log
(
error
);
}
}
\ No newline at end of file
...
...
src/routers/userRouter.js
View file @
bd5da55
import
express
from
"express"
;
import
{
getEditProfile
,
getRepos
,
getUserDetail
,
handleUsers
,
postEditProfile
,
...
...
@@ -20,5 +21,6 @@ userRouter.post(
);
userRouter
.
get
(
"/:id"
,
getUserDetail
);
userRouter
.
get
(
"/:id/repo"
,
getRepos
);
export
default
userRouter
;
...
...
src/views/home.pug
View file @
bd5da55
...
...
@@ -18,7 +18,8 @@ block content
a(href="https://google.com" target="_blank")
img(src="https://user-images.githubusercontent.com/48612525/86507657-d54fbd80-bd8e-11ea-866b-ac26496481ae.png" alt="google icon")
input(type="text" id="jsInput" placeholder="Google 검색")
i.fa.fa-search(aria-hidden="true")
button
i.fa.fa-search(aria-hidden="true")
.home-quote
h2=quote
...
...
src/views/userDetail.pug
View file @
bd5da55
...
...
@@ -12,7 +12,7 @@ block content
img(src=`/${user.avatarUrl}`)
.user-profile__link
a(href=user.githubUrl target="_blank") GitHub
i.fab.fa-github
i.fab.fa-github
a(href=`//${user.blogUrl}` target="_blank") Blog
i.fas.fa-link
.user-profile__column
...
...
@@ -24,7 +24,7 @@ block content
h3 GITHUB
br
|NICKNAME
h4=user.githubName
h4
#jsGithubNickname
=user.githubName
.user-profile__email
h3 EMAIL
h4=user.email
...
...
Please
register
or
login
to post a comment