Upgrade to GHC 8.4 and LTS 12

This commit is contained in:
fr33domlover 2018-12-05 03:41:19 +00:00
parent 4c17e3486b
commit 33338a73cc
14 changed files with 128 additions and 155 deletions

View file

@ -1,17 +1,16 @@
#!/bin/sh #!/bin/sh
VERVIS='https://dev.angeley.es/s/fr33domlover/r' VERVIS='https://dev.angeley.es/s/fr33domlover/r'
HUB='https://hub.darcs.net/fr33domlover'
mkdir -p lib mkdir -p lib
cd lib cd lib
darcs clone $HUB/hit-graph darcs clone $VERVIS/hit-graph
darcs clone $HUB/hit-harder darcs clone $VERVIS/hit-harder
darcs clone $HUB/hit-network darcs clone $VERVIS/hit-network
darcs clone $VERVIS/darcs-lights darcs clone $VERVIS/darcs-lights
darcs clone $VERVIS/darcs-rev darcs clone $VERVIS/darcs-rev
darcs clone $VERVIS/ssh darcs clone $VERVIS/ssh
darcs clone $VERVIS/persistent-migration darcs clone $VERVIS/persistent-migration
darcs clone $VERVIS/persistent-email-address darcs clone $VERVIS/persistent-email-address
darcs clone $VERVIS/time-interval-aeson darcs clone $VERVIS/time-interval-aeson
darcs clone $VERVIS/yesod-mail-send --to-hash 2800294a41daf57cd420710bc79c8c9b06c0d3dd darcs clone $VERVIS/yesod-mail-send

View file

@ -36,13 +36,13 @@ import Data.Hashable (Hashable)
import Data.String (IsString) import Data.String (IsString)
newtype AsOriginal s = AsOriginal { unOriginal :: CI s } newtype AsOriginal s = AsOriginal { unOriginal :: CI s }
deriving (Eq, Ord, Read, Show, IsString, Monoid, Hashable, FoldCase) deriving (Eq, Ord, Read, Show, IsString, Semigroup, Hashable, FoldCase)
mkOrig :: FoldCase s => s -> AsOriginal s mkOrig :: FoldCase s => s -> AsOriginal s
mkOrig = AsOriginal . mk mkOrig = AsOriginal . mk
newtype AsCaseFolded s = AsCaseFolded { unCaseFolded :: CI s } newtype AsCaseFolded s = AsCaseFolded { unCaseFolded :: CI s }
deriving (Eq, Ord, Read, Show, IsString, Monoid, Hashable, FoldCase) deriving (Eq, Ord, Read, Show, IsString, Semigroup, Hashable, FoldCase)
mkFolded :: FoldCase s => s -> AsCaseFolded s mkFolded :: FoldCase s => s -> AsCaseFolded s
mkFolded = AsCaseFolded . mk mkFolded = AsCaseFolded . mk

View file

@ -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.
- -
@ -33,6 +33,7 @@ import Control.Monad (when)
import Data.Byteable (toBytes) import Data.Byteable (toBytes)
import Data.Git import Data.Git
import Data.Git.Harder import Data.Git.Harder
import Data.Git.Ref (SHA1)
import Data.Git.Types (GitTime (..)) import Data.Git.Types (GitTime (..))
import Data.Set (Set) import Data.Set (Set)
import Data.Text (Text) import Data.Text (Text)
@ -104,7 +105,7 @@ data PathView
| TreeView Text ObjId TreeRows | TreeView Text ObjId TreeRows
| BlobView Text ObjId BL.ByteString | BlobView Text ObjId BL.ByteString
viewPath :: Git -> Tree -> EntPath -> IO PathView viewPath :: Git SHA1 -> Tree SHA1 -> EntPath -> IO PathView
viewPath git root path = do viewPath git root path = do
let toEnt False = EntObjBlob let toEnt False = EntObjBlob
toEnt True = EntObjTree toEnt True = EntObjTree
@ -122,8 +123,8 @@ viewPath git root path = do
Left blob -> return $ BlobView nameT oid (blobGetContent blob) Left blob -> return $ BlobView nameT oid (blobGetContent blob)
Right tree -> TreeView nameT oid <$> mkRows tree Right tree -> TreeView nameT oid <$> mkRows tree
listBranches :: Git -> IO (Set Text) listBranches :: Git SHA1 -> IO (Set Text)
listBranches git = S.mapMonotonic (T.pack . refNameRaw) <$> branchList git listBranches git = S.mapMonotonic (T.pack . refNameRaw) <$> branchList git
listTags :: Git -> IO (Set Text) listTags :: Git SHA1 -> IO (Set Text)
listTags git = S.mapMonotonic (T.pack . refNameRaw) <$> tagList git listTags git = S.mapMonotonic (T.pack . refNameRaw) <$> tagList git

View file

