diff --git a/src/Vervis/Foundation.hs b/src/Vervis/Foundation.hs index 96d7cda..0ba0a9c 100644 --- a/src/Vervis/Foundation.hs +++ b/src/Vervis/Foundation.hs @@ -15,7 +15,9 @@ module Vervis.Foundation where -import Vervis.Import.NoFoundation +import Prelude (init, last) + +import Vervis.Import.NoFoundation hiding (last) import Database.Persist.Sql (ConnectionPool, runSqlPool) import Text.Hamlet (hamletFile) import Text.Jasmine (minifym) @@ -26,6 +28,7 @@ import Yesod.Core.Types (Logger) import qualified Yesod.Core.Unsafe as Unsafe --import qualified Data.CaseInsensitive as CI +import Data.Text as T (pack) --import qualified Data.Text.Encoding as TE -- | The foundation datatype for your application. This can be a good place to @@ -246,3 +249,43 @@ loggedInAs ident msg = do if ident == sharerIdent sharer then return Authorized else return $ Unauthorized msg + +instance YesodBreadcrumbs App where + breadcrumb route = return $ case route of + HomeR -> ("Home", Nothing) + + PeopleR -> ("People", Just HomeR) + PersonNewR -> ("New", Just PeopleR) + PersonR shar -> (shar, Just PeopleR) + + KeysR shar -> ("Keys", Just $ PersonR shar) + KeyNewR shar -> ("New", Just $ KeysR shar) + KeyR shar key -> (key, Just $ KeysR shar) + + ReposR shar -> ("Repos", Just $ PersonR shar) + RepoNewR shar -> ("New", Just $ ReposR shar) + RepoR shar repo -> (repo, Just $ ReposR shar) + RepoSourceR shar repo branch [] -> ("Files", Just $ RepoR shar repo) + RepoSourceR shar repo branch dir -> ( last dir + , Just $ + RepoSourceR shar repo branch $ + init dir + ) + RepoCommitsR shar repo -> ("History", Just $ RepoR shar repo) + + ProjectsR shar -> ("Projects", Just $ PersonR shar) + ProjectNewR shar -> ("New", Just $ ProjectsR shar) + ProjectR shar proj -> (proj, Just $ ProjectsR shar) + + TicketsR shar proj -> ( "Tickets" + , Just $ ProjectR shar proj + ) + TicketNewR shar proj -> ("New", Just $ TicketsR shar proj) + TicketR shar proj num -> ( T.pack $ '#' : show num + , Just $ TicketsR shar proj + ) + TicketEditR shar proj num -> ( "Edit" + , Just $ TicketR shar proj num + ) + + _ -> ("", Nothing)