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
199
Issues
199
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
6999a68e
Commit
6999a68e
authored
Sep 28, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] Public screenshot to public home
parent
d0101d87
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
31 deletions
+59
-31
gargantext.ini_toModify
gargantext.ini_toModify
+4
-0
API.hs
src/Gargantext/API.hs
+16
-11
Public.hs
src/Gargantext/API/Public.hs
+28
-16
Share.hs
src/Gargantext/Database/Action/Share.hs
+1
-1
Node.hs
src/Gargantext/Database/Admin/Types/Node.hs
+3
-0
Config.hs
src/Gargantext/Prelude/Config.hs
+7
-3
No files found.
gargantext.ini_toModify
View file @
6999a68e
[gargantext]
# API url for server
URL = http://localhost:8008/api/v1.0
# Needed to instantiate the first users and first data
MASTER_USER = gargantua
...
...
src/Gargantext/API.hs
View file @
6999a68e
...
...
@@ -54,6 +54,7 @@ import Data.Version (showVersion)
import
GHC.Base
(
Applicative
)
import
GHC.Generics
(
D1
,
Meta
(
..
),
Rep
,
Generic
)
import
GHC.TypeLits
(
AppendSymbol
,
Symbol
)
import
Gargantext.Prelude.Config
(
gc_url
)
import
Gargantext.API.Admin.Auth
(
AuthContext
,
auth
)
import
Gargantext.API.Admin.FrontEnd
(
frontEndServer
)
import
Gargantext.API.Admin.Settings
...
...
@@ -86,7 +87,10 @@ startGargantext :: Mode -> PortNumber -> FilePath -> IO ()
startGargantext
mode
port
file
=
do
env
<-
newEnv
port
file
portRouteInfo
port
app
<-
makeApp
env
let
baseUrl
=
env
^.
env_gargConfig
.
gc_url
app
<-
makeApp
env
baseUrl
mid
<-
makeDevMiddleware
mode
run
port
(
mid
app
)
`
finally
`
stopGargantext
env
...
...
@@ -214,36 +218,37 @@ makeDevMiddleware mode = do
-- | API Global
---------------------------------------------------------------------
-- | Server declarations
server
::
forall
env
.
EnvC
env
=>
env
->
IO
(
Server
API
)
server
env
=
do
server
::
forall
env
.
EnvC
env
=>
env
->
Text
->
IO
(
Server
API
)
server
env
baseUrl
=
do
-- orchestrator <- scrapyOrchestrator env
pure
$
schemaUiServer
swaggerDoc
:<|>
hoistServerWithContext
(
Proxy
::
Proxy
GargAPI
)
(
Proxy
::
Proxy
AuthContext
)
transform
serverGargAPI
(
serverGargAPI
baseUrl
)
:<|>
frontEndServer
where
transform
::
forall
a
.
GargServerM
env
GargError
a
->
Handler
a
transform
=
Handler
.
withExceptT
showAsServantErr
.
(`
runReaderT
`
env
)
showAsServantErr
::
GargError
->
ServerError
showAsServantErr
(
GargServerError
err
)
=
err
showAsServantErr
a
=
err500
{
errBody
=
BL8
.
pack
$
show
a
}
---------------------------
serverGargAPI
::
GargServerT
env
err
(
GargServerM
env
err
)
GargAPI
serverGargAPI
-- orchestrator
serverGargAPI
::
Text
->
GargServerT
env
err
(
GargServerM
env
err
)
GargAPI
serverGargAPI
baseUrl
-- orchestrator
=
auth
:<|>
gargVersion
:<|>
serverPrivateGargAPI
:<|>
Public
.
api
:<|>
(
Public
.
api
baseUrl
)
-- :<|> orchestrator
where
gargVersion
::
GargServer
GargVersion
gargVersion
=
pure
(
cs
$
showVersion
PG
.
version
)
...
...
@@ -265,8 +270,8 @@ serverGargAdminAPI = roots
--gargMock :: Server GargAPI
--gargMock = mock apiGarg Proxy
---------------------------------------------------------------------
makeApp
::
EnvC
env
=>
env
->
IO
Application
makeApp
env
=
serveWithContext
api
cfg
<$>
server
env
makeApp
::
EnvC
env
=>
env
->
Text
->
IO
Application
makeApp
env
baseUrl
=
serveWithContext
api
cfg
<$>
server
env
baseUrl
where
cfg
::
Servant
.
Context
AuthContext
cfg
=
env
^.
settings
.
jwtSettings
...
...
src/Gargantext/API/Public.hs
View file @
6999a68e
...
...
@@ -41,8 +41,11 @@ type API = Summary " Public API"
:>
Get
'[
J
SON
]
[
PublicData
]
api
::
HasNodeError
err
=>
Cmd
err
[
PublicData
]
api
=
catMaybes
<$>
map
toPublicData
<$>
filterPublicDatas
<$>
selectPublic
=>
Text
->
Cmd
err
[
PublicData
]
api
base
=
catMaybes
<$>
map
(
toPublicData
base
)
<$>
filterPublicDatas
<$>
selectPublic
selectPublic
::
HasNodeError
err
...
...
@@ -52,20 +55,24 @@ selectPublic = selectPublicNodes
-- For tests only
-- pure $ replicate 6 defaultPublicData
filterPublicDatas
::
[(
Node
HyperdataFolder
,
Maybe
Int
)]
->
[(
Node
HyperdataFolder
,
[
NodeId
])]
filterPublicDatas
datas
=
map
(
\
(
n
,
mi
)
->
let
mi'
=
NodeId
<$>
mi
in
(
_node_id
n
,
(
n
,
maybe
[]
(
:
[]
)
mi'
))
)
datas
&
Map
.
fromListWith
(
\
(
n1
,
i1
)
(
_n2
,
i2
)
->
(
n1
,
i1
<>
i2
))
&
Map
.
filter
(
not
.
null
.
snd
)
&
Map
.
elems
toPublicData
::
(
Node
HyperdataFolder
,
[
NodeId
])
->
Maybe
PublicData
toPublicData
(
n
,
_mn
)
=
PublicData
<$>
(
hd
^?
(
_Just
.
hf_data
.
cf_title
))
<*>
(
hd
^?
(
_Just
.
hf_data
.
cf_desc
))
<*>
Just
"images/Gargantextuel-212x300.jpg"
<*>
Just
"https://.."
filterPublicDatas
::
[(
Node
HyperdataFolder
,
Maybe
Int
)]
->
[(
Node
HyperdataFolder
,
[
NodeId
])]
filterPublicDatas
datas
=
map
(
\
(
n
,
mi
)
->
let
mi'
=
NodeId
<$>
mi
in
(
_node_id
n
,
(
n
,
maybe
[]
(
:
[]
)
mi'
))
)
datas
&
Map
.
fromListWith
(
\
(
n1
,
i1
)
(
_n2
,
i2
)
->
(
n1
,
i1
<>
i2
))
&
Map
.
filter
(
not
.
null
.
snd
)
&
Map
.
elems
-- http://localhost:8008/api/v1.0/node/23543/file/download<Paste>
-- http://localhost:8000/images/Gargantextuel-212x300.jpg
toPublicData
::
Text
->
(
Node
HyperdataFolder
,
[
NodeId
])
->
Maybe
PublicData
toPublicData
base
(
n
,
mn
)
=
PublicData
<$>
(
hd
^?
(
_Just
.
hf_data
.
cf_title
))
<*>
(
hd
^?
(
_Just
.
hf_data
.
cf_desc
))
<*>
(
Just
$
url'
mn
)
-- "images/Gargantextuel-212x300.jpg"
<*>
(
Just
$
url'
mn
)
<*>
Just
(
cs
$
show
$
utc2year
(
n
^.
node_date
))
<*>
(
hd
^?
(
_Just
.
hf_data
.
cf_query
))
<*>
(
hd
^?
(
_Just
.
hf_data
.
cf_authors
))
...
...
@@ -73,6 +80,11 @@ toPublicData (n , _mn) = PublicData <$> (hd ^? (_Just . hf_data . cf_title))
hd
=
head
$
filter
(
\
(
HyperdataField
cd
_
_
)
->
cd
==
JSON
)
$
n
^.
(
node_hyperdata
.
hc_fields
)
url'
::
[
NodeId
]
->
Text
url'
mn'
=
base
<>
"/node/"
<>
(
cs
$
show
$
(
maybe
0
unNodeId
$
head
mn'
))
<>
"/file/download"
data
PublicData
=
PublicData
...
...
src/Gargantext/Database/Action/Share.hs
View file @
6999a68e
...
...
@@ -29,7 +29,7 @@ import Gargantext.Prelude
-- | TODO move in Config of Gargantext
publicNodeTypes
::
[
NodeType
]
publicNodeTypes
=
[
NodeDashboard
,
NodeGraph
,
NodePhylo
]
publicNodeTypes
=
[
NodeDashboard
,
NodeGraph
,
NodePhylo
,
NodeFile
]
------------------------------------------------------------------------
...
...
src/Gargantext/Database/Admin/Types/Node.hs
View file @
6999a68e
...
...
@@ -124,6 +124,9 @@ pgNodeId = O.pgInt4 . id2int
newtype
NodeId
=
NodeId
Int
deriving
(
Show
,
Read
,
Generic
,
Num
,
Eq
,
Ord
,
Enum
,
ToJSONKey
,
FromJSONKey
,
ToJSON
,
FromJSON
)
unNodeId
::
NodeId
->
Int
unNodeId
(
NodeId
n
)
=
n
instance
Serialise
NodeId
instance
ToField
NodeId
where
...
...
src/Gargantext/Prelude/Config.hs
View file @
6999a68e
...
...
@@ -23,7 +23,9 @@ import GHC.Generics (Generic)
import
Control.Lens
(
makeLenses
)
data
GargConfig
=
GargConfig
{
_gc_masteruser
::
!
Text
data
GargConfig
=
GargConfig
{
_gc_url
::
!
Text
,
_gc_masteruser
::
!
Text
,
_gc_secretkey
::
!
Text
,
_gc_datafilepath
::
!
FilePath
...
...
@@ -52,7 +54,8 @@ readConfig fp = do
Left
_
->
panic
(
pack
$
"ERROR: add "
<>
x
<>
" to your gargantext.ini"
)
Right
p'
->
p'
pure
$
GargConfig
(
val
"MASTER_USER"
)
pure
$
GargConfig
(
val
"URL"
)
(
val
"MASTER_USER"
)
(
val
"SECRET_KEY"
)
(
cs
$
val
"DATA_FILEPATH"
)
(
cs
$
val
"REPO_FILEPATH"
)
...
...
@@ -63,7 +66,8 @@ readConfig fp = do
(
read
$
cs
$
val
"MAX_DOCS_SCRAPERS"
)
defaultConfig
::
GargConfig
defaultConfig
=
GargConfig
"gargantua"
defaultConfig
=
GargConfig
"https://gargantext.org"
"gargantua"
"secret"
"data"
"repos/"
...
...
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