Router.purs 1.72 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

8
import Gargantext.Routes (AppRoute(..))
9
import Gargantext.Types (SessionId(..))
10

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

  , RouteFrameWrite    <$> (route "write"     *> sid) <*> int
  , RouteFrameCalc     <$> (route "calc"     *> sid) <*> int
36
  , Home              <$   lit ""
37
  ]
38 39
 where
    route str      = lit "" *> lit str
40

41 42
    int :: Match Int
    int = floor <$> num
43

44 45
    sid :: Match SessionId
    sid = SessionId <$> str
46