Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-155
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-155
2021-155
Commits
0a8302b1
Commit
0a8302b1
authored
Nov 22, 2021
by
Kamal Thennakoon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
introduce medium scrapper
parent
ebc21901
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
428 additions
and
98 deletions
+428
-98
client/actions/portfolio.js
client/actions/portfolio.js
+3
-2
client/components/portfolio/portfolio-generate-dialog/portfolio-generate-dialog.js
...io/portfolio-generate-dialog/portfolio-generate-dialog.js
+41
-11
client/pages/portfolio/[username].js
client/pages/portfolio/[username].js
+384
-85
No files found.
client/actions/portfolio.js
View file @
0a8302b1
...
...
@@ -52,12 +52,13 @@ export async function getAllPortfolios() {
return
err
}
}
export
async
function
createPortfolio
(
gitUsername
,
stofUsername
)
{
export
async
function
createPortfolio
(
gitUsername
,
stofUsername
,
mediumUsername
)
{
const
url
=
`/user/create`
try
{
const
response
=
await
portfolioPublicFetch
.
post
(
url
,
{
git_username
:
gitUsername
,
stof_username
:
stofUsername
stof_username
:
stofUsername
,
medium_username
:
mediumUsername
,
})
const
data
=
response
.
data
...
...
client/components/portfolio/portfolio-generate-dialog/portfolio-generate-dialog.js
View file @
0a8302b1
...
...
@@ -16,31 +16,41 @@ import {
export
default
function
PortfolioGenerateDialog
(
props
)
{
const
router
=
useRouter
()
const
[
username
,
setUsername
]
=
useState
(
''
)
const
[
stofUsername
,
setStofUsername
]
=
useState
(
''
)
const
[
mediumUsername
,
setMediumUsername
]
=
useState
(
''
)
const
handleChange
=
(
e
)
=>
{
console
.
log
(
e
.
target
.
value
)
setUsername
(
e
.
target
.
value
.
toLowerCase
())
}
const
handleStofChange
=
(
e
)
=>
{
console
.
log
(
e
.
target
.
value
)
setStofUsername
(
e
.
target
.
value
.
toLowerCase
())
}
const
handleMediumChange
=
(
e
)
=>
{
console
.
log
(
e
.
target
.
value
)
setMediumUsername
(
e
.
target
.
value
.
toLowerCase
())
}
const
navigateToPortfolio
=
(
username
)
=>
{
console
.
log
(
'
username::
'
,
username
)
router
.
push
(
`/portfolio/
${
username
}
`
)
}
const
createUserPortfolio
=
async
(
username
)
=>
{
const
portfolio
=
await
createPortfolio
(
username
)
const
createUserPortfolio
=
async
(
git_username
,
stof_username
,
medium_
username
)
=>
{
const
portfolio
=
await
createPortfolio
(
git_username
,
stof_username
,
medium_
username
)
return
portfolio
&&
portfolio
.
valid
?
true
:
false
}
const
portfolioGeneration
=
async
(
username
)
=>
{
const
portfolioGeneration
=
async
(
git_username
,
stof_username
,
medium_
username
)
=>
{
try
{
const
profileValidity
=
await
checkGithubProfile
(
username
)
const
profileValidity
=
await
checkGithubProfile
(
git_
username
)
if
(
profileValidity
)
{
const
portfolioValidity
=
await
checkPortfolio
(
username
)
const
portfolioValidity
=
await
checkPortfolio
Availability
(
git_
username
)
if
(
portfolioValidity
)
{
navigateToPortfolio
(
username
)
navigateToPortfolio
(
git_
username
)
}
else
{
const
portfolio
=
await
createUserPortfolio
(
username
)
const
portfolio
=
await
createUserPortfolio
(
git_username
,
stof_username
,
medium_
username
)
if
(
portfolio
)
{
navigateToPortfolio
(
username
)
navigateToPortfolio
(
git_
username
)
}
else
{
console
.
log
(
'
something went wrong, show it using toast
'
)
}
...
...
@@ -54,7 +64,7 @@ export default function PortfolioGenerateDialog(props) {
}
// check user portfolio availabilty from the backend
const
checkPortfolio
=
async
(
username
)
=>
{
const
checkPortfolio
Availability
=
async
(
username
)
=>
{
const
response
=
await
checkPortfolioExists
(
username
)
return
response
&&
response
.
valid
?
true
:
false
...
...
@@ -73,7 +83,7 @@ export default function PortfolioGenerateDialog(props) {
onClose
=
{
props
.
handleClose
}
aria
-
labelledby
=
"
form-dialog-title
"
>
<
DialogTitle
id
=
"
form-dialog-title
"
>
Subscribe
<
/DialogTitle
>
<
DialogTitle
id
=
"
form-dialog-title
"
>
Generate
Portfolio
<
/DialogTitle
>
<
DialogContent
>
<
DialogContentText
>
Please
enter
user
'
s github username to generate the dynamic
...
...
@@ -89,12 +99,32 @@ export default function PortfolioGenerateDialog(props) {
type="text"
fullWidth
/>
<TextField
value={stofUsername}
onChange={handleStofChange}
autoFocus
margin="dense"
id="stof_username"
label="Stackoverflow Username"
type="text"
fullWidth
/>
<TextField
value={mediumUsername}
onChange={handleMediumChange}
autoFocus
margin="dense"
id="medium_username"
label="medium Username"
type="text"
fullWidth
/>
</DialogContent>
<DialogActions>
<Button onClick={props.handleClose} color="primary">
Cancel
</Button>
<Button onClick={() => portfolioGeneration(username)} color="primary">
<Button onClick={() => portfolioGeneration(username
,stofUsername,mediumUsername
)} color="primary">
Generate
</Button>
</DialogActions>
...
...
client/pages/portfolio/[username].js
View file @
0a8302b1
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment