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
150
Issues
150
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
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
03d73fca
Commit
03d73fca
authored
Mar 03, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[list] add HTML list get endpoint
parent
a0bc6f1e
Pipeline
#761
failed with stage
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
9 deletions
+31
-9
List.hs
src/Gargantext/API/Ngrams/List.hs
+31
-9
No files found.
src/Gargantext/API/Ngrams/List.hs
View file @
03d73fca
...
...
@@ -12,6 +12,8 @@ Portability : POSIX
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
...
...
@@ -21,24 +23,36 @@ Portability : POSIX
module
Gargantext.API.Ngrams.List
where
import
Gargantext.Prelude
import
Gargantext.API.Ngrams
import
Servant
import
Data.Aeson
-- import qualified Data.ByteString.Lazy as BSL
import
Data.List
(
zip
)
import
Data.Map
(
Map
,
toList
,
fromList
)
import
Gargantext.Database.Types.Node
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
(
..
),
ngramsTypes
)
import
Gargantext.Database.Flow
(
FlowCmdM
)
-- import qualified Data.Text as T
-- import qualified Data.Text.Encoding as TE
import
Network.HTTP.Media
((
//
),
(
/:
))
import
Servant
import
Gargantext.Prelude
import
Gargantext.API.Ngrams
import
Gargantext.API.Types
(
GargServer
)
import
Gargantext.API.Ngrams
(
putListNgrams'
)
import
Gargantext.Database.Flow
(
FlowCmdM
)
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
(
..
),
ngramsTypes
)
import
Gargantext.Database.Types.Node
type
NgramsList
=
(
Map
NgramsType
(
Versioned
NgramsTableMap
))
data
HTML
instance
Accept
HTML
where
contentType
_
=
"text"
//
"html"
/:
(
"charset"
,
"utf-8"
)
instance
ToJSON
a
=>
MimeRender
HTML
a
where
mimeRender
_
=
encode
type
API
=
Get
'[
J
SON
]
NgramsList
:<|>
ReqBody
'[
J
SON
]
NgramsList
:>
Put
'[
J
SON
]
Bool
:<|>
Get
'[
H
TML
]
NgramsList
api
::
ListId
->
GargServer
API
api
l
=
get
l
:<|>
put
l
api
l
=
get
l
:<|>
put
l
:<|>
get
l
get
::
RepoCmdM
env
err
m
=>
ListId
->
m
NgramsList
...
...
@@ -46,6 +60,14 @@ get lId = fromList
<$>
zip
ngramsTypes
<$>
mapM
(
getNgramsTableMap
lId
)
ngramsTypes
getHtml
::
RepoCmdM
env
err
m
=>
ListId
->
m
NgramsList
getHtml
lId
=
do
lst
<-
get
lId
return
lst
--return $ TE.decodeUtf8 $ BSL.toStrict $ encode lst
-- TODO : purge list
put
::
FlowCmdM
env
err
m
=>
ListId
...
...
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