From 2323ec3fc0c2db397b8a446f0123b0618907df95 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Tue, 12 Apr 2016 23:38:21 +0000 Subject: [PATCH] Repo page is root repo source page, remove duplication --- src/Vervis/Handler/Repo.hs | 29 +++++++++--------------- templates/repo/repo.hamlet | 43 ------------------------------------ templates/repo/source.hamlet | 6 +++++ 3 files changed, 17 insertions(+), 61 deletions(-) delete mode 100644 templates/repo/repo.hamlet diff --git a/src/Vervis/Handler/Repo.hs b/src/Vervis/Handler/Repo.hs index 98637d4..975b301 100644 --- a/src/Vervis/Handler/Repo.hs +++ b/src/Vervis/Handler/Repo.hs @@ -127,25 +127,10 @@ getRepoR user repo = do Entity sid _s <- getBy404 $ UniqueSharerIdent user Entity _rid r <- getBy404 $ UniqueRepo repo sid return r - path <- askRepoDir user repo - view <- liftIO $ withRepo (fromString path) $ \ git -> do - oid <- resolveName git $ unpack $ repoMainBranch repository - commit <- getCommit git $ unObjId oid - tree <- getTree git $ commitTreeish commit - viewTree git tree - let toText = decodeUtf8With lenientDecode - mkrow (_perm, name, isTree) = - ( if isTree then "[D]" else "[F]" :: Text - , toText $ toBytes name - ) - rows = map mkrow view - defaultLayout $ do - setTitle $ toHtml $ intercalate " > " - ["Vervis", "People", user, "Repos", repo] - $(widgetFile "repo/repo") + getRepoSource repository user repo (repoMainBranch repository) [] -getRepoSourceR :: Text -> Text -> Text -> [Text] -> Handler Html -getRepoSourceR user repo ref dir = do +getRepoSource :: Repo -> Text -> Text -> Text -> [Text] -> Handler Html +getRepoSource repository user repo ref dir = do path <- askRepoDir user repo let toText = decodeUtf8With lenientDecode toTextL = L.decodeUtf8With lenientDecode @@ -216,6 +201,14 @@ getRepoSourceR user repo ref dir = do ["Vervis", "People", user, "Repos", repo] $(widgetFile "repo/source") +getRepoSourceR :: Text -> Text -> Text -> [Text] -> Handler Html +getRepoSourceR user repo ref dir = do + repository <- runDB $ do + Entity sid _s <- getBy404 $ UniqueSharerIdent user + Entity _rid r <- getBy404 $ UniqueRepo repo sid + return r + getRepoSource repository user repo ref dir + getRepoCommitsR :: Text -> Text -> Handler Html getRepoCommitsR user repo = do repository <- runDB $ do diff --git a/templates/repo/repo.hamlet b/templates/repo/repo.hamlet deleted file mode 100644 index b91bca7..0000000 --- a/templates/repo/repo.hamlet +++ /dev/null @@ -1,43 +0,0 @@ -$# This file is part of Vervis. -$# -$# Written in 2016 by fr33domlover . -$# -$# ♡ Copying is an act of love. Please copy, reuse and share. -$# -$# The author(s) have dedicated all copyright and related and neighboring -$# rights to this software to the public domain worldwide. This software is -$# distributed without any warranty. -$# -$# You should have received a copy of the CC0 Public Domain Dedication along -$# with this software. If not, see -$# . - -

Vervis > People > #{user} > Repos > #{repo} - -

About -

- This is the repo page for #{repo}, shared by user #{user}. - -

Details - - -
Description - - $maybe desc <- repoDesc repository - #{desc} - $nothing - (none) - -

Commits -

- See commits. - -

Files - - - -
Type - Name - $forall (type', name) <- rows -
#{type'} - #{name} diff --git a/templates/repo/source.hamlet b/templates/repo/source.hamlet index d584487..409ecb1 100644 --- a/templates/repo/source.hamlet +++ b/templates/repo/source.hamlet @@ -14,6 +14,12 @@ $# .

Vervis > People > #{user} > Repos > #{repo} +$maybe desc <- repoDesc repository +

#{desc} + +

+ Commits +

Branches
    $forall RefName branch <- branches