1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-27 18:24:51 +09:00

UI: Fix and re-enable getRepoSourceR (repo content file/dir browsing)

This commit is contained in:
fr33domlover 2022-09-16 13:47:10 +00:00
parent b66bab4295
commit 40f741e504
8 changed files with 130 additions and 142 deletions

View file

@ -15,9 +15,9 @@
-}
module Vervis.Darcs
( --readSourceView
( readSourceView
--, readWikiView
readChangesView
, readChangesView
--, lastChange
, readPatch
, writePostApplyHooks
@ -97,7 +97,6 @@ import Vervis.Readme
import Vervis.Settings
import Vervis.SourceTree
{-
dirToAnchoredPath :: [EntryName] -> AnchoredPath
dirToAnchoredPath = AnchoredPath . map (decodeWhiteName . encodeUtf8)
@ -166,7 +165,6 @@ readSourceView path dir = do
let mitem = find expandedTree anch
for mitem $ itemToSourceView (last dir)
return $ renderSources dir <$> msv
-}
{-
readWikiView

View file

@ -15,8 +15,8 @@
-}
module Vervis.Git
( --readSourceView
readChangesView
( readSourceView
, readChangesView
, listRefs
, readPatch
--, lastCommitTime
@ -97,7 +97,6 @@ import Vervis.Readme
import Vervis.Settings
import Vervis.SourceTree
{-
matchReadme :: (ModePerm, ObjId, Text, EntObjType) -> Bool
matchReadme (_, _, name, EntObjBlob) = isReadme name
matchReadme _ = False
@ -171,7 +170,6 @@ readSourceView path ref dir = do
G.withRepo (fromString path) $ \ git -> loadSourceView git ref dir
let toTexts = S.mapMonotonic $ T.pack . refNameRaw
return (toTexts bs, toTexts ts, renderSources dir <$> msv)
-}
readChangesView
:: FilePath

View file

@ -59,9 +59,9 @@ module Vervis.Handler.Repo
, deleteRepoDevR
, postRepoDevR
, getRepoTeamR
-}
, getHighlightStyleR
-}
)
where
@ -359,20 +359,22 @@ postGitUploadRequestR repoHash = do
getRepoSourceR :: KeyHashid Repo -> [Text] -> Handler Html
getRepoSourceR repoHash path = do
repoID <- decodeKeyHashid404 repoHash
repo <- runDB $ get404 repoID
(repo, actor) <- runDB $ do
r <- get404 repoID
(r,) <$> getJust (repoActor r)
case repoVcs repo of
VCSDarcs -> error "Temporarily disabled"
--getDarcsRepoSource repo repoHash path
VCSDarcs -> getDarcsRepoSource repo actor repoHash path
VCSGit -> notFound
getRepoBranchSourceR :: KeyHashid Repo -> Text -> [Text] -> Handler Html
getRepoBranchSourceR repoHash branch path = do
repoID <- decodeKeyHashid404 repoHash
repo <- runDB $ get404 repoID
(repo, actor) <- runDB $ do
r <- get404 repoID
(r,) <$> getJust (repoActor r)
case repoVcs repo of
VCSDarcs -> notFound
VCSGit -> error "Temporarily disabled"
--getGitRepoSource repo repoHash branch dir
VCSGit -> getGitRepoSource repo actor repoHash branch path
getRepoCommitsR :: KeyHashid Repo -> Handler TypedContent
getRepoCommitsR repoHash = do
@ -855,6 +857,7 @@ getRepoFollowersR shr rp = getFollowersCollection here getFsid
sid <- getKeyBy404 $ UniqueSharer shr
r <- getValBy404 $ UniqueRepo rp sid
return $ repoFollowers r
-}
getHighlightStyleR :: Text -> Handler TypedContent
getHighlightStyleR styleName =
@ -862,4 +865,3 @@ getHighlightStyleR styleName =
Nothing -> notFound
Just style ->
return $ TypedContent typeCss $ toContent $ styleToCss style
-}

View file

