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
775049e4
Commit
775049e4
authored
Mar 04, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-list-downloadable-with-content-type' into dev
parents
989cc231
6755aad5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
14 deletions
+35
-14
API.hs
src/Gargantext/API.hs
+1
-1
List.hs
src/Gargantext/API/Ngrams/List.hs
+30
-11
Settings.hs
src/Gargantext/API/Settings.hs
+4
-2
No files found.
src/Gargantext/API.hs
View file @
775049e4
...
...
@@ -208,7 +208,7 @@ type GargAPI' =
-- auth and capabilities.
:<|>
GargPrivateAPI
type
GargPrivateAPI
=
SA
.
Auth
'[
S
A
.
JWT
]
AuthenticatedUser
:>
GargPrivateAPI'
type
GargPrivateAPI
=
SA
.
Auth
'[
S
A
.
JWT
,
SA
.
Cookie
]
AuthenticatedUser
:>
GargPrivateAPI'
type
GargAdminAPI
-- Roots endpoint
...
...
src/Gargantext/API/Ngrams/List.hs
View file @
775049e4
...
...
@@ -12,6 +12,8 @@ Portability : POSIX
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
...
...
@@ -21,31 +23,48 @@ Portability : POSIX
module
Gargantext.API.Ngrams.List
where
import
Gargantext.Prelude
import
Gargantext.API.Ngrams
import
Servant
import
Data.Text
(
Text
,
concat
,
pack
)
import
Data.Aeson
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
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
))
type
API
=
Get
'[
J
SON
]
NgramsList
:<|>
ReqBody
'[
J
SON
]
NgramsList
:>
Put
'[
J
SON
]
Bool
data
HTML
instance
Accept
HTML
where
contentType
_
=
"text"
//
"html"
/:
(
"charset"
,
"utf-8"
)
instance
ToJSON
a
=>
MimeRender
HTML
a
where
mimeRender
_
=
encode
type
API
=
ReqBody
'[
J
SON
]
NgramsList
:>
Put
'[
J
SON
]
Bool
:<|>
Get
'[
H
TML
]
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsList
)
api
::
ListId
->
GargServer
API
api
l
=
get
l
:<|>
put
l
api
l
=
put
l
:<|>
getHtml
l
get
::
RepoCmdM
env
err
m
get
::
RepoCmdM
env
err
m
=>
ListId
->
m
NgramsList
get
lId
=
fromList
<$>
zip
ngramsTypes
<$>
mapM
(
getNgramsTableMap
lId
)
ngramsTypes
getHtml
::
RepoCmdM
env
err
m
=>
ListId
->
m
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsList
)
getHtml
lId
=
do
lst
<-
get
lId
let
(
NodeId
id
)
=
lId
return
$
addHeader
(
concat
[
"attachment; filename=GarganText_NgramsList-"
,
pack
$
show
id
,
".json"
])
lst
-- TODO : purge list
put
::
FlowCmdM
env
err
m
=>
ListId
...
...
src/Gargantext/API/Settings.hs
View file @
775049e4
...
...
@@ -48,7 +48,7 @@ import Data.ByteString (ByteString)
import
qualified
Data.ByteString.Lazy
as
L
import
Servant
import
Servant.Auth.Server
(
defaultJWTSettings
,
JWTSettings
,
CookieSettings
,
default
CookieSettings
,
readKey
,
writeKey
)
import
Servant.Auth.Server
(
defaultJWTSettings
,
JWTSettings
,
CookieSettings
(
..
),
XsrfCookieSettings
(
..
),
defaultCookieSettings
,
defaultXsrf
CookieSettings
,
readKey
,
writeKey
)
import
Servant.Client
(
BaseUrl
,
parseBaseUrl
)
import
qualified
Servant.Job.Core
import
Servant.Job.Async
(
newJobEnv
,
defaultSettings
,
HasJobEnv
(
..
),
Job
)
...
...
@@ -106,9 +106,11 @@ devSettings jwkFile = do
,
_sendLoginEmails
=
LogEmailToConsole
,
_scrapydUrl
=
fromMaybe
(
panic
"Invalid scrapy URL"
)
$
parseBaseUrl
"http://localhost:6800"
,
_fileFolder
=
"data"
,
_cookieSettings
=
defaultCookieSettings
-- TODO-SECURITY tune
,
_cookieSettings
=
defaultCookieSettings
{
cookieXsrfSetting
=
Just
xsrfCookieSetting
}
-- TODO-SECURITY tune
,
_jwtSettings
=
defaultJWTSettings
jwk
-- TODO-SECURITY tune
}
where
xsrfCookieSetting
=
defaultXsrfCookieSettings
{
xsrfExcludeGet
=
True
}
...
...
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