1{-# LANGUAGE EmptyCase #-}
2{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE LambdaCase #-}
5{-# LANGUAGE RankNTypes #-}
6{-# LANGUAGE TemplateHaskell #-}
7{-# LANGUAGE KindSignatures #-}
8{-# LANGUAGE EmptyCase #-}
9{-# LANGUAGE MultiParamTypeClasses #-}
10{-# LANGUAGE FlexibleInstances #-}
11{-# LANGUAGE OverloadedStrings #-}
13module Common.Route where
15{- -- You will probably want these imports for composing Encoders.
16import Prelude hiding (id, (.))
17import Control.Category
20import Data.Text (Text)
21import Data.Functor.Identity
22import Data.Functor.Sum
25import Obelisk.Route.TH
27data BackendRoute :: * -> * where
28 -- | Used to handle unparseable routes.
29 BackendRoute_Missing :: BackendRoute ()
30 -- You can define any routes that will be handled specially by the backend here.
31 -- i.e. These do not serve the frontend, but do something different, such as serving static files.
33data FrontendRoute :: * -> * where
34 FrontendRoute_Main :: FrontendRoute ()
35 -- This type is used to define frontend routes, i.e. ones for which the backend will serve the frontend.
38 :: Encoder (Either Text) Identity (R (Sum BackendRoute (ObeliskRoute FrontendRoute))) PageName
39backendRouteEncoder = handleEncoder (const (InL BackendRoute_Missing :/ ())) $
40 pathComponentEncoder $ \case
41 InL backendRoute -> case backendRoute of
42 BackendRoute_Missing -> PathSegment "missing" $ unitEncoder mempty
43 InR obeliskRoute -> obeliskRouteSegment obeliskRoute $ \case
44 -- The encoder given to PathEnd determines how to parse query parameters,
45 -- in this example, we have none, so we insist on it.
46 FrontendRoute_Main -> PathEnd $ unitEncoder mempty
49concat <$> mapM deriveRouteComponent
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list