@ -13,7 +13,6 @@ module Database.Persist.Local.Sql.Orphan.Common
( fieldName ( fieldName
, dummyFromFilts , dummyFromFilts
, getFiltsValues , getFiltsValues
, updatePersistValue
, filterClause , filterClause
, orderClause , orderClause
) )
@ -203,10 +202,6 @@ filterClauseHelper includeTable includeWhere conn orNull filters =
showSqlFilter NotIn = " NOT IN " showSqlFilter NotIn = " NOT IN "
showSqlFilter (BackendSpecificFilter s) = s showSqlFilter (BackendSpecificFilter s) = s
updatePersistValue :: Update v -> PersistValue
updatePersistValue (Update _ v _) = toPersistValue v
updatePersistValue _ = error "BackendUpdate not implemented"
filterClause :: (PersistEntity val, PersistEntityBackend val ~ SqlBackend) filterClause :: (PersistEntity val, PersistEntityBackend val ~ SqlBackend)
=> Bool -- ^ include table name? => Bool -- ^ include table name?
-> SqlBackend -> SqlBackend

View file

@ -102,7 +102,7 @@ makeFoundation appSettings = do
appSvgFont <- appSvgFont <-
if appLoadFontFromLibData appSettings if appLoadFontFromLibData appSettings
then return lin2 then lin2
else loadFont "data/LinLibertineCut.svg" else loadFont "data/LinLibertineCut.svg"
-- We need a log function to create a connection pool. We need a connection -- We need a log function to create a connection pool. We need a connection

View file

@ -386,7 +386,7 @@ instance Yesod App where
-- What messages should be logged. The following includes all messages when -- What messages should be logged. The following includes all messages when
-- in development, and warnings and errors in production. -- in development, and warnings and errors in production.
shouldLog app _source level = shouldLogIO app _source level = pure $
appShouldLogAll (appSettings app) appShouldLogAll (appSettings app)
|| level == LevelWarn || level == LevelWarn
|| level == LevelError || level == LevelError
@ -433,7 +433,7 @@ instance YesodAuth App where
-- Override the above two destinations when a Referer: header is present -- Override the above two destinations when a Referer: header is present
redirectToReferer _ = True redirectToReferer _ = True
authenticate creds = do authenticate creds = liftHandler $ do
let ident = credsIdent creds let ident = credsIdent creds
mpid <- runDB $ getBy $ UniquePersonLogin $ credsIdent creds mpid <- runDB $ getBy $ UniquePersonLogin $ credsIdent creds
return $ case mpid of return $ case mpid of
@ -443,7 +443,7 @@ instance YesodAuth App where
-- You can add other plugins like BrowserID, email or OAuth here -- You can add other plugins like BrowserID, email or OAuth here
authPlugins _ = [accountPlugin] authPlugins _ = [accountPlugin]
authHttpManager = getHttpManager authHttpManager = getsYesod getHttpManager
onLogout = clearUnverifiedCreds False onLogout = clearUnverifiedCreds False
@ -517,7 +517,7 @@ instance YesodAuthAccount AccountPersistDB' App where
allowLoginByEmailAddress _ = True allowLoginByEmailAddress _ = True
runAccountDB = unAccountPersistDB' runAccountDB = unAccountPersistDB'
unregisteredLogin u = do unregisteredLogin u = do
lift $ setUnverifiedCreds True $ Creds "account" (username u) [] setUnverifiedCreds True $ Creds "account" (username u) []
return mempty return mempty
-- This instance is required to use forms. You can modify renderMessage to -- This instance is required to use forms. You can modify renderMessage to

View file

