Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
11
Merge Requests
11
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
haskell-gargantext
Commits
cf953746
Commit
cf953746
authored
Feb 07, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TEXT] String to Text in Servant file.
parent
ca5569fb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
13 deletions
+16
-13
Prelude.hs
src/Gargantext/Prelude.hs
+1
-1
Server.hs
src/Gargantext/Server.hs
+15
-12
No files found.
src/Gargantext/Prelude.hs
View file @
cf953746
...
@@ -24,7 +24,7 @@ import Protolude ( Bool(True, False), Int, Double, Integer
...
@@ -24,7 +24,7 @@ import Protolude ( Bool(True, False), Int, Double, Integer
,
sum
,
fromIntegral
,
length
,
fmap
,
sum
,
fromIntegral
,
length
,
fmap
,
takeWhile
,
sqrt
,
undefined
,
identity
,
takeWhile
,
sqrt
,
undefined
,
identity
,
abs
,
maximum
,
minimum
,
return
,
snd
,
truncate
,
abs
,
maximum
,
minimum
,
return
,
snd
,
truncate
,
(
+
),
(
*
),
(
/
),
(
-
),
(
.
),
(
>=
),
(
$
),
(
**
),
(
^
),
(
<
),
(
>
),
(
==
)
,
(
+
),
(
*
),
(
/
),
(
-
),
(
.
),
(
>=
),
(
$
),
(
**
),
(
^
),
(
<
),
(
>
),
(
==
)
,
(
<>
)
)
)
-- TODO import functions optimized in Utils.Count
-- TODO import functions optimized in Utils.Count
...
...
src/Gargantext/Server.hs
View file @
cf953746
...
@@ -8,6 +8,8 @@ Maintainer : team@gargantext.org
...
@@ -8,6 +8,8 @@ Maintainer : team@gargantext.org
Stability : experimental
Stability : experimental
Portability : POSIX
Portability : POSIX
Main REST API of Gargantext (both Server and Client sides)
-}
-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
...
@@ -20,7 +22,8 @@ module Gargantext.Server
...
@@ -20,7 +22,8 @@ module Gargantext.Server
-- )
-- )
where
where
import
Prelude
hiding
(
null
)
import
Gargantext.Prelude
import
Control.Monad
import
Control.Monad
import
Control.Monad.IO.Class
import
Control.Monad.IO.Class
import
Data.Aeson
import
Data.Aeson
...
@@ -30,8 +33,8 @@ import Servant
...
@@ -30,8 +33,8 @@ import Servant
import
Servant.Multipart
import
Servant.Multipart
import
Database.PostgreSQL.Simple
(
Connection
,
connect
)
import
Database.PostgreSQL.Simple
(
Connection
,
connect
)
import
Opaleye
import
Opaleye
import
System.IO
(
FilePath
)
import
System.IO
(
FilePath
,
putStrLn
,
readFile
,
print
)
import
Data.Text
(
Text
(),
pack
)
import
Gargantext.Types.Main
(
Node
,
NodeId
)
import
Gargantext.Types.Main
(
Node
,
NodeId
)
import
Gargantext.Database.Node
(
getNodesWithParentId
,
getNode
)
import
Gargantext.Database.Node
(
getNodesWithParentId
,
getNode
)
import
Gargantext.Database.Private
(
databaseParameters
)
import
Gargantext.Database.Private
(
databaseParameters
)
...
@@ -43,8 +46,8 @@ type NodeAPI = Get '[JSON] (Node Value)
...
@@ -43,8 +46,8 @@ type NodeAPI = Get '[JSON] (Node Value)
type
API
=
"roots"
:>
Get
'[
J
SON
]
[
Node
Value
]
type
API
=
"roots"
:>
Get
'[
J
SON
]
[
Node
Value
]
:<|>
"node"
:>
Capture
"id"
Int
:>
NodeAPI
:<|>
"node"
:>
Capture
"id"
Int
:>
NodeAPI
:<|>
"echo"
:>
Capture
"string"
String
:>
Get
'[
J
SON
]
String
:<|>
"echo"
:>
Capture
"string"
Text
:>
Get
'[
J
SON
]
Text
:<|>
"upload"
:>
MultipartForm
MultipartData
:>
Post
'[
J
SON
]
String
:<|>
"upload"
:>
MultipartForm
MultipartData
:>
Post
'[
J
SON
]
Text
-- :<|> "node" :> Capture "id" Int :> Get '[JSON] Node
-- :<|> "node" :> Capture "id" Int :> Get '[JSON] Node
...
@@ -60,7 +63,7 @@ server conn
...
@@ -60,7 +63,7 @@ server conn
startGargantext
::
FilePath
->
IO
()
startGargantext
::
FilePath
->
IO
()
startGargantext
file
=
do
startGargantext
file
=
do
print
(
"Starting server on port "
++
show
port
)
print
(
"Starting server on port "
<>
show
port
)
param
<-
databaseParameters
file
param
<-
databaseParameters
file
conn
<-
connect
param
conn
<-
connect
param
...
@@ -90,17 +93,17 @@ nodeAPI conn id
...
@@ -90,17 +93,17 @@ nodeAPI conn id
-- | Upload files
-- | Upload files
-- TODO Is it possible to adapt the function according to iValue input ?
-- TODO Is it possible to adapt the function according to iValue input ?
upload
::
MultipartData
->
Handler
String
upload
::
MultipartData
->
Handler
Text
upload
multipartData
=
do
upload
multipartData
=
do
liftIO
$
do
liftIO
$
do
putStrLn
"Inputs:"
putStrLn
"Inputs:"
forM_
(
inputs
multipartData
)
$
\
input
->
forM_
(
inputs
multipartData
)
$
\
input
->
putStrLn
$
" "
++
show
(
iName
input
)
putStrLn
$
" "
<>
show
(
iName
input
)
++
" -> "
++
show
(
iValue
input
)
<>
" -> "
<>
show
(
iValue
input
)
forM_
(
files
multipartData
)
$
\
file
->
do
forM_
(
files
multipartData
)
$
\
file
->
do
content
<-
readFile
(
fdFilePath
file
)
content
<-
readFile
(
fdFilePath
file
)
putStrLn
$
"Content of "
++
show
(
fdFileName
file
)
putStrLn
$
"Content of "
<>
show
(
fdFileName
file
)
++
" at "
++
fdFilePath
file
<>
" at "
<>
fdFilePath
file
putStrLn
content
putStrLn
content
pure
"Data loaded"
pure
(
pack
"Data loaded"
)
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