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