Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
198
Issues
198
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
25fc4df9
Commit
25fc4df9
authored
Dec 03, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[searx] some more work on triggerSearxSearch
parent
50d10679
Pipeline
#2210
failed with stage
in 10 minutes and 21 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
Searx.hs
src/Gargantext/API/Node/Corpus/Searx.hs
+12
-4
No files found.
src/Gargantext/API/Node/Corpus/Searx.hs
View file @
25fc4df9
...
@@ -23,8 +23,14 @@ import Gargantext.Core.Utils.Prefix (unPrefix)
...
@@ -23,8 +23,14 @@ import Gargantext.Core.Utils.Prefix (unPrefix)
import
Gargantext.Database.Action.Flow.Types
(
FlowCmdM
)
import
Gargantext.Database.Action.Flow.Types
(
FlowCmdM
)
import
Gargantext.Database.Admin.Types.Node
(
CorpusId
)
import
Gargantext.Database.Admin.Types.Node
(
CorpusId
)
import
Gargantext.Database.Prelude
(
hasConfig
)
import
Gargantext.Database.Prelude
(
hasConfig
)
import
Gargantext.Database.Query.Table.Node
(
defaultList
)
langToSearx
::
Lang
->
Text
langToSearx
EN
=
"en-US"
langToSearx
FR
=
"fr-FR"
langToSearx
All
=
"en-US"
data
SearxResult
=
SearxResult
data
SearxResult
=
SearxResult
{
_sr_url
::
Text
{
_sr_url
::
Text
,
_sr_title
::
Text
,
_sr_title
::
Text
...
@@ -76,26 +82,28 @@ fetchSearxPage (FetchSearxParams { _fsp_language
...
@@ -76,26 +82,28 @@ fetchSearxPage (FetchSearxParams { _fsp_language
,
(
"categories"
,
"news"
)
-- https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/70#note_3976
,
(
"categories"
,
"news"
)
-- https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/70#note_3976
,
(
"pageno"
,
encodeUtf8
$
T
.
pack
$
show
_fsp_pageno
)
,
(
"pageno"
,
encodeUtf8
$
T
.
pack
$
show
_fsp_pageno
)
--, ("time_range", "None")
--, ("time_range", "None")
,
(
"language"
,
encodeUtf8
$
T
.
pack
$
show
_fsp_language
)
,
(
"language"
,
encodeUtf8
$
langToSearx
_fsp_language
)
,
(
"format"
,
"json"
)
,
(
"format"
,
"json"
)
]
req
]
req
res
<-
httpLbs
request
_fsp_manager
res
<-
httpLbs
request
_fsp_manager
let
dec
=
Aeson
.
eitherDecode
$
responseBody
res
::
(
Either
Prelude
.
String
SearxResponse
)
let
dec
=
Aeson
.
eitherDecode
$
responseBody
res
::
(
Either
Prelude
.
String
SearxResponse
)
pure
dec
pure
dec
-- TODO Make an async task out of this?
triggerSearxSearch
::
(
MonadBase
IO
m
,
FlowCmdM
env
err
m
)
triggerSearxSearch
::
(
MonadBase
IO
m
,
FlowCmdM
env
err
m
)
=>
CorpusId
=>
CorpusId
->
API
.
Query
->
API
.
Query
->
Lang
->
Lang
->
m
()
->
m
()
triggerSearxSearch
cId
q
l
=
do
triggerSearxSearch
cid
q
l
=
do
printDebug
"[triggerSearxSearch] cId"
cId
printDebug
"[triggerSearxSearch] cid"
cid
printDebug
"[triggerSearxSearch] q"
q
printDebug
"[triggerSearxSearch] q"
q
printDebug
"[triggerSearxSearch] l"
l
printDebug
"[triggerSearxSearch] l"
l
cfg
<-
view
hasConfig
cfg
<-
view
hasConfig
let
surl
=
_gc_frame_searx_url
cfg
let
surl
=
_gc_frame_searx_url
cfg
printDebug
"[triggerSearxSearch] surl"
surl
printDebug
"[triggerSearxSearch] surl"
surl
listId
<-
defaultList
cId
printDebug
"[triggerSearxSearch] listId"
listId
manager
<-
liftBase
$
newManager
tlsManagerSettings
manager
<-
liftBase
$
newManager
tlsManagerSettings
res
<-
liftBase
$
fetchSearxPage
$
FetchSearxParams
{
_fsp_language
=
l
res
<-
liftBase
$
fetchSearxPage
$
FetchSearxParams
{
_fsp_language
=
l
...
...
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