Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
istex
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
crawlers
istex
Commits
bb8919de
Commit
bb8919de
authored
Sep 17, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Reading] cosmetics
parent
98ffb24a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
37 deletions
+42
-37
ISTEX.hs
src/ISTEX.hs
+14
-2
Client.hs
src/ISTEX/Client.hs
+28
-35
No files found.
src/ISTEX.hs
View file @
bb8919de
...
@@ -15,9 +15,21 @@ runIstexAPIClient cmd = do
...
@@ -15,9 +15,21 @@ runIstexAPIClient cmd = do
runClientM
cmd
(
mkClientEnv
manager'
$
BaseUrl
Https
"api.istex.fr"
443
"document"
)
runClientM
cmd
(
mkClientEnv
manager'
$
BaseUrl
Https
"api.istex.fr"
443
"document"
)
getMetadataWith
::
Text
->
Maybe
Int
->
IO
(
Either
ClientError
Documents
)
getMetadataWith
::
Text
->
Maybe
Int
->
IO
(
Either
ClientError
Documents
)
getMetadataWith
q
l
=
do
getMetadataWith
q
n
=
do
runIstexAPIClient
$
runIstexAPIClient
$
search
search
(
Just
"author,title,abstract,publicationDate,refBibs"
)
(
Just
"author,title,abstract,publicationDate,refBibs"
)
l
n
(
Just
q
)
(
Just
q
)
type
Query
=
Text
runTest
::
Query
->
Maybe
Int
->
IO
()
runTest
query
n
=
do
res
<-
getMetadataWith
query
n
case
res
of
(
Left
err
)
->
print
$
show
err
(
Right
val
)
->
do
print
val
src/ISTEX/Client.hs
View file @
bb8919de
...
@@ -18,9 +18,8 @@ import qualified Data.Text as T
...
@@ -18,9 +18,8 @@ import qualified Data.Text as T
import
qualified
Control.Lens
as
L
import
qualified
Control.Lens
as
L
data
Author
=
Author
data
Author
=
Author
{
{
_author_name
::
T
.
Text
_author_name
::
T
.
Text
,
,
_author_affiliations
::
[
T
.
Text
]
_author_affiliations
::
[
T
.
Text
]
}
deriving
(
Show
,
Generic
)
}
deriving
(
Show
,
Generic
)
L
.
makeLenses
''
A
uthor
L
.
makeLenses
''
A
uthor
...
@@ -29,60 +28,54 @@ instance FromJSON Author where
...
@@ -29,60 +28,54 @@ instance FromJSON Author where
Author
<$>
(
o
.:
"name"
)
<*>
(
o
.:
"affiliations"
<|>
pure
[]
)
Author
<$>
(
o
.:
"name"
)
<*>
(
o
.:
"affiliations"
<|>
pure
[]
)
data
Source
=
Source
data
Source
=
Source
{
{
_source_title
::
Maybe
T
.
Text
_source_title
::
Maybe
T
.
Text
,
,
_source_authors
::
[
Author
]
_source_authors
::
[
Author
],
,
_source_publicationDate
::
Maybe
Int
_source_publicationDate
::
Maybe
Int
}
deriving
(
Show
,
Generic
)
}
deriving
(
Show
,
Generic
)
L
.
makeLenses
''
S
ource
L
.
makeLenses
''
S
ource
instance
FromJSON
Source
where
instance
FromJSON
Source
where
parseJSON
(
Object
o
)
=
parseJSON
(
Object
o
)
=
Source
<$>
Source
<$>
(
o
.:?
"title"
)
(
o
.:?
"title"
)
<*>
(
o
.:
"author"
)
<*>
(
o
.:
"author"
)
<*>
do
pPubDate
<-
(
o
.:?
"publicationDate"
)
<*>
do
pPubDate
<-
(
o
.:?
"publicationDate"
)
return
$
(
read
.
T
.
unpack
)
<$>
pPubDate
return
$
(
read
.
T
.
unpack
)
<$>
pPubDate
data
Document
=
Document
data
Document
=
Document
{
{
_document_id
::
T
.
Text
_document_id
::
T
.
Text
,
,
_document_title
::
Maybe
T
.
Text
_document_title
::
Maybe
T
.
Text
,
,
_document_authors
::
[
Author
]
_document_authors
::
[
Author
],
,
_document_abstract
::
Maybe
T
.
Text
_document_abstract
::
Maybe
T
.
Text
,
,
_document_publicationDate
::
Maybe
Int
_document_publicationDate
::
Maybe
Int
,
,
_document_sources
::
[
Source
]
_document_sources
::
[
Source
]
}
deriving
(
Show
,
Generic
)
}
deriving
(
Show
,
Generic
)
L
.
makeLenses
''
D
ocument
L
.
makeLenses
''
D
ocument
instance
FromJSON
Document
where
instance
FromJSON
Document
where
parseJSON
(
Object
o
)
=
parseJSON
(
Object
o
)
=
Document
<$>
Document
<$>
(
o
.:
"id"
)
(
o
.:
"id"
)
<*>
(
o
.:?
"title"
)
<*>
(
o
.:?
"title"
)
<*>
(
o
.:
"author"
<|>
pure
[]
)
<*>
(
o
.:
"author"
<|>
pure
[]
)
<*>
(
o
.:?
"abstract"
)
<*>
(
o
.:?
"abstract"
)
<*>
((
o
.:?
"publicationDate"
)
>>=
\
date
->
return
$
fmap
(
read
.
T
.
unpack
)
date
)
<*>
do
pPubDate
<-
(
o
.:?
"publicationDate"
)
<*>
(
o
.:
"refBibs"
<|>
pure
[]
)
return
$
(
read
.
T
.
unpack
)
<$>
pPubDate
<*>
(
o
.:
"refBibs"
<|>
pure
[]
)
data
Documents
=
Documents
data
Documents
=
Documents
{
{
_documents_total
::
Int
_documents_total
::
Int
,
,
_documents_hits
::
[
Document
]
_documents_hits
::
[
Document
]
}
deriving
(
Show
,
Generic
)
}
deriving
(
Show
,
Generic
)
L
.
makeLenses
''
D
ocuments
L
.
makeLenses
''
D
ocuments
instance
FromJSON
Documents
where
instance
FromJSON
Documents
where
parseJSON
(
Object
o
)
=
parseJSON
(
Object
o
)
=
Documents
<$>
(
o
.:
"total"
)
<*>
(
o
.:
"hits"
)
Documents
<$>
(
o
.:
"total"
)
<*>
(
o
.:
"hits"
)
type
ISTEXAPI
=
Search
type
ISTEXAPI
=
Search
type
Search
=
type
Search
=
QueryParam
"output"
T
.
Text
QueryParam
"output"
T
.
Text
:>
QueryParam
"size"
Int
:>
QueryParam
"size"
Int
:>
QueryParam
"q"
T
.
Text
:>
QueryParam
"q"
T
.
Text
:>
Get
'[
J
SON
]
Documents
:>
Get
'[
J
SON
]
Documents
istexProxy
::
Proxy
(
ISTEXAPI
)
istexProxy
::
Proxy
(
ISTEXAPI
)
istexProxy
=
Proxy
istexProxy
=
Proxy
...
...
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