Router.purs 1.59 KB
Newer Older
1
module Gargantext.Router where
2

3
import Prelude
4
import Data.Foldable (oneOf)
5
import Data.Int (floor)
6
import Routing.Match (Match, lit, num, str)
7
import Gargantext.Routes (AppRoute(..))
8
import Gargantext.Types (SessionId(..))
9

10 11
router :: Match AppRoute
router = oneOf
12
  [ Login            <$   route "login"
13
  , Folder           <$> (route "folder"     *> sid) <*> int
14 15 16
  , FolderPrivate    <$> (route "folderPrivate"     *> sid) <*> int
  , FolderPublic     <$> (route "folderPublic"     *> sid) <*> int
  , FolderShared     <$> (route "folderShared"     *> sid) <*> int
Alexandre Delanoë's avatar
Alexandre Delanoë committed
17
  , Team             <$> (route "team"     *> sid) <*> int
18 19
  , CorpusDocument   <$> (route "corpus"     *> sid) <*> int
                        <*> (lit "list" *> int)
20
                        <*> (lit "document" *> int)
21
  , Corpus            <$> (route "corpus"     *> sid) <*> int
22
     , Document       <$> (route "list"      *> sid) <*> int 
23
                        <*> (lit "document" *> int)
24 25 26 27
     , Dashboard      <$> (route "dashboard" *> sid) <*> int
     , PGraphExplorer <$> (route "graph"     *> sid) <*> int
     , Texts          <$> (route "texts"     *> sid) <*> int
     , Lists          <$> (route "lists"     *> sid) <*> int
28
    , ContactPage     <$> (route "annuaire"  *> sid) <*> int
29
                          <*> (lit "contact" *> int)
30 31
  , Annuaire          <$> (route "annuaire"  *> sid) <*> int
    , UserPage        <$> (route "user"      *> sid) <*> int
32
  , Home              <$   lit ""
33
  ]
34 35
 where
    route str      = lit "" *> lit str
36

37 38
    int :: Match Int
    int = floor <$> num
39

40 41
    sid :: Match SessionId
    sid = SessionId <$> str
42