@ -15,8 +15,8 @@
-}
module Vervis.Web.Darcs
( --getDarcsRepoSource
getDarcsRepoChanges
( getDarcsRepoSource
, getDarcsRepoChanges
, getDarcsPatch
)
where
@ -29,7 +29,7 @@ import Data.Text.Encoding
import Data.Text.Encoding.Error (lenientDecode)
import Data.Traversable (for)
import Database.Esqueleto
import Network.HTTP.Types (StdMethod (DELETE))
import Network.HTTP.Types
import System.FilePath ((</>), joinPath)
import System.Directory (doesFileExist)
import Text.Blaze.Html (Html)
@ -48,12 +48,13 @@ import qualified Data.Text.Lazy.Encoding as L (decodeUtf8With)
import Data.MediaType
import Development.PatchMediaType
import Web.ActivityPub hiding (Repo, Project)
import Yesod.ActivityPub
import Yesod.FedURI
import Yesod.Hashids
import Yesod.RenderSource
import qualified Web.ActivityPub as AP
import Data.ByteString.Char8.Local (takeLine)
import Data.Paginate.Local
import Data.Patch.Local
@ -72,14 +73,16 @@ import Vervis.SourceTree
import Vervis.Style
import Vervis.Time
import Vervis.Web.Repo
import Vervis.Widget
import Vervis.Widget.Person
import Vervis.Widget.Repo
import qualified Vervis.Darcs as D
{-
getDarcsRepoSource :: (Maybe (Sharer, Project, Workflow, Sharer), Repo) -> ShrIdent -> RpIdent -> [Text] -> Handler Html
getDarcsRepoSource (mproject, repository) user repo dir = do
path <- askRepoDir user repo
getDarcsRepoSource
:: Repo -> Actor -> KeyHashid Repo -> [Text] -> Handler Html
getDarcsRepoSource repository actor repo dir = do
path <- askRepoDir repo
msv <- liftIO $ D.readSourceView path dir
case msv of
Nothing -> notFound
@ -96,11 +99,7 @@ getDarcsRepoSource (mproject, repository) user repo dir = do
$(widgetFile "repo/source-darcs")
where
followButton =
followW
(RepoFollowR user repo)
(RepoUnfollowR user repo)
(return $ repoFollowers repository)
-}
followW (RepoFollowR repo) (RepoUnfollowR repo) (actorFollowers actor)
getDarcsRepoChanges :: KeyHashid Repo -> Handler TypedContent
getDarcsRepoChanges repo = do
@ -119,36 +118,36 @@ getDarcsRepoChanges repo = do
case mpage of
Nothing -> do
(total, pages, _, _) <- getPageAndNavTop getChanges
let collection = Collection
{ collectionId = encodeRouteLocal here
, collectionType = CollectionTypeOrdered
, collectionTotalItems = Just total
, collectionCurrent = Nothing
, collectionFirst = Just $ pageUrl 1
, collectionLast = Just $ pageUrl pages
, collectionItems = [] :: [Text]
let collection = AP.Collection
{ AP.collectionId = encodeRouteLocal here
, AP.collectionType = AP.CollectionTypeOrdered
, AP.collectionTotalItems = Just total
, AP.collectionCurrent = Nothing
, AP.collectionFirst = Just $ pageUrl 1
, AP.collectionLast = Just $ pageUrl pages
, AP.collectionItems = [] :: [Text]
}
provideHtmlAndAP collection $ redirectFirstPage here
Just (_total, pages, items, navModel) ->
let current = nmCurrent navModel
page = CollectionPage
{ collectionPageId = pageUrl current
, collectionPageType = CollectionPageTypeOrdered
, collectionPageTotalItems = Nothing
, collectionPageCurrent = Just $ pageUrl current
, collectionPageFirst = Just $ pageUrl 1
, collectionPageLast = Just $ pageUrl pages
, collectionPagePartOf = encodeRouteLocal here
, collectionPagePrev =
page = AP.CollectionPage
{ AP.collectionPageId = pageUrl current
, AP.collectionPageType = AP.CollectionPageTypeOrdered
, AP.collectionPageTotalItems = Nothing
, AP.collectionPageCurrent = Just $ pageUrl current
, AP.collectionPageFirst = Just $ pageUrl 1
, AP.collectionPageLast = Just $ pageUrl pages
, AP.collectionPagePartOf = encodeRouteLocal here
, AP.collectionPagePrev =
if current > 1
then Just $ pageUrl $ current - 1
else Nothing
, collectionPageNext =
, AP.collectionPageNext =
if current < pages
then Just $ pageUrl $ current + 1
else Nothing
, collectionPageStartIndex = Nothing
, collectionPageItems =
, AP.collectionPageStartIndex = Nothing
, AP.collectionPageItems =
map (encodeRouteHome . RepoCommitR repo . leHash)
items
}

View file

@ -15,9 +15,9 @@
-}
module Vervis.Web.Git
( --getGitRepoSource
( getGitRepoSource
--, getGitRepoBranch
getGitRepoChanges
, getGitRepoChanges
, getGitPatch
)
where
@ -42,7 +42,7 @@ import Data.Text.Encoding.Error (lenientDecode)
import Data.Traversable (for)
import Database.Esqueleto
import Data.Hourglass (timeConvert)
import Network.HTTP.Types (StdMethod (DELETE))
import Network.HTTP.Types
import System.Directory (createDirectoryIfMissing)
import System.Hourglass (dateCurrent)
import Text.Blaze.Html (Html)
@ -59,7 +59,6 @@ import qualified Data.Text as T
import qualified Data.Text.Lazy.Encoding as L (decodeUtf8With)
import Data.MediaType
import Web.ActivityPub hiding (Commit, Author, Repo, Project)
import Yesod.ActivityPub
import Yesod.FedURI
import Yesod.Hashids
@ -88,15 +87,17 @@ import Vervis.SourceTree
import Vervis.Style
import Vervis.Time (showDate)
import Vervis.Web.Repo
import Vervis.Widget
import Vervis.Widget.Person
import Vervis.Widget.Repo
import qualified Data.ByteString.Lazy as BL (ByteString)
import qualified Vervis.Git as G
{-
getGitRepoSource :: (Maybe (Sharer, Project, Workflow, Sharer), Repo) -> ShrIdent -> RpIdent -> Text -> [Text] -> Handler Html
getGitRepoSource (mproject, repository) user repo ref dir = do
path <- askRepoDir user repo
getGitRepoSource
:: Repo -> Actor -> KeyHashid Repo -> Text -> [Text] -> Handler Html
getGitRepoSource repository actor repo ref dir = do
path <- askRepoDir repo
(branches, tags, msv) <- liftIO $ G.readSourceView path ref dir
case msv of
Nothing -> notFound
@ -113,11 +114,7 @@ getGitRepoSource (mproject, repository) user repo ref dir = do
$(widgetFile "repo/source-git")
where
followButton =
followW
(RepoFollowR user repo)
(RepoUnfollowR user repo)
(return $ repoFollowers repository)
-}
followW (RepoFollowR repo) (RepoUnfollowR repo) (actorFollowers actor)
{-
getGitRepoBranch :: ShrIdent -> RpIdent -> Text -> Handler TypedContent
@ -153,36 +150,36 @@ getGitRepoChanges repo ref = do
case mpage of
Nothing -> do
(total, pages, _, _) <- getPageAndNavTop getChanges
let collection = Collection
{ collectionId = encodeRouteLocal here
, collectionType = CollectionTypeOrdered
, collectionTotalItems = Just total
, collectionCurrent = Nothing
, collectionFirst = Just $ pageUrl 1
, collectionLast = Just $ pageUrl pages
, collectionItems = [] :: [Text]
let collection = AP.Collection
{ AP.collectionId = encodeRouteLocal here
, AP.collectionType = AP.CollectionTypeOrdered
, AP.collectionTotalItems = Just total
, AP.collectionCurrent = Nothing
, AP.collectionFirst = Just $ pageUrl 1
, AP.collectionLast = Just $ pageUrl pages
, AP.collectionItems = [] :: [Text]
}
provideHtmlAndAP collection $ redirectFirstPage here
Just (_total, pages, items, navModel) ->
let current = nmCurrent navModel
page = CollectionPage
{ collectionPageId = pageUrl current
, collectionPageType = CollectionPageTypeOrdered
, collectionPageTotalItems = Nothing
, collectionPageCurrent = Just $ pageUrl current
, collectionPageFirst = Just $ pageUrl 1
, collectionPageLast = Just $ pageUrl pages
, collectionPagePartOf = encodeRouteLocal here
, collectionPagePrev =
page = AP.CollectionPage
{ AP.collectionPageId = pageUrl current
, AP.collectionPageType = AP.CollectionPageTypeOrdered
, AP.collectionPageTotalItems = Nothing
, AP.collectionPageCurrent = Just $ pageUrl current
, AP.collectionPageFirst = Just $ pageUrl 1
, AP.collectionPageLast = Just $ pageUrl pages
, AP.collectionPagePartOf = encodeRouteLocal here
, AP.collectionPagePrev =
if current > 1
then Just $ pageUrl $ current - 1
else Nothing
, collectionPageNext =
, AP.collectionPageNext =
if current < pages
then Just $ pageUrl $ current + 1
else Nothing
, collectionPageStartIndex = Nothing
, collectionPageItems =
, AP.collectionPageStartIndex = Nothing
, AP.collectionPageItems =
map (encodeRouteHome . RepoCommitR repo . leHash)
items
}

View file

@ -13,54 +13,51 @@ $# You should have received a copy of the CC0 Public Domain Dedication along
$# with this software. If not, see
$# <http://creativecommons.org/publicdomain/zero/1.0/>.
$maybe (s, j, w, sw) <- mproject
<p>
Belongs to project
<a href=@{ProjectR (sharerIdent s) (projectIdent j)}>
$maybe name <- projectName j
#{name}
$nothing
#{prj2text $ projectIdent j}
$# $maybe (s, j, w, sw) <- mproject
$# <p>
$# Belongs to project
$# <a href=@{ProjectR (sharerIdent s) (projectIdent j)}>
$# $maybe name <- projectName j
$# #{name}
$# $nothing
$# #{prj2text $ projectIdent j}
$#
$# ^{personNavW $ sharerIdent s}
$#
$# ^{projectNavW j w sw (sharerIdent s) (projectIdent j)}
^{personNavW $ sharerIdent s}
<p>#{actorDesc actor}
^{projectNavW j w sw (sharerIdent s) (projectIdent j)}
$maybe desc <- repoDesc repository
<p>#{desc}
^{personNavW user}
$# ^{personNavW user}
<div>
<span>
[[ 🗃
<a href=@{RepoR user repo}>
#{rp2text repo}
<a href=@{RepoR repo}>
^#{keyHashidText repo} #{actorName actor}
]] ::
<span>
<a href=@{RepoInboxR user repo}>
<a href=@{RepoInboxR repo}>
[📥 Inbox]
<span>
<a href=@{RepoOutboxR user repo}>
<a href=@{RepoOutboxR repo}>
[📤 Outbox]
<span>
<a href=@{RepoFollowersR user repo}>
<a href=@{RepoFollowersR repo}>
[🐤 Followers]
<span>
<a href=@{RepoDevsR user repo}>
[🤝 Collaborators]
<span>
<a href=@{RepoHeadChangesR user repo}>
<a href=@{RepoCommitsR repo}>
[🛠 Changes]
<span>
<a href=@{RepoProposalsR user repo}>
[🧩 Patches]
^{followButton}
<h2>Clone
<code>darcs clone @{RepoR user repo}
<code>darcs clone @{RepoR repo}
<h2>Tags
@ -68,7 +65,7 @@ $maybe desc <- repoDesc repository
<div>
$forall (piece, piecePath) <- dirs
<a href=@{RepoSourceR user repo piecePath}>#{piece}
<a href=@{RepoSourceR repo piecePath}>#{piece}
/ #
$case sv
@ -90,15 +87,15 @@ $case sv
$of TypeTree
🗀
<td>
<a href=@{RepoSourceR user repo (dir ++ [name])}>
<a href=@{RepoSourceR repo (dir ++ [name])}>
#{name}
$maybe (readmeName, readmeWidget) <- mreadme
<h2>#{readmeName}
^{readmeWidget}
<div>
^{buttonW DELETE "Delete this repo" (RepoR user repo)}
^{buttonW POST "Delete this repo" (RepoDeleteR repo)}
<div>
<a href=@?{(RepoR user repo, [("prettyjson","true")])}>
<a href=@?{(RepoR repo, [("prettyjson","true")])}>
[See repo JSON]

View file

@ -13,74 +13,71 @@ $# You should have received a copy of the CC0 Public Domain Dedication along
$# with this software. If not, see
$# <http://creativecommons.org/publicdomain/zero/1.0/>.
$maybe (s, j, w, sw) <- mproject
<p>
Belongs to project
<a href=@{ProjectR (sharerIdent s) (projectIdent j)}>
$maybe name <- projectName j
#{name}
$nothing
#{prj2text $ projectIdent j}
$# $maybe (s, j, w, sw) <- mproject
$# <p>
$# Belongs to project
$# <a href=@{ProjectR (sharerIdent s) (projectIdent j)}>
$# $maybe name <- projectName j
$# #{name}
$# $nothing
$# #{prj2text $ projectIdent j}
$#
$# ^{personNavW $ sharerIdent s}
$#
$# ^{projectNavW j w sw (sharerIdent s) (projectIdent j)}
^{personNavW $ sharerIdent s}
<p>#{actorDesc actor}
^{projectNavW j w sw (sharerIdent s) (projectIdent j)}
$maybe desc <- repoDesc repository
<p>#{desc}
^{personNavW user}
$# ^{personNavW user}
<div>
<span>
[[ 🗃
<a href=@{RepoR user repo}>
#{rp2text repo}
<a href=@{RepoR repo}>
^#{keyHashidText repo} #{actorName actor}
]] ::
<span>
<a href=@{RepoInboxR user repo}>
<a href=@{RepoInboxR repo}>
[📥 Inbox]
<span>
<a href=@{RepoOutboxR user repo}>
<a href=@{RepoOutboxR repo}>
[📤 Outbox]
<span>
<a href=@{RepoFollowersR user repo}>
<a href=@{RepoFollowersR repo}>
[🐤 Followers]
<span>
<a href=@{RepoDevsR user repo}>
[🤝 Collaborators]
<span>
<a href=@{RepoHeadChangesR user repo}>
<a href=@{RepoCommitsR repo}>
[🛠 Commits]
<span>
<a href=@{RepoProposalsR user repo}>
[🧩 Merge Requests]
^{followButton}
<h2>Clone
<code>git clone @{RepoR user repo}
<code>git clone @{RepoR repo}
<h2>Branches
<ul>
$forall branch <- branches
<li>
<a href=@{RepoSourceR user repo [branch]}>#{branch}
<a href=@{RepoBranchSourceR repo branch []}>#{branch}
<h2>Tags
<ul>
$forall tag <- tags
<li>
<a href=@{RepoSourceR user repo [tag]}>#{tag}
<a href=@{RepoBranchSourceR repo tag []}>#{tag}
<div>
<a href=@{RepoSourceR user repo [ref]}>#{ref}
<a href=@{RepoBranchSourceR repo ref []}>#{ref}
:: #
$forall (piece, piecePath) <- dirs
<a href=@{RepoSourceR user repo (ref : piecePath)}>#{piece}
<a href=@{RepoBranchSourceR repo ref piecePath}>#{piece}
/ #
$case sv
@ -102,15 +99,15 @@ $case sv
$of TypeTree
🗀
<td>
<a href=@{RepoSourceR user repo (ref : (dir ++ [name]))}>
<a href=@{RepoBranchSourceR repo ref (dir ++ [name])}>
#{name}
$maybe (readmeName, readmeWidget) <- mreadme
<h2>#{readmeName}
^{readmeWidget}
<div>
^{buttonW DELETE "Delete this repo" (RepoR user repo)}
^{buttonW POST "Delete this repo" (RepoDeleteR repo)}
<div>
<a href=@?{(RepoR user repo, [("prettyjson","true")])}>
<a href=@?{(RepoR repo, [("prettyjson","true")])}>
[See repo JSON]

View file

@ -17,7 +17,7 @@
-- Yesod misc
-- ----------------------------------------------------------------------------
-- /highlight/#Text/style.css HighlightStyleR GET
/highlight/#Text/style.css HighlightStyleR GET
-- ----------------------------------------------------------------------------
-- Internal