@ -18,24 +18,27 @@ module Vervis.Git
, readChangesView , readChangesView
, listRefs , listRefs
, readPatch , readPatch
, lastCommitTime
) )
where where
import Prelude import Prelude
import Control.Arrow ((***)) import Control.Arrow ((***))
import Control.Monad (join)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Except
import Data.Algorithm.Patience (diff, Item (..)) import Data.Algorithm.Patience (diff, Item (..))
import Data.Byteable (toBytes) import Data.Byteable (toBytes)
import Data.Foldable (find) import Data.Foldable (foldlM, find)
import Data.Git
import Data.Git.Diff import Data.Git.Diff
import Data.Git.Graph import Data.Git.Graph
import Data.Git.Harder import Data.Git.Harder
import Data.Git.Ref (fromHex, toHex) import Data.Git.Monad
import Data.Git.Repository (getCommit) import Data.Git.Ref (SHA1, fromHex, toHex)
import Data.Git.Storage (getObject_) import Data.Git.Storage (getObject_)
import Data.Git.Storage.Object (Object (..)) import Data.Git.Storage.Object (Object (..))
import Data.Git.Types (GitTime (..)) import Data.Git.Types (GitTime (..), ModePerm (..), EntPath, Blob (..))
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.NonEmpty (NonEmpty ((:|))) import Data.List.NonEmpty (NonEmpty ((:|)))
@ -43,7 +46,8 @@ 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, decodeUtf8) import Data.Text.Encoding (encodeUtf8, decodeUtf8)
import Data.Time.Clock () import Data.Time.Calendar (Day (..))
import Data.Time.Clock (UTCTime (..))
import Data.Time.Clock.POSIX (posixSecondsToUTCTime) import Data.Time.Clock.POSIX (posixSecondsToUTCTime)
import Data.Traversable (for) import Data.Traversable (for)
import Data.Word (Word32) import Data.Word (Word32)
@ -54,8 +58,9 @@ import Time.Types (Elapsed (..), Seconds (..))
import qualified Data.ByteString as B (intercalate) import qualified Data.ByteString as B (intercalate)
import qualified Data.ByteString.Lazy as BL (ByteString, toStrict, length) import qualified Data.ByteString.Lazy as BL (ByteString, toStrict, length)
import qualified Data.DList as D (DList, empty, snoc, toList) import qualified Data.DList as D (DList, empty, snoc, toList)
import qualified Data.Git as G
import qualified Data.List.NonEmpty as N (toList) import qualified Data.List.NonEmpty as N (toList)
import qualified Data.Set as S (member, mapMonotonic) import qualified Data.Set as S (member, mapMonotonic, toList)
import qualified Data.Text as T (pack, unpack, break, strip) import qualified Data.Text as T (pack, unpack, break, strip)
import qualified Data.Text.Encoding as TE (decodeUtf8With) import qualified Data.Text.Encoding as TE (decodeUtf8With)
import qualified Data.Text.Encoding.Error as TE (lenientDecode) import qualified Data.Text.Encoding.Error as TE (lenientDecode)
@ -77,7 +82,7 @@ matchReadme _ = False
-- | Find a README file in a directory. Return the filename and the file -- | Find a README file in a directory. Return the filename and the file
-- content. -- content.
findReadme :: Git -> TreeRows -> IO (Maybe (Text, BL.ByteString)) findReadme :: Git SHA1 -> TreeRows -> IO (Maybe (Text, BL.ByteString))
findReadme git rows = findReadme git rows =
case find matchReadme rows of case find matchReadme rows of
Nothing -> return Nothing Nothing -> return Nothing
@ -95,23 +100,23 @@ rowToEntry :: (ModePerm, ObjId, Text, EntObjType) -> DirEntry
rowToEntry (_, _, name, etype) = DirEntry (matchType etype) name rowToEntry (_, _, name, etype) = DirEntry (matchType etype) name
loadSourceView loadSourceView
:: Git :: Git SHA1
-> Text -> Text
-> [Text] -> [Text]
-> IO (Set RefName, Set RefName, Maybe (SourceView BL.ByteString)) -> IO (Set RefName, Set RefName, Maybe (SourceView BL.ByteString))
loadSourceView git refT dir = do loadSourceView git refT dir = do
branches <- branchList git branches <- G.branchList git
tags <- tagList git tags <- G.tagList git
let refS = T.unpack refT let refS = T.unpack refT
refN = RefName refS refN = RefName refS
msv <- if refN `S.member` branches || refN `S.member` tags msv <- if refN `S.member` branches || refN `S.member` tags
then do then do
tipOid <- resolveName git refS tipOid <- resolveName git refS
mtree <- resolveTreeish git $ unObjId tipOid mtree <- G.resolveTreeish git $ unObjId tipOid
case mtree of case mtree of
Nothing -> return Nothing Nothing -> return Nothing
Just tree -> do Just tree -> do
let dir' = map (entName . encodeUtf8) dir let dir' = map (G.entName . encodeUtf8) dir
view <- viewPath git tree dir' view <- viewPath git tree dir'
Just <$> case view of Just <$> case view of
RootView rows -> do RootView rows -> do
@ -140,7 +145,7 @@ readSourceView
-- ^ Branches, tags, view of the selected item -- ^ Branches, tags, view of the selected item
readSourceView path ref dir = do readSourceView path ref dir = do
(bs, ts, msv) <- (bs, ts, msv) <-
withRepo (fromString path) $ \ git -> loadSourceView git ref dir G.withRepo (fromString path) $ \ git -> loadSourceView git ref dir
let toTexts = S.mapMonotonic $ T.pack . refNameRaw let toTexts = S.mapMonotonic $ T.pack . refNameRaw
return (toTexts bs, toTexts ts, renderSources dir <$> msv) return (toTexts bs, toTexts ts, renderSources dir <$> msv)
@ -159,7 +164,7 @@ readChangesView
-- ^ Limit, i.e. how many latest commits to take after the offset -- ^ Limit, i.e. how many latest commits to take after the offset
-> IO (Int, [LogEntry]) -> IO (Int, [LogEntry])
-- ^ Total number of ref's changes, and view of selected ref's change log -- ^ Total number of ref's changes, and view of selected ref's change log
readChangesView path ref off lim = withRepo (fromString path) $ \ git -> do readChangesView path ref off lim = G.withRepo (fromString path) $ \ git -> do
oid <- resolveName git $ T.unpack ref oid <- resolveName git $ T.unpack ref
graph <- loadCommitGraphPT git [oid] graph <- loadCommitGraphPT git [oid]
let mnodes = topsortUnmixOrder graph (NodeStack [noNodes graph]) let mnodes = topsortUnmixOrder graph (NodeStack [noNodes graph])
@ -187,10 +192,10 @@ readChangesView path ref off lim = withRepo (fromString path) $ \ git -> do
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)
listRefs path = withRepo (fromString path) $ \ git -> listRefs path = G.withRepo (fromString path) $ \ git ->
(,) <$> listBranches git <*> listTags git (,) <$> listBranches git <*> listTags git
patch :: [Edit] -> Commit -> Patch patch :: [Edit] -> Commit SHA1 -> Patch
patch edits c = Patch patch edits c = Patch
{ patchAuthorName = decodeUtf8 $ personName $ commitAuthor c { patchAuthorName = decodeUtf8 $ personName $ commitAuthor c
, patchAuthorEmail = , patchAuthorEmail =
@ -251,7 +256,7 @@ mkdiff old new =
map eitherOldNew $ map eitherOldNew $
diff (zipWith Line [1..] old) (zipWith Line [1..] new) diff (zipWith Line [1..] old) (zipWith Line [1..] new)
accumEdits :: BlobStateDiff -> [Edit] -> [Edit] accumEdits :: BlobStateDiff SHA1 -> [Edit] -> [Edit]
accumEdits (OnlyOld bs) es = accumEdits (OnlyOld bs) es =
case bsContent bs of case bsContent bs of
FileContent lines -> RemoveTextFile (ep2fp $ bsFilename bs) (unModePerm $ bsMode bs) (map (decodeUtf8 . BL.toStrict) lines) : es FileContent lines -> RemoveTextFile (ep2fp $ bsFilename bs) (unModePerm $ bsMode bs) (map (decodeUtf8 . BL.toStrict) lines) : es
@ -277,14 +282,36 @@ accumEdits (OldAndNew old new) es =
else error "getDiffWith gave OldAndNew with different file paths" else error "getDiffWith gave OldAndNew with different file paths"
readPatch :: FilePath -> Text -> IO (Patch, [Text]) readPatch :: FilePath -> Text -> IO (Patch, [Text])
readPatch path hash = withRepo (fromString path) $ \ git -> do readPatch path hash = G.withRepo (fromString path) $ \ git -> do
let ref = fromHex $ encodeUtf8 hash let ref = fromHex $ encodeUtf8 hash
c <- getCommit git ref c <- G.getCommit git ref
medits <- case commitParents c of medits <- case commitParents c of
[] -> error "Use the tree to generate list of AddFile diff parts?" [] -> error "Use the tree to generate list of AddFile diff parts?"
[p] -> Right <$> getDiffWith accumEdits [] p ref git [p] -> Right <$> getDiffWith accumEdits [] p ref git
ps -> fmap Left $ for ps $ \ p -> ps -> fmap Left $ for ps $ \ p ->
decodeUtf8 . takeLine . commitMessage <$> getCommit git p decodeUtf8 . takeLine . commitMessage <$> G.getCommit git p
return $ case medits of return $ case medits of
Left parents -> (patch [] c, parents) Left parents -> (patch [] c, parents)
Right edits -> (patch edits c, []) Right edits -> (patch edits c, [])
lastCommitTime :: FilePath -> IO (Maybe UTCTime)
lastCommitTime repo =
(either fail return =<<) $ fmap join $ withRepo (fromString repo) $ runExceptT $ do
branches <- S.toList <$> lift branchList
lct <- foldlM' utc0 branches $ \ time branch -> do
mcommit <- lift $ getCommit branch
case mcommit of
Nothing ->
throwE $
"lastCommitTime: Failed to get commit for branch " ++
refNameRaw branch
Just c ->
return $ max time $
utc $ gitTimeUTC $ personTime $ commitCommitter c
return $ if null branches
then Nothing
else Just lct
where
utc (Elapsed (Seconds i)) = posixSecondsToUTCTime $ fromIntegral i
utc0 = UTCTime (ModifiedJulianDay 0) 0
foldlM' i l f = foldlM f i l

View file

@ -34,7 +34,7 @@ import Vervis.Model.Repo
import Vervis.Path import Vervis.Path
import Data.EventTime.Local import Data.EventTime.Local
import qualified Vervis.GitOld as G import qualified Vervis.Git as G
import qualified Vervis.Darcs as D import qualified Vervis.Darcs as D
intro :: Handler Html intro :: Handler Html
@ -56,20 +56,19 @@ intro = do
, repo ^. RepoVcs , repo ^. RepoVcs
) )
now <- liftIO getCurrentTime now <- liftIO getCurrentTime
let utc (Seconds i) = posixSecondsToUTCTime $ fromIntegral i
forM repos $ forM repos $
\ (Value sharer, Value mproj, Value repo, Value vcs) -> do \ (Value sharer, Value mproj, Value repo, Value vcs) -> do
path <- askRepoDir sharer repo path <- askRepoDir sharer repo
mlast <- case vcs of mlast <- case vcs of
VCSDarcs -> liftIO $ D.lastChange path now VCSDarcs -> liftIO $ D.lastChange path now
VCSGit -> do VCSGit -> do
mel <- liftIO $ G.lastChange path mt <- liftIO $ G.lastCommitTime path
return $ Just $ case mel of return $ Just $ case mt of
Nothing -> Never Nothing -> Never
Just (Elapsed t) -> Just t ->
intervalToEventTime $ intervalToEventTime $
FriendlyConvert $ FriendlyConvert $
now `diffUTCTime` utc t now `diffUTCTime` t
return (sharer, mproj, repo, vcs, mlast) return (sharer, mproj, repo, vcs, mlast)
defaultLayout $ do defaultLayout $ do
setTitle "Welcome to Vervis!" setTitle "Welcome to Vervis!"

View file

@ -120,11 +120,10 @@ maybeUnverifiedAuth
maybeUnverifiedAuth = maybeUnverifiedAuth =
maybeEntity unverifiedLoginKey CachedUnverifiedLogin unCachedUnverifiedLogin maybeEntity unverifiedLoginKey CachedUnverifiedLogin unCachedUnverifiedLogin
-- TODO fix signatures when moving to GHC 8
maybeAuthIdAllowUnverified maybeAuthIdAllowUnverified
:: ( -- MonadHandler m :: ( MonadHandler m
-- , HandlerSite m ~ master , HandlerSite m ~ master
YesodPersist master , YesodPersist master
, YesodPersistBackend master ~ backend , YesodPersistBackend master ~ backend
, PersistStoreRead backend , PersistStoreRead backend
, YesodAuth master , YesodAuth master
@ -132,16 +131,15 @@ maybeAuthIdAllowUnverified
, PersistRecordBackend record backend , PersistRecordBackend record backend
, Typeable record , Typeable record
) )
-- => m (Maybe (Key record, Bool)) => m (Maybe (Key record, Bool))
=> HandlerT master IO (Maybe (Key record, Bool))
maybeAuthIdAllowUnverified = runMaybeT $ maybeAuthIdAllowUnverified = runMaybeT $
(, True) <$> MaybeT maybeVerifiedAuthId (, True) <$> MaybeT maybeVerifiedAuthId
<|> (, False) <$> MaybeT maybeUnverifiedAuthId <|> (, False) <$> MaybeT maybeUnverifiedAuthId
maybeAuthAllowUnverified maybeAuthAllowUnverified
:: ( -- MonadHandler m :: ( MonadHandler m
-- , HandlerSite m ~ master , HandlerSite m ~ master
YesodPersist master , YesodPersist master
, YesodPersistBackend master ~ backend , YesodPersistBackend master ~ backend
, PersistStoreRead backend , PersistStoreRead backend
, YesodAuthPersist master , YesodAuthPersist master
@ -150,25 +148,20 @@ maybeAuthAllowUnverified
, PersistRecordBackend record backend , PersistRecordBackend record backend
, Typeable record , Typeable record
) )
-- => m (Maybe (Entity record, Bool)) => m (Maybe (Entity record, Bool))
=> HandlerT master IO (Maybe (Entity record, Bool))
maybeAuthAllowUnverified = runMaybeT $ maybeAuthAllowUnverified = runMaybeT $
(, True) <$> MaybeT maybeVerifiedAuth (, True) <$> MaybeT maybeVerifiedAuth
<|> (, False) <$> MaybeT maybeUnverifiedAuth <|> (, False) <$> MaybeT maybeUnverifiedAuth
maybeVerifiedAuthId maybeVerifiedAuthId
{-
:: ( MonadHandler m :: ( MonadHandler m
, HandlerSite m ~ master , HandlerSite m ~ master
, YesodAuth master , YesodAuth master
) )
=> m (Maybe (AuthId master)) => m (Maybe (AuthId master))
-}
:: YesodAuth master => HandlerT master IO (Maybe (AuthId master))
maybeVerifiedAuthId = maybeAuthId maybeVerifiedAuthId = maybeAuthId
maybeVerifiedAuth maybeVerifiedAuth
{-
:: ( MonadHandler m :: ( MonadHandler m
, HandlerSite m ~ master , HandlerSite m ~ master
, YesodAuthPersist master , YesodAuthPersist master
@ -178,14 +171,6 @@ maybeVerifiedAuth
, Typeable record , Typeable record
) )
=> m (Maybe (Entity record)) => m (Maybe (Entity record))
-}
:: ( YesodAuthPersist master
, AuthId master ~ Key record
, AuthEntity master ~ record
, PersistEntity record
, Typeable record
)
=> HandlerT master IO (Maybe (Entity record))
maybeVerifiedAuth = maybeAuth maybeVerifiedAuth = maybeAuth
handleAuthLack :: (YesodAuth (HandlerSite m), MonadHandler m) => m a handleAuthLack :: (YesodAuth (HandlerSite m), MonadHandler m) => m a
@ -201,7 +186,8 @@ handleAuthLack = do
Nothing -> permissionDenied "Please configure authRoute" Nothing -> permissionDenied "Please configure authRoute"
handleUnverified handleUnverified
:: YesodAuthVerify master => (a, Bool) -> HandlerT master IO a :: (MonadHandler m, YesodAuthVerify (HandlerSite m))
=> (a, Bool) -> m a
handleUnverified (v, True) = return v handleUnverified (v, True) = return v
handleUnverified (_v, False) = do handleUnverified (_v, False) = do
aj <- acceptsJson aj <- acceptsJson
@ -213,7 +199,9 @@ handleUnverified (_v, False) = do
when (redirectToCurrent y) setUltDestCurrent when (redirectToCurrent y) setUltDestCurrent
redirect $ verificationRoute y redirect $ verificationRoute y
handleVerified :: YesodAuth master => (a, Bool) -> HandlerT master IO a handleVerified
:: (MonadHandler m, YesodAuth (HandlerSite m))
=> (a, Bool) -> m a
handleVerified (v, False) = return v handleVerified (v, False) = return v
handleVerified (_v, True) = do handleVerified (_v, True) = do
aj <- acceptsJson aj <- acceptsJson
@ -230,9 +218,9 @@ handleVerified (_v, True) = do
-- @since 1.1.0 -- @since 1.1.0
requireUnverifiedAuthId requireUnverifiedAuthId
:: ( -- MonadHandler m :: ( MonadHandler m
-- , HandlerSite m ~ master , HandlerSite m ~ master
YesodPersist master , YesodPersist master
, YesodPersistBackend master ~ backend , YesodPersistBackend master ~ backend
, PersistStoreRead backend , PersistStoreRead backend
, YesodAuth master , YesodAuth master
@ -240,8 +228,7 @@ requireUnverifiedAuthId
, PersistRecordBackend record backend , PersistRecordBackend record backend
, Typeable record , Typeable record
) )
-- => m (Key record) => m (Key record)
=> HandlerT master IO (Key record)
requireUnverifiedAuthId = requireUnverifiedAuthId =
maybeAuthIdAllowUnverified >>= maybe handleAuthLack handleVerified maybeAuthIdAllowUnverified >>= maybe handleAuthLack handleVerified
@ -251,9 +238,9 @@ requireUnverifiedAuthId =
-- @since 1.1.0 -- @since 1.1.0
requireUnverifiedAuth requireUnverifiedAuth
:: ( -- MonadHandler m :: ( MonadHandler m
-- , HandlerSite m ~ master , HandlerSite m ~ master
YesodPersist master , YesodPersist master
, YesodPersistBackend master ~ backend , YesodPersistBackend master ~ backend
, PersistStoreRead backend , PersistStoreRead backend
, YesodAuthPersist master , YesodAuthPersist master
@ -262,15 +249,14 @@ requireUnverifiedAuth
, PersistRecordBackend record backend , PersistRecordBackend record backend
, Typeable record , Typeable record
) )
-- => m (Entity record) => m (Entity record)
=> HandlerT master IO (Entity record)
requireUnverifiedAuth = requireUnverifiedAuth =
maybeAuthAllowUnverified >>= maybe handleAuthLack handleVerified maybeAuthAllowUnverified >>= maybe handleAuthLack handleVerified
requireAuthIdAllowUnverified requireAuthIdAllowUnverified
:: ( -- MonadHandler m :: ( MonadHandler m
-- , HandlerSite m ~ master , HandlerSite m ~ master
YesodPersist master , YesodPersist master
, YesodPersistBackend master ~ backend , YesodPersistBackend master ~ backend
, PersistStoreRead backend , PersistStoreRead backend
, YesodAuth master , YesodAuth master
@ -278,15 +264,14 @@ requireAuthIdAllowUnverified
, PersistRecordBackend record backend , PersistRecordBackend record backend
, Typeable record , Typeable record
) )
-- => m (Key record, Bool) => m (Key record, Bool)
=> HandlerT master IO (Key record, Bool)
requireAuthIdAllowUnverified = requireAuthIdAllowUnverified =
maybeAuthIdAllowUnverified >>= maybe handleAuthLack return maybeAuthIdAllowUnverified >>= maybe handleAuthLack return
requireAuthAllowUnverified requireAuthAllowUnverified
:: ( -- MonadHandler m :: ( MonadHandler m
-- , HandlerSite m ~ master , HandlerSite m ~ master
YesodPersist master , YesodPersist master
, YesodPersistBackend master ~ backend , YesodPersistBackend master ~ backend
, PersistStoreRead backend , PersistStoreRead backend
, YesodAuthPersist master , YesodAuthPersist master
@ -295,15 +280,14 @@ requireAuthAllowUnverified
, PersistRecordBackend record backend , PersistRecordBackend record backend
, Typeable record , Typeable record
) )
-- => m (Entity record, Bool) => m (Entity record, Bool)
=> HandlerT master IO (Entity record, Bool)
requireAuthAllowUnverified = requireAuthAllowUnverified =
maybeAuthAllowUnverified >>= maybe handleAuthLack return maybeAuthAllowUnverified >>= maybe handleAuthLack return
requireVerifiedAuthId requireVerifiedAuthId
:: ( -- MonadHandler m :: ( MonadHandler m
-- , HandlerSite m ~ master , HandlerSite m ~ master
YesodPersist master , YesodPersist master
, YesodPersistBackend master ~ backend , YesodPersistBackend master ~ backend
, PersistStoreRead backend , PersistStoreRead backend
, YesodAuthVerify master , YesodAuthVerify master
@ -311,15 +295,14 @@ requireVerifiedAuthId
, PersistRecordBackend record backend , PersistRecordBackend record backend
, Typeable record , Typeable record
) )
-- => m (Key record) => m (Key record)
=> HandlerT master IO (Key record)
requireVerifiedAuthId = requireVerifiedAuthId =
maybeAuthIdAllowUnverified >>= maybe handleAuthLack handleUnverified maybeAuthIdAllowUnverified >>= maybe handleAuthLack handleUnverified
requireVerifiedAuth requireVerifiedAuth
:: ( -- MonadHandler m :: ( MonadHandler m
-- , HandlerSite m ~ master , HandlerSite m ~ master
YesodPersist master , YesodPersist master
, YesodPersistBackend master ~ backend , YesodPersistBackend master ~ backend
, PersistStoreRead backend , PersistStoreRead backend
, YesodAuthPersist master , YesodAuthPersist master
@ -329,7 +312,6 @@ requireVerifiedAuth
, PersistRecordBackend record backend , PersistRecordBackend record backend
, Typeable record , Typeable record
) )
-- => m (Entity record) => m (Entity record)
=> HandlerT master IO (Entity record)
requireVerifiedAuth = requireVerifiedAuth =
maybeAuthAllowUnverified >>= maybe handleAuthLack handleUnverified maybeAuthAllowUnverified >>= maybe handleAuthLack handleUnverified

