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

3
import Prelude
4

5
import Data.Foldable (oneOf)
6
import Data.Int (floor)
7
import Gargantext.Routes (AppRoute(..))
8
import Gargantext.Types (SessionId(..))
9
import Routing.Match (Match, lit, num, str)
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 24
     , CorpusCode     <$> (route "corpusCode" *> sid) <*> int
     , Document       <$> (route "list"      *> sid) <*> int
25
                        <*> (lit "document" *> int)
26 27
     , Dashboard      <$> (route "dashboard" *> sid) <*> int
     , PGraphExplorer <$> (route "graph"     *> sid) <*> int
28
     , PhyloExplorer  <$> (route "phylo"     *> sid) <*> int
29
     , NodeTexts      <$> (route "texts"     *> sid) <*> int
30
     , Lists          <$> (route "lists"     *> sid) <*> int
31
    , ContactPage     <$> (route "annuaire"  *> sid) <*> int
32
                          <*> (lit "contact" *> int)
33 34
  , Annuaire          <$> (route "annuaire"  *> sid) <*> int
    , UserPage        <$> (route "user"      *> sid) <*> int
35

36
  , RouteFrameWrite    <$> (route "write"    *> sid) <*> int
37
  , RouteFrameCalc     <$> (route "calc"     *> sid) <*> int
38
  , RouteFrameCode     <$> (route "code"     *> sid) <*> int
39 40
  , RouteFrameVisio    <$> (route "visio"    *> sid) <*> int
  , RouteFile          <$> (route "file"     *> sid) <*> int
41
  , Home              <$   lit ""
42
  ]
43 44
 where
    route str      = lit "" *> lit str
45

46 47
    int :: Match Int
    int = floor <$> num
48

49 50
    sid :: Match SessionId
    sid = SessionId <$> str