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
160
Issues
160
List
Board
Labels
Milestones
Merge Requests
14
Merge Requests
14
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
9cc5159a
Commit
9cc5159a
authored
Jan 20, 2025
by
Alfredo Di Napoli
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support transfering of notes
parent
1fe60d75
Pipeline
#7242
passed with stages
in 53 minutes and 55 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
5 deletions
+18
-5
Remote.hs
src/Gargantext/API/Server/Named/Remote.hs
+18
-5
No files found.
src/Gargantext/API/Server/Named/Remote.hs
View file @
9cc5159a
...
...
@@ -24,7 +24,9 @@ import Data.ByteString.Lazy qualified as BL
import
Data.Conduit.Combinators
qualified
as
C
import
Data.Conduit.List
qualified
as
CL
import
Data.Foldable
(
for_
,
foldlM
)
import
Data.List
qualified
as
List
import
Data.List.Split
qualified
as
Split
import
Data.Monoid
import
Data.String
(
IsString
(
..
))
import
Data.Text.Encoding
qualified
as
TE
import
Data.Text
qualified
as
T
...
...
@@ -59,8 +61,8 @@ import Gargantext.Orphans ()
import
Gargantext.System.Logging
(
logLocM
,
LogLevel
(
..
),
MonadLogger
)
import
GHC.Generics
(
Generic
)
import
Network.HTTP.Client
qualified
as
HTTP
import
Network.HTTP.Types.Header
qualified
as
HTTP
import
Prelude
import
qualified
Network.HTTP.Types.Header
as
HTTP
import
Servant.Client.Streaming
(
mkClientEnv
,
withClientM
,
ClientError
)
import
Servant.Server.Generic
(
AsServerT
)
...
...
@@ -270,7 +272,7 @@ importNote :: (MonadIO m, MonadLogger m, HasBackendInternalError err, IsDBCmd en
->
m
HyperdataFrame
importNote
mgr
rawText
cfg
=
do
let
_hf_base
=
cfg
^.
gc_frames
.
f_write_url
case
HTTP
.
parseRequest
(
T
.
unpack
_hf_base
)
of
case
HTTP
.
parseRequest
(
T
.
unpack
_hf_base
`
appendPath
`
"/new"
)
of
Left
err
->
do
let
msg
=
"Couldn't extract a valid URL from "
<>
_hf_base
<>
", "
<>
T
.
pack
(
show
err
)
$
(
logLocM
)
ERROR
msg
...
...
@@ -280,10 +282,14 @@ importNote mgr rawText cfg = do
,
HTTP
.
requestHeaders
=
textMarkdown
:
(
HTTP
.
requestHeaders
rq0
)
,
HTTP
.
requestBody
=
HTTP
.
RequestBodyBS
(
TE
.
encodeUtf8
rawText
)
}
-- The response will contain the new path to the notes, where the last fragment
-- The response will contain
(in the redirects)
the new path to the notes, where the last fragment
-- is the frameId
res
<-
HTTP
.
responseBody
<$>
liftIO
(
HTTP
.
httpLbs
rq
mgr
)
let
_hf_frame_id
=
snd
$
T
.
breakOnEnd
"/"
(
TE
.
decodeUtf8
$
BL
.
toStrict
res
)
res
<-
liftIO
$
HTTP
.
withResponseHistory
rq
mgr
$
\
redirects
->
do
let
allLocations
=
map
(
First
.
List
.
lookup
HTTP
.
hLocation
.
HTTP
.
responseHeaders
.
snd
)
(
HTTP
.
hrRedirects
redirects
)
case
getFirst
$
mconcat
allLocations
of
Nothing
->
pure
mempty
Just
x
->
pure
x
let
_hf_frame_id
=
snd
$
T
.
breakOnEnd
"/"
(
TE
.
decodeUtf8
res
)
pure
$
HyperdataFrame
{
..
}
where
mk_err
msg
=
...
...
@@ -293,6 +299,13 @@ importNote mgr rawText cfg = do
textMarkdown
::
HTTP
.
Header
textMarkdown
=
(
HTTP
.
hContentType
,
fromString
"text/markdown"
)
-- | Append two URL paths together. The second argument must be given with an initial '/',
-- and must be non-null.
appendPath
::
String
->
String
->
String
appendPath
t
r
=
case
List
.
last
t
of
'/'
->
t
<>
List
.
tail
r
_
->
t
<>
r
checkNodesTypeAllowed
::
(
MonadError
e
m
,
HasNodeError
e
)
=>
Tree
(
Node
a
)
->
m
()
checkNodesTypeAllowed
(
TreeN
r
xs
)
=
do
checkNodeTypeAllowed
r
...
...
Przemyslaw Kaminski
@cgenie
mentioned in commit
942e663f
·
Jan 29, 2025
mentioned in commit
942e663f
mentioned in commit 942e663f539b287b4cc0469fe2bcf735813b4ff2
Toggle commit list
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