View file

@ -113,7 +113,6 @@ import Yesod.Auth.Unverified.Internal
credsKey = unverifiedLoginKey credsKey = unverifiedLoginKey
{-
loginErrorMessageI loginErrorMessageI
:: Route Auth :: Route Auth
-> AuthMessage -> AuthMessage
@ -121,16 +120,7 @@ loginErrorMessageI
loginErrorMessageI dest msg = do loginErrorMessageI dest msg = do
toParent <- getRouteToParent toParent <- getRouteToParent
loginErrorMessageMasterI (toParent dest) msg loginErrorMessageMasterI (toParent dest) msg
-}
loginErrorMessageI :: (MonadResourceBase m, YesodAuth master)
=> Route child
-> AuthMessage
-> HandlerT child (HandlerT master m) TypedContent
loginErrorMessageI dest msg = do
toParent <- getRouteToParent
lift $ loginErrorMessageMasterI (toParent dest) msg
{-
loginErrorMessageMasterI loginErrorMessageMasterI
:: (MonadHandler m, HandlerSite m ~ master, YesodAuth master) :: (MonadHandler m, HandlerSite m ~ master, YesodAuth master)
=> Route master => Route master
@ -139,14 +129,6 @@ loginErrorMessageMasterI
loginErrorMessageMasterI dest msg = do loginErrorMessageMasterI dest msg = do
mr <- getMessageRender mr <- getMessageRender
loginErrorMessage dest (mr msg) loginErrorMessage dest (mr msg)
-}
loginErrorMessageMasterI :: (YesodAuth master, MonadResourceBase m, RenderMessage master AuthMessage)
=> Route master
-> AuthMessage
-> HandlerT master m TypedContent
loginErrorMessageMasterI dest msg = do
mr <- getMessageRender
loginErrorMessage dest (mr msg)
{- {-
-- | For HTML, set the message and redirect to the route. -- | For HTML, set the message and redirect to the route.
@ -189,15 +171,10 @@ provideJsonMessage :: Monad m => Text -> Writer.Writer (Endo [ProvidedRep m]) ()
provideJsonMessage msg = provideRep $ return $ object ["message" .= msg] provideJsonMessage msg = provideRep $ return $ object ["message" .= msg]
-} -}
{-
setUnverifiedCredsRedirect setUnverifiedCredsRedirect
:: (MonadHandler m, YesodAuth (HandlerSite m)) :: (MonadHandler m, YesodAuthVerify (HandlerSite m))
=> Creds (HandlerSite m) -- ^ new credentials => Creds (HandlerSite m) -- ^ new credentials
-> m TypedContent -> m TypedContent
-}
setUnverifiedCredsRedirect :: YesodAuthVerify master
=> Creds master -- ^ new credentials
-> HandlerT master IO TypedContent
setUnverifiedCredsRedirect creds = do setUnverifiedCredsRedirect creds = do
y <- getYesod y <- getYesod
auth <- authenticate creds auth <- authenticate creds
@ -236,16 +213,10 @@ setUnverifiedCredsRedirect creds = do
return $ renderAuthMessage master langs msg return $ renderAuthMessage master langs msg
-- | Sets user credentials for the session after checking them with authentication backends. -- | Sets user credentials for the session after checking them with authentication backends.
{- setUnverifiedCreds :: (MonadHandler m, YesodAuthVerify (HandlerSite m))
setUnverifiedCreds :: (MonadHandler m, YesodAuth (HandlerSite m))
=> Bool -- ^ if HTTP redirects should be done => Bool -- ^ if HTTP redirects should be done
-> Creds (HandlerSite m) -- ^ new credentials -> Creds (HandlerSite m) -- ^ new credentials
-> m () -> m ()
-}
setUnverifiedCreds :: YesodAuthVerify master
=> Bool -- ^ if HTTP redirects should be done
-> Creds master -- ^ new credentials
-> HandlerT master IO ()
setUnverifiedCreds doRedirects creds = setUnverifiedCreds doRedirects creds =
if doRedirects if doRedirects
then void $ setUnverifiedCredsRedirect creds then void $ setUnverifiedCredsRedirect creds
@ -269,14 +240,9 @@ authLayoutJson w json = selectRep $ do
-- | Clears current user credentials for the session. -- | Clears current user credentials for the session.
-- --
-- @since 1.1.7 -- @since 1.1.7
{-
clearUnverifiedCreds :: (MonadHandler m, YesodAuth (HandlerSite m)) clearUnverifiedCreds :: (MonadHandler m, YesodAuth (HandlerSite m))
=> Bool -- ^ if HTTP redirect to 'logoutDest' should be done => Bool -- ^ if HTTP redirect to 'logoutDest' should be done
-> m () -> m ()
-}
clearUnverifiedCreds :: YesodAuth master
=> Bool -- ^ if HTTP redirect to 'logoutDest' should be done
-> HandlerT master IO ()
clearUnverifiedCreds doRedirects = do clearUnverifiedCreds doRedirects = do
y <- getYesod y <- getYesod
-- onLogout -- onLogout

