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
runClientM
cmd
(
mkClientEnv
manager'
$
BaseUrl
Https
"api.istex.fr"
443
"document"
)
getMetadataWith
::
Text
->
Maybe
Int
->
IO
(
Either
ClientError
Documents
)
getMetadataWith
q
l
=
do
getMetadataWith
q
n
=
do
runIstexAPIClient
$
search
(
Just
"author,title,abstract,publicationDate,refBibs"
)
l
n
(
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
import
qualified
Control.Lens
as
L
data
Author
=
Author
{
_author_name
::
T
.
Text
,
_author_affiliations
::
[
T
.
Text
]
{
_author_name
::
T
.
Text
,
_author_affiliations
::
[
T
.
Text
]
}
deriving
(
Show
,
Generic
)
L
.
makeLenses
''
A
uthor
...
...
@@ -29,60 +28,54 @@ instance FromJSON Author where
Author
<$>
(
o
.:
"name"
)
<*>
(
o
.:
"affiliations"
<|>
pure
[]
)
data
Source
=
Source
{
_source_title
::
Maybe
T
.
Text
,
_source_authors
::
[
Author
],
_source_publicationDate
::
Maybe
Int
{
_source_title
::
Maybe
T
.
Text
,
_source_authors
::
[
Author
]
,
_source_publicationDate
::
Maybe
Int
}
deriving
(
Show
,
Generic
)
L
.
makeLenses
''
S
ource
instance
FromJSON
Source
where
parseJSON
(
Object
o
)
=
Source
<$>
(
o
.:?
"title"
)
<*>
(
o
.:
"author"
)
<*>
do
pPubDate
<-
(
o
.:?
"publicationDate"
)
return
$
(
read
.
T
.
unpack
)
<$>
pPubDate
Source
<$>
(
o
.:?
"title"
)
<*>
(
o
.:
"author"
)
<*>
do
pPubDate
<-
(
o
.:?
"publicationDate"
)
return
$
(
read
.
T
.
unpack
)
<$>
pPubDate
data
Document
=
Document
{
_document_id
::
T
.
Text
,
_document_title
::
Maybe
T
.
Text
,
_document_authors
::
[
Author
],
_document_abstract
::
Maybe
T
.
Text
,
_document_publicationDate
::
Maybe
Int
,
_document_sources
::
[
Source
]
{
_document_id
::
T
.
Text
,
_document_title
::
Maybe
T
.
Text
,
_document_authors
::
[
Author
]
,
_document_abstract
::
Maybe
T
.
Text
,
_document_publicationDate
::
Maybe
Int
,
_document_sources
::
[
Source
]
}
deriving
(
Show
,
Generic
)
L
.
makeLenses
''
D
ocument
instance
FromJSON
Document
where
parseJSON
(
Object
o
)
=
Document
<$>
(
o
.:
"id"
)
<*>
(
o
.:?
"title"
)
<*>
(
o
.:
"author"
<|>
pure
[]
)
<*>
(
o
.:?
"abstract"
)
<*>
do
pPubDate
<-
(
o
.:?
"publicationDate"
)
return
$
(
read
.
T
.
unpack
)
<$>
pPubDate
<*>
(
o
.:
"refBibs"
<|>
pure
[]
)
Document
<$>
(
o
.:
"id"
)
<*>
(
o
.:?
"title"
)
<*>
(
o
.:
"author"
<|>
pure
[]
)
<*>
(
o
.:?
"abstract"
)
<*>
((
o
.:?
"publicationDate"
)
>>=
\
date
->
return
$
fmap
(
read
.
T
.
unpack
)
date
)
<*>
(
o
.:
"refBibs"
<|>
pure
[]
)
data
Documents
=
Documents
{
_documents_total
::
Int
,
_documents_hits
::
[
Document
]
{
_documents_total
::
Int
,
_documents_hits
::
[
Document
]
}
deriving
(
Show
,
Generic
)
L
.
makeLenses
''
D
ocuments
instance
FromJSON
Documents
where
parseJSON
(
Object
o
)
=
Documents
<$>
(
o
.:
"total"
)
<*>
(
o
.:
"hits"
)
type
ISTEXAPI
=
Search
type
Search
=
QueryParam
"output"
T
.
Text
:>
QueryParam
"size"
Int
:>
QueryParam
"q"
T
.
Text
:>
Get
'[
J
SON
]
Documents
type
Search
=
QueryParam
"output"
T
.
Text
:>
QueryParam
"size"
Int
:>
QueryParam
"q"
T
.
Text
:>
Get
'[
J
SON
]
Documents
istexProxy
::
Proxy
(
ISTEXAPI
)
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