1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-29 01:44:53 +09:00

Add breadcrumb to repo tree content view

This commit is contained in:
fr33domlover 2016-04-12 23:10:46 +00:00
parent 979156b8ae
commit d37108fa6f
2 changed files with 14 additions and 2 deletions

View file

@ -36,7 +36,7 @@ import ClassyPrelude.Conduit hiding (last, toStrict, unpack)
import Yesod hiding (Header, parseTime, (==.)) import Yesod hiding (Header, parseTime, (==.))
import Yesod.Auth import Yesod.Auth
import Prelude (last) import Prelude (init, last, tail)
import Data.Byteable (toBytes) import Data.Byteable (toBytes)
import Data.ByteString.Lazy (toStrict) 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.Git.Types (Blob (..), Commit (..), Person (..), entName)
import Data.Graph.Inductive.Graph (noNodes) import Data.Graph.Inductive.Graph (noNodes)
import Data.Graph.Inductive.Query.Topsort import Data.Graph.Inductive.Query.Topsort
import Data.List (inits)
import Data.Text (unpack) import Data.Text (unpack)
import Data.Text.Encoding (decodeUtf8With) import Data.Text.Encoding (decodeUtf8With)
import Data.Text.Encoding.Error (lenientDecode) import Data.Text.Encoding.Error (lenientDecode)
@ -204,6 +205,12 @@ getRepoSourceR user repo ref dir = do
Right tokens -> Right tokens ->
return $ Right $ format True tokens return $ Right $ format True tokens
Right v -> return $ Right $ map mkrow v 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 defaultLayout $ do
setTitle $ toHtml $ intercalate " > " $ setTitle $ toHtml $ intercalate " > " $
["Vervis", "People", user, "Repos", repo] ["Vervis", "People", user, "Repos", repo]

View file

@ -26,7 +26,12 @@ $forall RefName tag <- tags
<li> <li>
<a href=@{RepoSourceR user repo (pack tag) []}>#{tag} <a href=@{RepoSourceR user repo (pack tag) []}>#{tag}
<h2>Files for #{ref} <a href=@{RepoSourceR user repo ref []}>#{ref}
<span>::
$forall (piece, piecePath) <- dirs
<a href=@{RepoSourceR user repo ref piecePath}>#{piece}
<span>/
<h2>#{title}
$case display $case display
$of Left (Left plain) $of Left (Left plain)
<pre> <pre>