Atom and RSS feeds for repo history
This commit is contained in:
parent
c5a50c336e
commit
bfa6436bb3
8 changed files with 52 additions and 28 deletions
|
@ -1,6 +1,6 @@
|
||||||
{- This file is part of Vervis.
|
{- This file is part of Vervis.
|
||||||
-
|
-
|
||||||
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
- Written in 2016, 2018 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
-
|
-
|
||||||
- ♡ Copying is an act of love. Please copy, reuse and share.
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
-
|
-
|
||||||
|
@ -22,6 +22,7 @@ where
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
|
import Data.Time.Clock (UTCTime)
|
||||||
|
|
||||||
import Data.EventTime.Local
|
import Data.EventTime.Local
|
||||||
|
|
||||||
|
@ -29,5 +30,5 @@ data LogEntry = LogEntry
|
||||||
{ leAuthor :: Text
|
{ leAuthor :: Text
|
||||||
, leHash :: Text
|
, leHash :: Text
|
||||||
, leMessage :: Text
|
, leMessage :: Text
|
||||||
, leTime :: EventTime
|
, leTime :: (UTCTime, EventTime)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{- This file is part of Vervis.
|
{- This file is part of Vervis.
|
||||||
-
|
-
|
||||||
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
- Written in 2016, 2018 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
-
|
-
|
||||||
- ♡ Copying is an act of love. Please copy, reuse and share.
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
-
|
-
|
||||||
|
@ -197,8 +197,10 @@ readChangesView path off lim = fmap maybeRight $ runExceptT $ do
|
||||||
, leHash = decodeStrict $ encodePatchHash h
|
, leHash = decodeStrict $ encodePatchHash h
|
||||||
, leMessage = piTitle pi
|
, leMessage = piTitle pi
|
||||||
, leTime =
|
, leTime =
|
||||||
intervalToEventTime $
|
( piTime pi
|
||||||
FriendlyConvert $
|
, intervalToEventTime $
|
||||||
now `diffUTCTime` piTime pi
|
FriendlyConvert $
|
||||||
|
now `diffUTCTime` piTime pi
|
||||||
|
)
|
||||||
}
|
}
|
||||||
return (total, map (uncurry toLE) $ reverse $ snd ps)
|
return (total, map (uncurry toLE) $ reverse $ snd ps)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{- This file is part of Vervis.
|
{- This file is part of Vervis.
|
||||||
-
|
-
|
||||||
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
- Written in 2016, 2018 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
-
|
-
|
||||||
- ♡ Copying is an act of love. Please copy, reuse and share.
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
-
|
-
|
||||||
|
@ -36,8 +36,10 @@ import Data.Set (Set)
|
||||||
import Data.String (fromString)
|
import Data.String (fromString)
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import Data.Text.Encoding (encodeUtf8)
|
import Data.Text.Encoding (encodeUtf8)
|
||||||
|
import Data.Time.Clock ()
|
||||||
|
import Data.Time.Clock.POSIX (posixSecondsToUTCTime)
|
||||||
import System.Hourglass (timeCurrent)
|
import System.Hourglass (timeCurrent)
|
||||||
import Time.Types (Elapsed (..))
|
import Time.Types (Elapsed (..), Seconds (..))
|
||||||
|
|
||||||
import qualified Data.ByteString.Lazy as BL (ByteString)
|
import qualified Data.ByteString.Lazy as BL (ByteString)
|
||||||
import qualified Data.DList as D (DList, empty, snoc, toList)
|
import qualified Data.DList as D (DList, empty, snoc, toList)
|
||||||
|
@ -158,12 +160,15 @@ readChangesView path ref off lim = withRepo (fromString path) $ \ git -> do
|
||||||
, leHash = toText $ toHex $ unObjId oid
|
, leHash = toText $ toHex $ unObjId oid
|
||||||
, leMessage = toText $ takeLine $ commitMessage commit
|
, leMessage = toText $ takeLine $ commitMessage commit
|
||||||
, leTime =
|
, leTime =
|
||||||
intervalToEventTime $
|
( utc t
|
||||||
FriendlyConvert $
|
, intervalToEventTime $
|
||||||
now - t
|
FriendlyConvert $
|
||||||
|
now - t
|
||||||
|
)
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
Elapsed t = gitTimeUTC $ personTime $ commitAuthor commit
|
Elapsed t = gitTimeUTC $ personTime $ commitAuthor commit
|
||||||
|
utc (Seconds i) = posixSecondsToUTCTime $ fromIntegral i
|
||||||
return (noNodes graph, map (uncurry mkrow) pairs')
|
return (noNodes graph, map (uncurry mkrow) pairs')
|
||||||
|
|
||||||
listRefs :: FilePath -> IO (Set Text, Set Text)
|
listRefs :: FilePath -> IO (Set Text, Set Text)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{- This file is part of Vervis.
|
{- This file is part of Vervis.
|
||||||
-
|
-
|
||||||
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
- Written in 2016, 2018 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
-
|
-
|
||||||
- ♡ Copying is an act of love. Please copy, reuse and share.
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
-
|
-
|
||||||
|
@ -63,6 +63,7 @@ import System.Hourglass (dateCurrent)
|
||||||
import Text.Blaze.Html (Html)
|
import Text.Blaze.Html (Html)
|
||||||
import Yesod.Auth (requireAuthId)
|
import Yesod.Auth (requireAuthId)
|
||||||
import Yesod.Core (defaultLayout, setMessage)
|
import Yesod.Core (defaultLayout, setMessage)
|
||||||
|
import Yesod.Core.Content (TypedContent)
|
||||||
import Yesod.Core.Handler (lookupPostParam, redirect, notFound)
|
import Yesod.Core.Handler (lookupPostParam, redirect, notFound)
|
||||||
import Yesod.Form.Functions (runFormPost)
|
import Yesod.Form.Functions (runFormPost)
|
||||||
import Yesod.Form.Types (FormResult (..))
|
import Yesod.Form.Types (FormResult (..))
|
||||||
|
@ -97,9 +98,7 @@ import Vervis.Widget.Sharer
|
||||||
import qualified Darcs.Local.Repository as D (createRepo)
|
import qualified Darcs.Local.Repository as D (createRepo)
|
||||||
import qualified Data.ByteString.Lazy as BL (ByteString)
|
import qualified Data.ByteString.Lazy as BL (ByteString)
|
||||||
import qualified Data.Git.Local as G (createRepo)
|
import qualified Data.Git.Local as G (createRepo)
|
||||||
import qualified Vervis.Darcs as D (readSourceView, readChangesView)
|
|
||||||
import qualified Vervis.Formatting as F
|
import qualified Vervis.Formatting as F
|
||||||
import qualified Vervis.Git as G (readSourceView, readChangesView, listRefs)
|
|
||||||
|
|
||||||
getReposR :: ShrIdent -> Handler Html
|
getReposR :: ShrIdent -> Handler Html
|
||||||
getReposR user = do
|
getReposR user = do
|
||||||
|
@ -245,14 +244,14 @@ getRepoSourceR shar repo refdir = do
|
||||||
[] -> notFound
|
[] -> notFound
|
||||||
(ref:dir) -> getGitRepoSource repository shar repo ref dir
|
(ref:dir) -> getGitRepoSource repository shar repo ref dir
|
||||||
|
|
||||||
getRepoHeadChangesR :: ShrIdent -> RpIdent -> Handler Html
|
getRepoHeadChangesR :: ShrIdent -> RpIdent -> Handler TypedContent
|
||||||
getRepoHeadChangesR user repo = do
|
getRepoHeadChangesR user repo = do
|
||||||
repository <- runDB $ selectRepo user repo
|
repository <- runDB $ selectRepo user repo
|
||||||
case repoVcs repository of
|
case repoVcs repository of
|
||||||
VCSDarcs -> getDarcsRepoHeadChanges user repo
|
VCSDarcs -> getDarcsRepoHeadChanges user repo
|
||||||
VCSGit -> getGitRepoHeadChanges repository user repo
|
VCSGit -> getGitRepoHeadChanges repository user repo
|
||||||
|
|
||||||
getRepoChangesR :: ShrIdent -> RpIdent -> Text -> Handler Html
|
getRepoChangesR :: ShrIdent -> RpIdent -> Text -> Handler TypedContent
|
||||||
getRepoChangesR shar repo ref = do
|
getRepoChangesR shar repo ref = do
|
||||||
repository <- runDB $ selectRepo shar repo
|
repository <- runDB $ selectRepo shar repo
|
||||||
case repoVcs repository of
|
case repoVcs repository of
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{- This file is part of Vervis.
|
{- This file is part of Vervis.
|
||||||
-
|
-
|
||||||
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
- Written in 2016, 2018 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
-
|
-
|
||||||
- ♡ Copying is an act of love. Please copy, reuse and share.
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
-
|
-
|
||||||
|
@ -35,7 +35,9 @@ import System.Directory (doesFileExist)
|
||||||
import Text.Blaze.Html (Html)
|
import Text.Blaze.Html (Html)
|
||||||
import Yesod.Core (defaultLayout, setTitle)
|
import Yesod.Core (defaultLayout, setTitle)
|
||||||
import Yesod.Core.Content (TypedContent, typeOctet)
|
import Yesod.Core.Content (TypedContent, typeOctet)
|
||||||
import Yesod.Core.Handler (sendFile, notFound)
|
import Yesod.Core.Handler (selectRep, provideRep, sendFile, notFound)
|
||||||
|
import Yesod.AtomFeed (atomFeed)
|
||||||
|
import Yesod.RssFeed (rssFeed)
|
||||||
|
|
||||||
import qualified Data.DList as D
|
import qualified Data.DList as D
|
||||||
import qualified Data.Set as S (member)
|
import qualified Data.Set as S (member)
|
||||||
|
@ -44,6 +46,7 @@ import qualified Data.Text.Lazy.Encoding as L (decodeUtf8With)
|
||||||
|
|
||||||
import Data.ByteString.Char8.Local (takeLine)
|
import Data.ByteString.Char8.Local (takeLine)
|
||||||
import Text.FilePath.Local (breakExt)
|
import Text.FilePath.Local (breakExt)
|
||||||
|
import Vervis.ChangeFeed (changeFeed)
|
||||||
import Vervis.Form.Repo
|
import Vervis.Form.Repo
|
||||||
import Vervis.Foundation
|
import Vervis.Foundation
|
||||||
import Vervis.Path
|
import Vervis.Path
|
||||||
|
@ -74,7 +77,7 @@ getDarcsRepoSource repository user repo dir = do
|
||||||
dirs = zip parent (tail $ inits parent)
|
dirs = zip parent (tail $ inits parent)
|
||||||
defaultLayout $(widgetFile "repo/source-darcs")
|
defaultLayout $(widgetFile "repo/source-darcs")
|
||||||
|
|
||||||
getDarcsRepoHeadChanges :: ShrIdent -> RpIdent -> Handler Html
|
getDarcsRepoHeadChanges :: ShrIdent -> RpIdent -> Handler TypedContent
|
||||||
getDarcsRepoHeadChanges shar repo = do
|
getDarcsRepoHeadChanges shar repo = do
|
||||||
path <- askRepoDir shar repo
|
path <- askRepoDir shar repo
|
||||||
(entries, navModel) <- getPageAndNav $
|
(entries, navModel) <- getPageAndNav $
|
||||||
|
@ -85,9 +88,13 @@ getDarcsRepoHeadChanges shar repo = do
|
||||||
Just v -> return v
|
Just v -> return v
|
||||||
let changes = changesW entries
|
let changes = changesW entries
|
||||||
pageNav = navWidget navModel
|
pageNav = navWidget navModel
|
||||||
defaultLayout $(widgetFile "repo/changes-darcs")
|
feed = changeFeed shar repo Nothing VCSDarcs entries
|
||||||
|
selectRep $ do
|
||||||
|
provideRep $ defaultLayout $(widgetFile "repo/changes-darcs")
|
||||||
|
provideRep $ atomFeed feed
|
||||||
|
provideRep $ rssFeed feed
|
||||||
|
|
||||||
getDarcsRepoChanges :: ShrIdent -> RpIdent -> Text -> Handler Html
|
getDarcsRepoChanges :: ShrIdent -> RpIdent -> Text -> Handler TypedContent
|
||||||
getDarcsRepoChanges shar repo tag = notFound
|
getDarcsRepoChanges shar repo tag = notFound
|
||||||
|
|
||||||
getDarcsDownloadR :: ShrIdent -> RpIdent -> [Text] -> Handler TypedContent
|
getDarcsDownloadR :: ShrIdent -> RpIdent -> [Text] -> Handler TypedContent
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{- This file is part of Vervis.
|
{- This file is part of Vervis.
|
||||||
-
|
-
|
||||||
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
- Written in 2016, 2018 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
-
|
-
|
||||||
- ♡ Copying is an act of love. Please copy, reuse and share.
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
-
|
-
|
||||||
|
@ -44,7 +44,10 @@ import System.Directory (createDirectoryIfMissing)
|
||||||
import System.Hourglass (dateCurrent)
|
import System.Hourglass (dateCurrent)
|
||||||
import Text.Blaze.Html (Html)
|
import Text.Blaze.Html (Html)
|
||||||
import Yesod.Core (defaultLayout)
|
import Yesod.Core (defaultLayout)
|
||||||
import Yesod.Core.Handler (notFound)
|
import Yesod.Core.Content (TypedContent)
|
||||||
|
import Yesod.Core.Handler (selectRep, provideRep, notFound)
|
||||||
|
import Yesod.AtomFeed (atomFeed)
|
||||||
|
import Yesod.RssFeed (rssFeed)
|
||||||
|
|
||||||
import qualified Data.DList as D
|
import qualified Data.DList as D
|
||||||
import qualified Data.Set as S (member)
|
import qualified Data.Set as S (member)
|
||||||
|
@ -53,6 +56,7 @@ import qualified Data.Text.Lazy.Encoding as L (decodeUtf8With)
|
||||||
import Data.ByteString.Char8.Local (takeLine)
|
import Data.ByteString.Char8.Local (takeLine)
|
||||||
import Data.Git.Local
|
import Data.Git.Local
|
||||||
import Text.FilePath.Local (breakExt)
|
import Text.FilePath.Local (breakExt)
|
||||||
|
import Vervis.ChangeFeed (changeFeed)
|
||||||
import Vervis.Form.Repo
|
import Vervis.Form.Repo
|
||||||
import Vervis.Foundation
|
import Vervis.Foundation
|
||||||
import Vervis.Path
|
import Vervis.Path
|
||||||
|
@ -83,11 +87,11 @@ getGitRepoSource repository user repo ref dir = do
|
||||||
dirs = zip parent (tail $ inits parent)
|
dirs = zip parent (tail $ inits parent)
|
||||||
defaultLayout $(widgetFile "repo/source-git")
|
defaultLayout $(widgetFile "repo/source-git")
|
||||||
|
|
||||||
getGitRepoHeadChanges :: Repo -> ShrIdent -> RpIdent -> Handler Html
|
getGitRepoHeadChanges :: Repo -> ShrIdent -> RpIdent -> Handler TypedContent
|
||||||
getGitRepoHeadChanges repository shar repo =
|
getGitRepoHeadChanges repository shar repo =
|
||||||
getGitRepoChanges shar repo $ repoMainBranch repository
|
getGitRepoChanges shar repo $ repoMainBranch repository
|
||||||
|
|
||||||
getGitRepoChanges :: ShrIdent -> RpIdent -> Text -> Handler Html
|
getGitRepoChanges :: ShrIdent -> RpIdent -> Text -> Handler TypedContent
|
||||||
getGitRepoChanges shar repo ref = do
|
getGitRepoChanges shar repo ref = do
|
||||||
path <- askRepoDir shar repo
|
path <- askRepoDir shar repo
|
||||||
(branches, tags) <- liftIO $ G.listRefs path
|
(branches, tags) <- liftIO $ G.listRefs path
|
||||||
|
@ -98,5 +102,9 @@ getGitRepoChanges shar repo ref = do
|
||||||
let refSelect = refSelectW shar repo branches tags
|
let refSelect = refSelectW shar repo branches tags
|
||||||
changes = changesW entries
|
changes = changesW entries
|
||||||
pageNav = navWidget navModel
|
pageNav = navWidget navModel
|
||||||
defaultLayout $(widgetFile "repo/changes-git")
|
feed = changeFeed shar repo (Just ref) VCSGit entries
|
||||||
|
selectRep $ do
|
||||||
|
provideRep $ defaultLayout $(widgetFile "repo/changes-git")
|
||||||
|
provideRep $ atomFeed feed
|
||||||
|
provideRep $ rssFeed feed
|
||||||
else notFound
|
else notFound
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
$# This file is part of Vervis.
|
$# This file is part of Vervis.
|
||||||
$#
|
$#
|
||||||
$# Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
$# Written in 2016, 2018 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
$#
|
$#
|
||||||
$# ♡ Copying is an act of love. Please copy, reuse and share.
|
$# ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
$#
|
$#
|
||||||
|
@ -18,7 +18,7 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
<th>Hash
|
<th>Hash
|
||||||
<th>Message
|
<th>Message
|
||||||
<th>Time
|
<th>Time
|
||||||
$forall LogEntry author hash message time <- entries
|
$forall LogEntry author hash message (_, time) <- entries
|
||||||
<tr>
|
<tr>
|
||||||
<td>#{author}
|
<td>#{author}
|
||||||
<td .hash>#{T.take 10 hash}
|
<td .hash>#{T.take 10 hash}
|
||||||
|
|
|
@ -101,6 +101,7 @@ library
|
||||||
Vervis.Avatar
|
Vervis.Avatar
|
||||||
Vervis.BinaryBody
|
Vervis.BinaryBody
|
||||||
Vervis.Changes
|
Vervis.Changes
|
||||||
|
Vervis.ChangeFeed
|
||||||
Vervis.Colour
|
Vervis.Colour
|
||||||
Vervis.Content
|
Vervis.Content
|
||||||
Vervis.Darcs
|
Vervis.Darcs
|
||||||
|
@ -313,6 +314,7 @@ library
|
||||||
, yesod-core
|
, yesod-core
|
||||||
, yesod-form
|
, yesod-form
|
||||||
, yesod-mail-send
|
, yesod-mail-send
|
||||||
|
, yesod-newsfeed
|
||||||
, yesod-static
|
, yesod-static
|
||||||
, yesod-persistent
|
, yesod-persistent
|
||||||
-- for reading gzipped darcs inventory via utils in
|
-- for reading gzipped darcs inventory via utils in
|
||||||
|
|
Loading…
Reference in a new issue