Router.purs 1.28 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 18
  , Corpus           <$> (route "corpus"     *> sid) <*> int
     , Document       <$> (route "list"      *> sid) <*> int 
19
                        <*> (lit "document" *> int)
20 21 22 23 24 25 26
     , Dashboard      <$> (route "dashboard" *> sid) <*> int
     , PGraphExplorer <$> (route "graph"     *> sid) <*> int
     , Texts          <$> (route "texts"     *> sid) <*> int
     , Lists          <$> (route "lists"     *> sid) <*> int
  , Annuaire          <$> (route "annuaire"  *> sid) <*> int
    , UserPage        <$> (route "user"      *> sid) <*> int
    , ContactPage     <$> (route "contact"   *> sid) <*> int
27
  , Home              <$   lit ""
28
  ]
29 30 31 32
 where
    route str      = lit "" *> lit str
    int :: Match Int
    int = floor <$> num
33 34
    sid :: Match SessionId
    sid = SessionId <$> str
35