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
d424a377
Commit
d424a377
authored
Mar 13, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[graph] add gexf API endpoint
parent
9d461c2e
Pipeline
#779
failed with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
API.hs
src/Gargantext/Viz/Graph/API.hs
+8
-5
No files found.
src/Gargantext/Viz/Graph/API.hs
View file @
d424a377
...
...
@@ -31,6 +31,7 @@ import Control.Monad.IO.Class (liftIO)
import
qualified
Data.HashMap.Lazy
as
HashMap
import
qualified
Data.Map
as
Map
import
Data.Maybe
(
Maybe
(
..
))
import
Data.Text
import
Servant
import
Servant.XML
import
qualified
Xmlbf
as
Xmlbf
...
...
@@ -53,6 +54,8 @@ import Gargantext.Viz.Graph
import
qualified
Gargantext.Viz.Graph
as
G
import
Gargantext.Viz.Graph.Tools
-- (cooc2graph)
-- Converts to GEXF format
-- See https://gephi.org/gexf/format/
instance
Xmlbf
.
ToXml
Graph
where
toXml
(
Graph
{
_graph_nodes
=
graphNodes
,
_graph_edges
=
graphEdges
})
=
root
graphNodes
graphEdges
...
...
@@ -66,8 +69,8 @@ instance Xmlbf.ToXml Graph where
meta
=
Xmlbf
.
element
"meta"
params
$
creator
<>
description
where
params
=
HashMap
.
fromList
[
(
"lastmodifieddate"
,
"2020-03-13"
)
]
creator
=
Xmlbf
.
element
"
Gargantext.org"
HashMap
.
empty
[]
description
=
Xmlbf
.
element
"
Gargantext gexf file"
HashMap
.
empty
[]
creator
=
Xmlbf
.
element
"
creator"
HashMap
.
empty
$
Xmlbf
.
text
"Gargantext.org"
description
=
Xmlbf
.
element
"
description"
HashMap
.
empty
$
Xmlbf
.
text
"Gargantext gexf file"
graph
::
[
G
.
Node
]
->
[
G
.
Edge
]
->
[
Xmlbf
.
Node
]
graph
gn
ge
=
Xmlbf
.
element
"graph"
params
$
(
nodes
gn
)
<>
(
edges
ge
)
where
...
...
@@ -98,7 +101,7 @@ instance Xmlbf.ToXml Graph where
type
GraphAPI
=
Get
'[
J
SON
]
Graph
:<|>
Post
'[
J
SON
]
[
GraphId
]
:<|>
Put
'[
J
SON
]
Int
:<|>
"gexf"
:>
Get
'[
X
ML
]
Graph
:<|>
"gexf"
:>
Get
'[
X
ML
]
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
Graph
)
graphAPI
::
UserId
->
NodeId
->
GargServer
GraphAPI
...
...
@@ -193,7 +196,7 @@ putGraph :: NodeId -> GargServer (Put '[JSON] Int)
putGraph
=
undefined
getGraphGexf
::
UserId
->
NodeId
->
GargNoServer
Graph
getGraphGexf
::
UserId
->
NodeId
->
GargNoServer
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
Graph
)
getGraphGexf
uId
nId
=
do
graph
<-
getGraph
uId
nId
pure
graph
pure
$
addHeader
(
concat
[
"attachment; filename=graph.gexf"
])
graph
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