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
153
Issues
153
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
4f317061
Commit
4f317061
authored
Jan 09, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[export] texts: attachment with filename
parent
74015249
Pipeline
#3532
canceled with stage
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
Export.hs
src/Gargantext/API/Node/Document/Export.hs
+13
-7
Types.hs
src/Gargantext/API/Node/Document/Export/Types.hs
+2
-2
No files found.
src/Gargantext/API/Node/Document/Export.hs
View file @
4f317061
...
...
@@ -36,12 +36,15 @@ api uid dId = getDocumentsJSON uid dId
-- | Hashes are ordered by Set
getDocumentsJSON
::
UserId
->
DocId
->
GargNoServer
DocumentExport
->
GargNoServer
(
Headers
'[
H
eader
"Content-Disposition"
T
.
Text
]
DocumentExport
)
getDocumentsJSON
uId
pId
=
do
mcId
<-
getClosestParentIdByType
pId
NodeCorpus
let
cId
=
maybe
(
panic
"[G.A.N.D.Export] Node has no parent"
)
identity
mcId
docs
<-
runViewDocuments
cId
False
Nothing
Nothing
Nothing
Nothing
Nothing
pure
$
DocumentExport
{
_de_documents
=
mapFacetDoc
<$>
docs
pure
$
addHeader
(
T
.
concat
[
"attachment; filename=GarganText_DocsList-"
,
T
.
pack
$
show
pId
,
".json"
])
DocumentExport
{
_de_documents
=
mapFacetDoc
<$>
docs
,
_de_garg_version
=
T
.
pack
$
showVersion
PG
.
version
}
where
mapFacetDoc
(
FacetDoc
{
..
})
=
...
...
@@ -64,10 +67,13 @@ getDocumentsJSON uId pId = do
getDocumentsCSV
::
UserId
->
DocId
->
GargNoServer
T
.
Text
-- [Document]
->
GargNoServer
(
Headers
'[
H
eader
"Content-Disposition"
T
.
Text
]
T
.
Text
)
-- [Document]
getDocumentsCSV
uId
pId
=
do
DocumentExport
{
_de_documents
}
<-
getDocumentsJSON
uId
pId
dJSON
<-
getDocumentsJSON
uId
pId
let
DocumentExport
{
_de_documents
}
=
getResponse
dJSON
let
ret
=
TE
.
decodeUtf8
$
BSC
.
toStrict
$
encodeDefaultOrderedByName
_de_documents
pure
ret
pure
$
addHeader
(
T
.
concat
[
"attachment; filename=GarganText_DocsList-"
,
T
.
pack
$
show
pId
,
".csv"
])
ret
src/Gargantext/API/Node/Document/Export/Types.hs
View file @
4f317061
...
...
@@ -90,9 +90,9 @@ instance ToParamSchema Ngrams where
type
API
=
Summary
"Document Export"
:>
"export"
:>
(
"json"
:>
Get
'[
J
SON
]
DocumentExport
:>
Get
'[
J
SON
]
(
Headers
'[
S
ervant
.
Header
"Content-Disposition"
Text
]
DocumentExport
)
:<|>
"csv"
:>
Get
'[
P
lainText
]
Text
)
-- [Document])
:>
Get
'[
P
lainText
]
(
Headers
'[
S
ervant
.
Header
"Content-Disposition"
Text
]
Text
)
)
-- [Document])
$
(
deriveJSON
(
unPrefix
"_de_"
)
''
D
ocumentExport
)
$
(
deriveJSON
(
unPrefix
"_d_"
)
''
D
ocument
)
...
...
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