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
069118b2
Commit
069118b2
authored
Jun 14, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DOC] fix API.
parent
bfb0e7d8
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
33 deletions
+64
-33
Main.hs
app/Main.hs
+2
-2
crawlerIsidore.cabal
crawlerIsidore.cabal
+3
-6
ISIDORE.hs
src/ISIDORE.hs
+0
-13
Isidore.hs
src/Isidore.hs
+43
-0
Client.hs
src/Isidore/Client.hs
+16
-12
No files found.
app/Main.hs
View file @
069118b2
{-# LANGUAGE OverloadedStrings #-}
module
Main
where
import
I
SIDORE
.Client
import
I
sidore
.Client
import
Network.HTTP.Client
(
newManager
)
import
Network.HTTP.Client.TLS
(
tlsManagerSettings
)
import
Servant.Client
...
...
@@ -10,7 +10,7 @@ main :: IO ()
main
=
do
manager'
<-
newManager
tlsManagerSettings
res
<-
runClientM
(
search
(
clientIsidore
(
Just
10
)
(
Just
"poison"
)
(
Nothing
))
...
...
crawlerIsidore.cabal
View file @
069118b2
...
...
@@ -2,7 +2,7 @@
--
-- see: https://github.com/sol/hpack
--
-- hash:
7f8443023714c385aa78461bf264946e215e8e840afeaf9e117216f86773fe67
-- hash:
37b28b3c7df7f52e571a3f00f87a54ca95eb656d9c0fbfe562bacbfcccb6ab6d
name: crawlerIsidore
version: 0.1.0.0
...
...
@@ -26,8 +26,8 @@ source-repository head
library
exposed-modules:
I
SIDORE
I
SIDORE
.Client
I
sidore
I
sidore
.Client
other-modules:
Paths_crawlerIsidore
hs-source-dirs:
...
...
@@ -41,7 +41,6 @@ library
, http-media
, servant
, servant-client
, servant-server
, text
, vector
default-language: Haskell2010
...
...
@@ -63,7 +62,6 @@ executable crawlerIsidore-exe
, http-media
, servant
, servant-client
, servant-server
, text
, vector
default-language: Haskell2010
...
...
@@ -86,7 +84,6 @@ test-suite crawlerIsidore-test
, http-media
, servant
, servant-client
, servant-server
, text
, vector
default-language: Haskell2010
src/ISIDORE.hs
deleted
100644 → 0
View file @
bfb0e7d8
{-# LANGUAGE OverloadedStrings #-}
module
ISIDORE
where
import
ISIDORE.Client
import
Network.HTTP.Client
(
newManager
)
import
Network.HTTP.Client.TLS
(
tlsManagerSettings
)
import
Servant.Client
-- crawler :: IO ()
crawler
n
q
a
=
do
manager'
<-
newManager
tlsManagerSettings
runClientM
(
search
n
q
a
)
(
mkClientEnv
manager'
$
BaseUrl
Https
"api.isidore.science"
443
"resource"
)
src/Isidore.hs
0 → 100644
View file @
069118b2
{-|
Module : Gargantext
Description : Textmining Collaborative Platform
Copyright : (c) CNRS/IMT, 2019-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
Examples:
- For a "portrait":
either (\(DecodeFailure e _) -> error $ show e) (length . _docs) <$> get (Just 100) Nothing (Just "anheim_etienne")
- For a "paysage":
either (\(DecodeFailure e _) -> error $ show e) (length . _docs) <$> get (Just 100) (Just "peste noire") Nothing
-}
{-# LANGUAGE OverloadedStrings #-}
module
Isidore
where
import
Isidore.Client
import
Network.HTTP.Client
(
newManager
)
import
Network.HTTP.Client.TLS
(
tlsManagerSettings
)
import
Servant.Client
import
Data.Maybe
(
Maybe
)
import
Data.Text
(
Text
)
import
Data.Either
(
Either
,
either
)
type
Limit
=
Int
type
TextQuery
=
Text
type
AuthorQuery
=
Text
get
::
Maybe
Limit
->
Maybe
TextQuery
->
Maybe
AuthorQuery
->
IO
(
Either
ServantError
Reply
)
get
n
q
a
=
do
manager'
<-
newManager
tlsManagerSettings
runClientM
(
clientIsidore
n
q
a
)
(
mkClientEnv
manager'
$
BaseUrl
Https
"api.isidore.science"
443
"resource"
)
src/I
SIDORE
/Client.hs
→
src/I
sidore
/Client.hs
View file @
069118b2
{-|
Module : Gargantext
Description : Textmining Collaborative Platform
Copyright : (c) CNRS/IMT, 2019-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FlexibleInstances #-}
module
ISIDORE.Client
where
module
Isidore.Client
where
import
Control.Monad
import
Servant.API
...
...
@@ -105,26 +116,19 @@ instance FromJSON IsidoreDoc where
instance
FromJSON
Reply
where
parseJSON
(
Object
o
)
=
Reply
<$>
(
responseReplies
>>=
parseJSON
)
-- <*> (responseReplies >>= (.: "abstract") >>= (.: "$"))
-- <*> (responseReplies >>= (.: "date") >>= (.: "origin"))
-- <*> (responseReplies >>= (.: "enrichedCreators") >>= (.: "creator"))
where
responseReplies
=
(
o
.:
"response"
)
>>=
(
.:
"replies"
)
>>=
(
.:
"content"
)
>>=
(
.:
"reply"
)
-- docs = mapM (\r -> IsidoreDoc <$> (r .: "isidore") >>= (.: "title")) responseReplies
-- >>= (.: "$"))
-- >>= (.: "isidore")
data
Output
=
JSON
instance
ToHttpApiData
Output
where
toUrlPiece
JSON
=
"json"
type
I
SIDORE
API
=
Search
type
I
sidore
API
=
Search
-- search?q=colza&output=json&replies=1&author=jm&
type
Search
=
"search"
:>
QueryParam
"replies"
Int
:>
QueryParam
"output"
Output
...
...
@@ -132,10 +136,10 @@ type Search = "search"
:>
QueryParam
"author"
T
.
Text
:>
Get
'[
J
SON
]
Reply
isidoreAPI
::
Proxy
I
SIDORE
API
isidoreAPI
::
Proxy
I
sidore
API
isidoreAPI
=
Proxy
search
::
Maybe
Int
->
Maybe
T
.
Text
->
Maybe
T
.
Text
->
ClientM
Reply
search
n
q
a
=
client
isidoreAPI
n
(
Just
JSON
)
q
a
clientIsidore
::
Maybe
Int
->
Maybe
T
.
Text
->
Maybe
T
.
Text
->
ClientM
Reply
clientIsidore
n
q
a
=
client
isidoreAPI
n
(
Just
JSON
)
q
a
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