Commit 884906b4 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] (Still bug with Author search) + easy search function + doc.cabal.

parent 3b06f228
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Lib
import ISIDORE.Client
import Network.HTTP.Client (newManager)
import Network.HTTP.Client.TLS (tlsManagerSettings)
......@@ -12,8 +11,7 @@ main = do
manager' <- newManager tlsManagerSettings
res <- runClientM
(search
(Just 1)
(Just JSON)
(Just 10)
(Just "poison")
(Nothing))
(mkClientEnv manager' $ BaseUrl Https "api.isidore.science" 443 "resource")
......
......@@ -2,7 +2,7 @@
--
-- see: https://github.com/sol/hpack
--
-- hash: 81cc2f638a0cccea3e393883a34212b675a830c7654ae029d01acc5e922f87c0
-- hash: f8c91a232670fcf66018c2dc22039b92e3caf411691f9c10100f31a4337dc13d
name: crawlerIsidore
version: 0.1.0.0
......@@ -26,13 +26,22 @@ source-repository head
library
exposed-modules:
Lib
ISIDORE
ISIDORE.Client
other-modules:
Paths_crawlerIsidore
hs-source-dirs:
src
build-depends:
base >=4.7 && <5
aeson
, base >=4.7 && <5
, bytestring
, http-client
, http-client-tls
, http-media
, servant
, servant-client
, text
default-language: Haskell2010
executable crawlerIsidore-exe
......@@ -43,8 +52,16 @@ executable crawlerIsidore-exe
app
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
aeson
, base >=4.7 && <5
, bytestring
, crawlerIsidore
, http-client
, http-client-tls
, http-media
, servant
, servant-client
, text
default-language: Haskell2010
test-suite crawlerIsidore-test
......@@ -56,6 +73,14 @@ test-suite crawlerIsidore-test
test
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
aeson
, base >=4.7 && <5
, bytestring
, crawlerIsidore
, http-client
, http-client-tls
, http-media
, servant
, servant-client
, text
default-language: Haskell2010
name: crawlerIsidore
version: 0.1.0.0
github: "githubuser/crawlerIsidore"
github: "gitlab.iscpif.fr/gargantext/crawlers/crawlerIsidore"
license: BSD3
author: "Author name here"
maintainer: "example@example.com"
copyright: "2019 Author name here"
author: "CNRS/IMT"
maintainer: "contact@gargantext.org"
copyright: "2019 CNRS/IMT"
extra-source-files:
- README.md
......
{-# 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")
......@@ -9,6 +9,7 @@ module ISIDORE.Client where
import Servant.API
import Servant.Client
import GHC.Generics (Generic)
import Data.Proxy(Proxy(..))
import Data.ByteString.Lazy (ByteString)
import Data.Aeson
......@@ -22,9 +23,7 @@ data LocalContent = LocalContent
deriving (Show)
instance FromJSON LocalContent where
parseJSON (Object o) = LocalContent <$>
(o .: "@xml:lang")
<*> (o .: "$")
parseJSON (Object o) = LocalContent <$> (o .: "@xml:lang") <*> (o .: "$")
data Author = Author
{
......@@ -34,13 +33,12 @@ data Author = Author
deriving (Show)
instance FromJSON Author where
parseJSON (Object o) = Author <$>
(o .: "firstName")
<*> (o .: "lastName")
parseJSON (Object o) = Author <$> (o .: "firstName") <*> (o .: "lastName")
data MayBeLocal = Local LocalContent | NonLocal T.Text
deriving (Show)
deriving (Show, Generic)
instance FromJSON MayBeLocal
data IsidoreDoc = IsidoreDoc
{
......@@ -79,6 +77,6 @@ type Search = "search"
isidoreAPI :: Proxy ISIDOREAPI
isidoreAPI = Proxy
search :: Maybe Int -> Maybe Output -> Maybe T.Text -> Maybe T.Text -> ClientM T.Text
search :: Maybe Int -> Maybe T.Text -> Maybe T.Text -> ClientM T.Text
search n q a = client isidoreAPI n (Just JSON) q a
search = client isidoreAPI
module Lib
( someFunc
) where
someFunc :: IO ()
someFunc = putStrLn "someFunc"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment