Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Grégoire Locqueville
purescript-gargantext
Commits
f6fd6ec6
Commit
f6fd6ec6
authored
Sep 21, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Config] url builders.
parent
7e500e2d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
5 deletions
+67
-5
Config.purs
src/Gargantext/Config.purs
+62
-0
Main.purs
test/Main.purs
+5
-5
No files found.
src/Gargantext/Config.purs
0 → 100644
View file @
f6fd6ec6
module Gargantext.Config where
import Prelude (class Eq, class Ord, class Show, compare, eq, show, (<>))
import Data.Map (Map)
import Data.Map as DM
-- import Data.Maybe (maybe)
import Data.Tuple (Tuple(..))
type FrontEndConfig = { proto :: String
, port :: Int
, address :: String
, urls :: Map NodeType Url
}
config :: FrontEndConfig
config = { proto : "http://"
, port : 2015
, address : "localhost"
, urls : urlConfig
}
-- | Basic starting example
-- for more complex urls, use urlConfig and smart constructors
toUrl :: NodeType -> Id -> Url
toUrl nt i = config.proto <> config.address <> ":" <> show config.port <> "/" <> show nt <> "/" <> show i
--where
--path = maybe "error" (DM.lookup nt config.urls)
------------------------------------------------------------
type Url = String
type Id = Int
------------------------------------------------------------
data NodeType = UserPage | Corpus | Document | Annuaire | Individu | Project
instance showNodeType :: Show NodeType where
show UserPage = "userPage"
show Corpus = "corpus"
show Document = "document"
show Annuaire = "annuaire"
show Individu = "individu"
show Project = "project"
instance ordNodeType :: Ord NodeType where
compare n1 n2 = compare (show n1) (show n2)
instance eqNodeType :: Eq NodeType where
eq n1 n2 = eq (show n1) (show n2)
------------------------------------------------------------
trivial :: NodeType -> Tuple NodeType Url
trivial n = Tuple n (show n)
urlConfig :: Map NodeType Url
urlConfig = DM.fromFoldable [ Tuple UserPage "user"
, trivial Corpus
, trivial Document
, trivial Annuaire
, trivial Individu
]
test/Main.purs
View file @
f6fd6ec6
module Test.Main where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)
--
import Control.Monad.Eff (Eff)
--
import Control.Monad.Eff.Console (CONSOLE, log)
main :: forall e. Eff (console :: CONSOLE | e) Unit
main = do
log "You should add some tests."
--
main :: forall e. Eff (console :: CONSOLE | e) Unit
--
main = do
--
log "You should add some tests."
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