From d37108fa6fb35b45ce52b37683124c5747de1b52 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Tue, 12 Apr 2016 23:10:46 +0000 Subject: [PATCH] Add breadcrumb to repo tree content view --- src/Vervis/Handler/Repo.hs | 9 ++++++++- templates/repo/source.hamlet | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Vervis/Handler/Repo.hs b/src/Vervis/Handler/Repo.hs index e444e87..98637d4 100644 --- a/src/Vervis/Handler/Repo.hs +++ b/src/Vervis/Handler/Repo.hs @@ -36,7 +36,7 @@ import ClassyPrelude.Conduit hiding (last, toStrict, unpack) import Yesod hiding (Header, parseTime, (==.)) import Yesod.Auth -import Prelude (last) +import Prelude (init, last, tail) import Data.Byteable (toBytes) import Data.ByteString.Lazy (toStrict) @@ -50,6 +50,7 @@ import Data.Git.Storage.Object (Object (..)) import Data.Git.Types (Blob (..), Commit (..), Person (..), entName) import Data.Graph.Inductive.Graph (noNodes) import Data.Graph.Inductive.Query.Topsort +import Data.List (inits) import Data.Text (unpack) import Data.Text.Encoding (decodeUtf8With) import Data.Text.Encoding.Error (lenientDecode) @@ -204,6 +205,12 @@ getRepoSourceR user repo ref dir = do Right tokens -> return $ Right $ format True tokens Right v -> return $ Right $ map mkrow v + let parent = if null dir then [] else init dir + dirs = zip parent (tail $ inits parent) + title = case (dir, display) of + ([], _) -> "Files" + (_, Left _) -> last dir + (_, Right _) -> last dir <> "/" defaultLayout $ do setTitle $ toHtml $ intercalate " > " $ ["Vervis", "People", user, "Repos", repo] diff --git a/templates/repo/source.hamlet b/templates/repo/source.hamlet index 67df609..d584487 100644 --- a/templates/repo/source.hamlet +++ b/templates/repo/source.hamlet @@ -26,7 +26,12 @@ $forall RefName tag <- tags
  • #{tag} -

    Files for #{ref} +#{ref} +:: +$forall (piece, piecePath) <- dirs + #{piece} + / +

    #{title} $case display $of Left (Left plain)