module DarcsWeb.Types
( PatchSummary(..)
, RepoInfo(..)
, TreeEntry(..)
, DarcsWebConfig(..)
, LogFunc
) where
import Data.Text (Text)
-- | Summary information about a single patch
data PatchSummary = PatchSummary
{ psName :: !Text
, psAuthor :: !Text
, psDate :: !Text
, psLog :: !Text
, psHash :: !Text
, psIsTag :: !Bool
, psTagName :: !(Maybe Text)
, psDiff :: !Text -- ^ Full patch diff content
, psSummary :: !Text -- ^ Short summary of changes
} deriving (Show)
-- | Information about a repository
data RepoInfo = RepoInfo
{ riName :: !Text -- ^ Display name (directory basename)
, riPath :: !FilePath -- ^ Absolute path on disk
, riDescription :: !Text -- ^ From _darcs/prefs/repo_description or empty
, riLastChange :: !Text -- ^ Date of most recent patch
, riPatchCount :: !Int
} deriving (Show)
-- | An entry in the repository file tree
data TreeEntry = TreeEntry
{ teName :: !Text -- ^ File or directory name
, teIsDir :: !Bool -- ^ True if directory
, teSize :: !Int -- ^ File size in bytes (0 for directories)
} deriving (Show)
-- | Application configuration
data DarcsWebConfig = DarcsWebConfig
{ cfgPort :: !Int
, cfgBind :: !String -- ^ IP address to bind to
, cfgRepoDir :: !FilePath -- ^ Directory containing darcs repos
, cfgTitle :: !Text
, cfgStaticDir :: !FilePath -- ^ Directory for static assets
, cfgLog :: !LogFunc -- ^ Logging function
}
-- | A logging function that takes a message string
type LogFunc = String -> IO ()
instance Show DarcsWebConfig where
show c = "DarcsWebConfig {bind=" ++ show (cfgBind c)
++ ", port=" ++ show (cfgPort c)
++ ", repos=" ++ show (cfgRepoDir c)
++ ", title=" ++ show (cfgTitle c)
++ ", static=" ++ show (cfgStaticDir c) ++ "}"