View file

@ -26,8 +26,7 @@ import Prelude
import Data.Text (Text) import Data.Text (Text)
import Yesod.Auth (YesodAuth (..)) import Yesod.Auth (YesodAuth (..))
import Yesod.Core (Route) import Yesod.Core (MonadHandler (..), Route)
import Yesod.Core.Handler (HandlerT)
class YesodAuth site => YesodAuthVerify site where class YesodAuth site => YesodAuthVerify site where
@ -43,8 +42,7 @@ class YesodAuth site => YesodAuthVerify site where
unverifiedLoginDest = verificationRoute unverifiedLoginDest = verificationRoute
-- | Called on a successful unverified login. Default: 'onLogin' -- | Called on a successful unverified login. Default: 'onLogin'
--onUnverifiedLogin :: (MonadHandler m, site ~ HandlerSite m) => m () onUnverifiedLogin :: (MonadHandler m, site ~ HandlerSite m) => m ()
onUnverifiedLogin :: HandlerT site IO ()
onUnverifiedLogin = onLogin onUnverifiedLogin = onLogin
-- | Session key used to hold the ID of the unverified logged-in user -- | Session key used to hold the ID of the unverified logged-in user

View file

@ -75,7 +75,7 @@ cachedRecord wrap unwrap
= fmap unwrap = fmap unwrap
. cached . cached
. fmap wrap . fmap wrap
. liftHandlerT . liftHandler
. runDB . runDB
. get . get

