Router.purs 1.84 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
  , RouteFrameCode     <$> (route "code"     *> sid) <*> int
37
  , RouteFile          <$> (route "file"   *> sid) <*> int
38
  , Home              <$   lit ""
39
  ]
40 41
 where
    route str      = lit "" *> lit str
42

43 44
    int :: Match Int
    int = floor <$> num
45

46 47
    sid :: Match SessionId
    sid = SessionId <$> str
48