Router.purs 1.34 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 14 15
  , Folder           <$> (route "folder"     *> sid) <*> int
  , CorpusDocument   <$> (route "corpus"     *> sid) <*> int
                        <*> (lit "list" *> int)
16
                        <*> (lit "document" *> int)
17
  , Corpus            <$> (route "corpus"     *> sid) <*> int
18
     , Document       <$> (route "list"      *> sid) <*> int 
19
                        <*> (lit "document" *> int)
20 21 22 23
     , Dashboard      <$> (route "dashboard" *> sid) <*> int
     , PGraphExplorer <$> (route "graph"     *> sid) <*> int
     , Texts          <$> (route "texts"     *> sid) <*> int
     , Lists          <$> (route "lists"     *> sid) <*> int
24
    , ContactPage     <$> (route "annuaire"  *> sid) <*> int
25
                          <*> (lit "contact" *> int)
26 27
  , Annuaire          <$> (route "annuaire"  *> sid) <*> int
    , UserPage        <$> (route "user"      *> sid) <*> int
28
  , Home              <$   lit ""
29
  ]
30 31
 where
    route str      = lit "" *> lit str
32

33 34
    int :: Match Int
    int = floor <$> num
35

36 37
    sid :: Match SessionId
    sid = SessionId <$> str
38