Toggle navigation
Toggle navigation
This project
Loading...
Sign in
bluejoyq
/
searchGuide
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
bluejoyq
2019-11-20 01:06:14 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
49e8b3f58cb405211751e08d1f8bf39f33634e7b
49e8b3f5
1 parent
870d17c4
add api connection
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
3 deletions
searchGuide/.expo/packager-info.json
searchGuide/lib/api.js
searchGuide/lib/filter.js
searchGuide/package-lock.json
searchGuide/package.json
searchGuide/reducers/search.js
searchGuide/.expo/packager-info.json
View file @
49e8b3f
...
...
@@ -2,8 +2,8 @@
"devToolsPort"
:
19002
,
"expoServerPort"
:
19000
,
"packagerPort"
:
19001
,
"packagerPid"
:
30352
,
"packagerPid"
:
14964
,
"expoServerNgrokUrl"
:
"https://s4-47j.anonymous.searchguide.exp.direct"
,
"packagerNgrokUrl"
:
"https://packager.s4-47j.anonymous.searchguide.exp.direct"
,
"ngrokPid"
:
1936
8
"ngrokPid"
:
378
8
}
...
...
searchGuide/lib/api.js
0 → 100644
View file @
49e8b3f
const
axios
=
require
(
'axios'
)
const
filter
=
require
(
'./filter'
)
export
const
SendToApi
=
async
(
searchdata
)
=>
{
console
.
log
(
searchdata
)
return
new
Promise
((
resolve
,
reject
)
=>
{
let
isBlank_reg
=
"/\s\g"
if
(
searchdata
===
""
||
searchdata
.
length
>
30
){
resolve
(
JSON
.
stringify
({
"return_code"
:
-
1
,
"error_code"
:
"검색 단어를 확인해 주세요!"
}));
}
else
{
axios
(
{
headers
:
{
"Accept"
:
"application/json"
,
"Content-Type"
:
"application/json"
,
},
url
:
'http://1.201.142.118:80/api/cliConnection'
,
data
:
{
data
:{
text
:
searchdata
.
replace
(
/
\s{1,}
/g
,
' '
)
}
},
method
:
"POST"
,
}
)
.
then
((
response
)
=>
{
resolve
(
JSON
.
stringify
(
filter
(
response
.
data
)))
})
.
catch
(
error
=>
{
console
.
error
(
error
);
});
}
setTimeout
(
()
=>
{
try
{
throw
new
Error
(
"ERROR"
);
}
catch
(
err
)
{
resolve
(
JSON
.
stringify
({
"return_code"
:
-
1
,
"error_code"
:
err
.
message
}));
return
false
;
}},
10000
)
})
}
\ No newline at end of file
searchGuide/lib/filter.js
0 → 100644
View file @
49e8b3f
const
specificURL
=
[
'naver.com'
,
'google.com'
,
'namu.wiki'
,
'facebook.com'
,
'ko.wikipedia.org'
,
'youtube.com'
];
export
default
filter
=
(
JSONdata
)
=>
{
JSONdata
.
return_data
.
searchResults
.
sort
(
(
a
,
b
)
=>
{
return
a
.
confidence
>
b
.
confidence
?
-
1
:
a
.
confidence
<
b
.
confidence
?
1
:
0
;
})
slicedata
=
Object
.
keys
(
JSONdata
.
return_data
.
searchResults
).
slice
(
0
,
10
).
reduce
(
(
result
,
key
)
=>
{
result
[
key
]
=
JSONdata
.
return_data
.
searchResults
[
key
]
return
result
},
{}
);
let
tempResult
=
Object
.
values
(
slicedata
);
tempResult
.
forEach
(
(
data
)
=>
{
if
(
data
.
title
.
length
>
14
)
{
data
.
title
=
data
.
title
.
slice
(
0
,
15
)
+
".."
;
}
if
(
data
.
passage
.
length
>
125
)
{
data
.
passage
=
data
.
passage
.
slice
(
0
,
125
)
+
".."
;
}
specificURL
.
forEach
(
(
url
)
=>
{
if
(
data
.
url
.
indexOf
(
url
)
!==
-
1
)
{
data
.
site
=
url
;
}
});
if
(
!
data
.
site
)
{
data
.
site
=
"etc"
;
}
});
return
(
{...
JSONdata
,
return_data
:
{
...
JSONdata
.
return_data
,
searchResults
:
tempResult
}
}
);
}
\ No newline at end of file
searchGuide/package-lock.json
View file @
49e8b3f
...
...
@@ -5717,6 +5717,11 @@
"react-is"
:
"^16.9.0"
}
},
"react-thunk"
:
{
"version"
:
"1.0.0"
,
"resolved"
:
"https://registry.npmjs.org/react-thunk/-/react-thunk-1.0.0.tgz"
,
"integrity"
:
"sha1-eYE9R/MRR+ga7oQe1edqnj6ryLE="
},
"react-timer-mixin"
:
{
"version"
:
"0.13.4"
,
"resolved"
:
"https://registry.npmjs.org/react-timer-mixin/-/react-timer-mixin-0.13.4.tgz"
,
...
...
searchGuide/package.json
View file @
49e8b3f
...
...
@@ -26,6 +26,7 @@
"react-navigation-material-bottom-tabs"
:
"^2.1.5"
,
"react-navigation-tabs"
:
"^2.5.6"
,
"react-redux"
:
"^7.1.3"
,
"react-thunk"
:
"^1.0.0"
,
"redux"
:
"^4.0.4"
},
"devDependencies"
:
{
...
...
searchGuide/reducers/search.js
View file @
49e8b3f
...
...
@@ -6,7 +6,7 @@ export const change = (text) => ({
text
,
})
export
const
submit
=
(
text
)
=>
({
export
const
submit
=
(
text
)
=>
(
dispatch
)
=>
(
{
type
:
CHANGE
,
text
,
})
...
...
Please
register
or
login
to post a comment