View file

@ -3,10 +3,14 @@
# Specifies the GHC version and set of packages available (e.g., lts-3.5, # Specifies the GHC version and set of packages available (e.g., lts-3.5,
# nightly-2015-09-21, ghc-7.10.2) # nightly-2015-09-21, ghc-7.10.2)
resolver: lts-10.10 resolver: lts-12.20
# Local packages, usually specified by relative directory name # Local packages, usually specified by relative directory name
packages: packages:
- location:
git: https://github.com/bitemyapp/esqueleto.git
commit: 434f81ed41795e3dd0754dbc5c75c4ed098631b3
extra-dep: true
- . - .
- lib/darcs-lights - lib/darcs-lights
- lib/darcs-rev - lib/darcs-rev
@ -20,23 +24,26 @@ packages:
# - lib/yesod-auth-account # - lib/yesod-auth-account
- location: - location:
git: https://dev.angeley.es/s/fr33domlover/r/yesod-auth-account git: https://dev.angeley.es/s/fr33domlover/r/yesod-auth-account
commit: cc9d6a5d4e0d5fb3b061a5a9ccc0ab03eea89811 commit: c14795264c3d63b2126e91e98107a631405cea74
extra-dep: true extra-dep: true
- lib/yesod-mail-send - lib/yesod-mail-send
# Packages to be pulled from upstream that are not in the resolver (e.g., # Packages to be pulled from upstream that are not in the resolver (e.g.,
# acme-missiles-0.3) # acme-missiles-0.3)
extra-deps: extra-deps:
- darcs-2.14.0 - SimpleAES-0.4.2
- data-default-instances-bytestring-0.0.1 - data-default-instances-bytestring-0.0.1
- git-0.2.2
- highlighter2-0.2.5 - highlighter2-0.2.5
- libravatar-0.4.0.2 - libravatar-0.4.0.2
- monad-hash-0.1.0.2 - monad-hash-0.1.0.2
- monadcryptorandom-0.7.2.1
- patience-0.1.1
- persistent-parser-0.1.0.2 - persistent-parser-0.1.0.2
- SimpleAES-0.4.2 - pwstore-fast-2.4.4
- RSA-2.2.0
- time-interval-0.1.1 - time-interval-0.1.1
- time-units-1.0.0 - time-units-1.0.0
- url-2.1.3
# Override default flag values for local packages and extra-deps # Override default flag values for local packages and extra-deps
flags: flags:

View file

@ -125,7 +125,6 @@ library
Vervis.Formatting Vervis.Formatting
Vervis.Foundation Vervis.Foundation
Vervis.Git Vervis.Git
Vervis.GitOld
Vervis.GraphProxy Vervis.GraphProxy
Vervis.Handler.Common Vervis.Handler.Common
Vervis.Handler.Discussion Vervis.Handler.Discussion
@ -256,13 +255,13 @@ library
, hashable , hashable
-- for source file highlighting -- for source file highlighting
, highlighter2 , highlighter2
, hit , git
, hit-graph >= 0.1 , hit-graph
, hit-harder >= 0.1 , hit-harder
, hit-network >= 0.1 , hit-network
-- currently discarding all JS so no need for minifier -- currently discarding all JS so no need for minifier
--, hjsmin --, hjsmin
-- 'hit' uses it for 'GitTime' -- 'git' uses it for 'GitTime'
, hourglass , hourglass
, http-conduit , http-conduit
, http-types , http-types