Router.purs 2.08 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(..))
Karen Konou's avatar
Karen Konou committed
9
import Routing.Match (Match, lit, num, params, str)
10

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

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

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

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