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
0832de16
Commit
0832de16
authored
Jan 19, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ini] strip trailing slash from ini urls
parent
defa83d9
Pipeline
#1357
failed with stage
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
20 deletions
+25
-20
Config.hs
src/Gargantext/Prelude/Config.hs
+25
-20
No files found.
src/Gargantext/Prelude/Config.hs
View file @
0832de16
...
...
@@ -17,26 +17,31 @@ import Prelude (read)
import
System.IO
(
FilePath
)
import
Data.Ini
(
readIniFile
,
lookupValue
)
import
Data.Either.Extra
(
Either
(
Left
,
Right
))
import
Gargantext.Prelude
import
Data.Text
(
Text
,
pack
)
import
Data.Text
as
T
import
GHC.Generics
(
Generic
)
import
Control.Lens
(
makeLenses
)
import
Gargantext.Prelude
data
GargConfig
=
GargConfig
{
_gc_url
::
!
Text
,
_gc_url_backend_api
::
!
Text
-- | strip a given character from end of string
stripRight
::
Char
->
T
.
Text
->
T
.
Text
stripRight
c
s
=
if
T
.
last
s
==
c
then
stripRight
c
(
T
.
take
(
T
.
length
s
-
1
)
s
)
else
s
,
_gc_masteruser
::
!
Text
,
_gc_secretkey
::
!
Text
data
GargConfig
=
GargConfig
{
_gc_url
::
!
T
.
Text
,
_gc_url_backend_api
::
!
T
.
Text
,
_gc_masteruser
::
!
T
.
Text
,
_gc_secretkey
::
!
T
.
Text
,
_gc_datafilepath
::
!
FilePath
,
_gc_repofilepath
::
!
FilePath
,
_gc_frame_write_url
::
!
Text
,
_gc_frame_calc_url
::
!
Text
,
_gc_frame_write_url
::
!
T
.
T
ext
,
_gc_frame_calc_url
::
!
T
.
T
ext
,
_gc_frame_searx_url
::
!
Text
,
_gc_frame_istex_url
::
!
Text
,
_gc_frame_searx_url
::
!
T
.
T
ext
,
_gc_frame_istex_url
::
!
T
.
T
ext
,
_gc_max_docs_scrapers
::
!
Integer
}
...
...
@@ -48,23 +53,23 @@ readConfig :: FilePath -> IO GargConfig
readConfig
fp
=
do
ini
<-
readIniFile
fp
let
ini''
=
case
ini
of
Left
e
->
panic
(
pack
$
"gargantext.ini not found"
<>
show
e
)
Left
e
->
panic
(
T
.
pack
$
"gargantext.ini not found"
<>
show
e
)
Right
ini'
->
ini'
let
val
x
=
case
(
lookupValue
(
pack
"gargantext"
)
(
pack
x
)
ini''
)
of
Left
_
->
panic
(
pack
$
"ERROR: add "
<>
x
<>
" to your gargantext.ini"
)
let
val
x
=
case
(
lookupValue
(
T
.
pack
"gargantext"
)
(
T
.
pack
x
)
ini''
)
of
Left
_
->
panic
(
T
.
pack
$
"ERROR: add "
<>
x
<>
" to your gargantext.ini"
)
Right
p'
->
p'
pure
$
GargConfig
(
val
"URL"
)
(
val
"URL_BACKEND_API"
)
pure
$
GargConfig
(
stripRight
'/'
$
val
"URL"
)
(
stripRight
'/'
$
val
"URL_BACKEND_API"
)
(
val
"MASTER_USER"
)
(
val
"SECRET_KEY"
)
(
cs
$
val
"DATA_FILEPATH"
)
(
cs
$
val
"REPO_FILEPATH"
)
(
val
"FRAME_WRITE_URL"
)
(
val
"FRAME_CALC_URL"
)
(
val
"FRAME_SEARX_URL"
)
(
val
"FRAME_ISTEX_URL"
)
(
stripRight
'/'
$
val
"FRAME_WRITE_URL"
)
(
stripRight
'/'
$
val
"FRAME_CALC_URL"
)
(
stripRight
'/'
$
val
"FRAME_SEARX_URL"
)
(
stripRight
'/'
$
val
"FRAME_ISTEX_URL"
)
(
read
$
cs
$
val
"MAX_DOCS_SCRAPERS"
)
{- UNUSED
...
...
@@ -80,4 +85,4 @@ defaultConfig = GargConfig "https://localhost"
"https://frame_searx.url"
"https://frame_istex.url"
1000
-}
\ No newline at end of file
-}
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