Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
isidore
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
isidore
Commits
3b06f228
Commit
3b06f228
authored
Jun 13, 2019
by
Mael NICOLAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stuck on the "" | {} fromJSON instance
parent
5136b6b8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
2 deletions
+53
-2
Main.hs
app/Main.hs
+2
-1
package.yaml
package.yaml
+1
-0
Client.hs
src/ISIDORE/Client.hs
+50
-1
No files found.
app/Main.hs
View file @
3b06f228
...
@@ -12,8 +12,9 @@ main = do
...
@@ -12,8 +12,9 @@ main = do
manager'
<-
newManager
tlsManagerSettings
manager'
<-
newManager
tlsManagerSettings
res
<-
runClientM
res
<-
runClientM
(
search
(
search
(
Just
1
)
(
Just
JSON
)
(
Just
JSON
)
(
Just
"
colza
"
)
(
Just
"
poison
"
)
(
Nothing
))
(
Nothing
))
(
mkClientEnv
manager'
$
BaseUrl
Https
"api.isidore.science"
443
"resource"
)
(
mkClientEnv
manager'
$
BaseUrl
Https
"api.isidore.science"
443
"resource"
)
case
res
of
case
res
of
...
...
package.yaml
View file @
3b06f228
...
@@ -21,6 +21,7 @@ description: Please see the README on GitHub at <https://github.com/gith
...
@@ -21,6 +21,7 @@ description: Please see the README on GitHub at <https://github.com/gith
dependencies
:
dependencies
:
-
base >= 4.7 && < 5
-
base >= 4.7 && < 5
-
aeson
-
servant
-
servant
-
servant-client
-
servant-client
-
text
-
text
...
...
src/ISIDORE/Client.hs
View file @
3b06f228
...
@@ -11,8 +11,56 @@ import Servant.Client
...
@@ -11,8 +11,56 @@ import Servant.Client
import
Data.Proxy
(
Proxy
(
..
))
import
Data.Proxy
(
Proxy
(
..
))
import
Data.ByteString.Lazy
(
ByteString
)
import
Data.ByteString.Lazy
(
ByteString
)
import
Data.Aeson
import
qualified
Data.Text
as
T
import
qualified
Data.Text
as
T
data
LocalContent
=
LocalContent
{
_lang
::
T
.
Text
,
_content
::
T
.
Text
}
deriving
(
Show
)
instance
FromJSON
LocalContent
where
parseJSON
(
Object
o
)
=
LocalContent
<$>
(
o
.:
"@xml:lang"
)
<*>
(
o
.:
"$"
)
data
Author
=
Author
{
_firstName
::
T
.
Text
,
_lastName
::
T
.
Text
}
deriving
(
Show
)
instance
FromJSON
Author
where
parseJSON
(
Object
o
)
=
Author
<$>
(
o
.:
"firstName"
)
<*>
(
o
.:
"lastName"
)
data
MayBeLocal
=
Local
LocalContent
|
NonLocal
T
.
Text
deriving
(
Show
)
data
IsidoreDoc
=
IsidoreDoc
{
_title
::
MayBeLocal
,
_abstract
::
MayBeLocal
,
_authors
::
[
Author
]
}
deriving
(
Show
)
instance
FromJSON
IsidoreDoc
where
parseJSON
(
Object
o
)
=
IsidoreDoc
<$>
(
responseReplies
>>=
(
.:
"title"
)
)
<*>
(
responseReplies
>>=
(
.:
"abstract"
))
<*>
(
responseReplies
>>=
(
.:
"enrichedCreators"
)
>>=
(
.:
"creator"
))
where
responseReplies
=
(
o
.:
"response"
)
>>=
(
.:
"replies"
)
>>=
(
.:
"content"
)
>>=
(
.:
"reply"
)
>>=
(
.:
"isidore"
)
data
Output
=
JSON
data
Output
=
JSON
instance
ToHttpApiData
Output
where
instance
ToHttpApiData
Output
where
...
@@ -22,6 +70,7 @@ type ISIDOREAPI = Search
...
@@ -22,6 +70,7 @@ type ISIDOREAPI = Search
-- search?q=colza&output=json&replies=1&author=jm&
-- search?q=colza&output=json&replies=1&author=jm&
type
Search
=
"search"
type
Search
=
"search"
:>
QueryParam
"replies"
Int
:>
QueryParam
"output"
Output
:>
QueryParam
"output"
Output
:>
QueryParam
"q"
T
.
Text
:>
QueryParam
"q"
T
.
Text
:>
QueryParam
"author"
T
.
Text
:>
QueryParam
"author"
T
.
Text
...
@@ -30,6 +79,6 @@ type Search = "search"
...
@@ -30,6 +79,6 @@ type Search = "search"
isidoreAPI
::
Proxy
ISIDOREAPI
isidoreAPI
::
Proxy
ISIDOREAPI
isidoreAPI
=
Proxy
isidoreAPI
=
Proxy
search
::
Maybe
Output
->
Maybe
T
.
Text
->
Maybe
T
.
Text
->
ClientM
T
.
Text
search
::
Maybe
Int
->
Maybe
Output
->
Maybe
T
.
Text
->
Maybe
T
.
Text
->
ClientM
T
.
Text
search
=
client
isidoreAPI
search
=
client
isidoreAPI
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