{- |
   The functions in this module are trivial wrappers around the functions
   in "Hakyll.FileStore.Context":

   @gitSomething@ is equivalent to @fsSomething gitStore@, where
   @gitStore = gitFileStore "."@.
-}

--------------------------------------------------------------------------------

module Hakyll.FileStore.Git.Context
    ( gitStore
    , gitGetItemUTC
    , gitGetItemUTC'
    , gitDateField
    , gitDateFieldWith
    , gitGetItemModificationTime
    , gitGetItemModificationTime'
    , gitModificationTimeField
    , gitModificationTimeFieldWith
    , gitGetRevisions
    , gitGetAuthors
    , gitGetAuthorNames
    , gitAuthorNamesField
    , gitAuthorNamesFieldWith
    , gitGetAuthorEmails
    , gitAuthorEmailsField
    , gitAuthorEmailsFieldWith
    ) where

--------------------------------------------------------------------------------

import           Data.Time.Clock             (UTCTime)
import           Data.FileStore              (Author,
                                              FileStore,
                                              Revision,
                                              gitFileStore)
import           Data.Time.Locale.Compat     (TimeLocale)
import           Hakyll.Core.Compiler        (Compiler)
import           Hakyll.Core.Identifier      (Identifier)
import           Hakyll.Web.Template.Context (Context)

--------------------------------------------------------------------------------

import           Hakyll.FileStore.Context -- evil!

--------------------------------------------------------------------------------

gitStore :: FileStore
gitStore :: FileStore
gitStore = FilePath -> FileStore
gitFileStore FilePath
"."
-- ^ @gitStore = gitFileStore "."@

--------------------------------------------------------------------------------

gitGetItemUTC :: TimeLocale
              -> Identifier
              -> Compiler UTCTime
gitGetItemUTC :: TimeLocale -> Identifier -> Compiler UTCTime
gitGetItemUTC = FileStore -> TimeLocale -> Identifier -> Compiler UTCTime
fsGetItemUTC FileStore
gitStore

gitGetItemUTC' :: Identifier
               -> Compiler (Maybe UTCTime)
gitGetItemUTC' :: Identifier -> Compiler (Maybe UTCTime)
gitGetItemUTC' = FileStore -> Identifier -> Compiler (Maybe UTCTime)
fsGetItemUTC' FileStore
gitStore

gitDateField :: String
             -> String
             -> Context a
gitDateField :: FilePath -> FilePath -> Context a
gitDateField = FileStore -> FilePath -> FilePath -> Context a
forall a. FileStore -> FilePath -> FilePath -> Context a
fsDateField FileStore
gitStore

gitDateFieldWith :: TimeLocale
                 -> String
                 -> String
                 -> Context a
gitDateFieldWith :: TimeLocale -> FilePath -> FilePath -> Context a
gitDateFieldWith = FileStore -> TimeLocale -> FilePath -> FilePath -> Context a
forall a.
FileStore -> TimeLocale -> FilePath -> FilePath -> Context a
fsDateFieldWith FileStore
gitStore

gitGetItemModificationTime :: Identifier
                           -> Compiler UTCTime
gitGetItemModificationTime :: Identifier -> Compiler UTCTime
gitGetItemModificationTime = FileStore -> Identifier -> Compiler UTCTime
fsGetItemModificationTime FileStore
gitStore

gitGetItemModificationTime' :: Identifier
                            -> Compiler (Maybe UTCTime)
gitGetItemModificationTime' :: Identifier -> Compiler (Maybe UTCTime)
gitGetItemModificationTime' = FileStore -> Identifier -> Compiler (Maybe UTCTime)
fsGetItemModificationTime' FileStore
gitStore

gitModificationTimeField :: String
                         -> String
                         -> Context a
gitModificationTimeField :: FilePath -> FilePath -> Context a
gitModificationTimeField = FileStore -> FilePath -> FilePath -> Context a
forall a. FileStore -> FilePath -> FilePath -> Context a
fsModificationTimeField FileStore
gitStore

gitModificationTimeFieldWith :: TimeLocale
                             -> String
                             -> String
                             -> Context a
gitModificationTimeFieldWith :: TimeLocale -> FilePath -> FilePath -> Context a
gitModificationTimeFieldWith = FileStore -> TimeLocale -> FilePath -> FilePath -> Context a
forall a.
FileStore -> TimeLocale -> FilePath -> FilePath -> Context a
fsModificationTimeFieldWith FileStore
gitStore

--------------------------------------------------------------------------------

gitGetRevisions :: Identifier
                -> Compiler [Revision]
gitGetRevisions :: Identifier -> Compiler [Revision]
gitGetRevisions = FileStore -> Identifier -> Compiler [Revision]
fsGetRevisions FileStore
gitStore

gitGetAuthors :: Identifier
              -> Compiler [Author]
gitGetAuthors :: Identifier -> Compiler [Author]
gitGetAuthors = FileStore -> Identifier -> Compiler [Author]
fsGetAuthors FileStore
gitStore

gitGetAuthorNames :: Identifier
                  -> Compiler [String]
gitGetAuthorNames :: Identifier -> Compiler [FilePath]
gitGetAuthorNames = FileStore -> Identifier -> Compiler [FilePath]
fsGetAuthorNames FileStore
gitStore

gitAuthorNamesField :: String
                    -> Context a
gitAuthorNamesField :: FilePath -> Context a
gitAuthorNamesField = FileStore -> FilePath -> Context a
forall a. FileStore -> FilePath -> Context a
fsAuthorNamesField FileStore
gitStore

gitAuthorNamesFieldWith :: String
                        -> String
                        -> Context a
gitAuthorNamesFieldWith :: FilePath -> FilePath -> Context a
gitAuthorNamesFieldWith = FileStore -> FilePath -> FilePath -> Context a
forall a. FileStore -> FilePath -> FilePath -> Context a
fsAuthorNamesFieldWith FileStore
gitStore

gitGetAuthorEmails :: Identifier
                   -> Compiler [String]
gitGetAuthorEmails :: Identifier -> Compiler [FilePath]
gitGetAuthorEmails = FileStore -> Identifier -> Compiler [FilePath]
fsGetAuthorEmails FileStore
gitStore

gitAuthorEmailsField :: String
                     -> Context a
gitAuthorEmailsField :: FilePath -> Context a
gitAuthorEmailsField = FileStore -> FilePath -> Context a
forall a. FileStore -> FilePath -> Context a
fsAuthorEmailsField FileStore
gitStore

gitAuthorEmailsFieldWith :: String
                         -> String
                         -> Context a
gitAuthorEmailsFieldWith :: FilePath -> FilePath -> Context a
gitAuthorEmailsFieldWith = FileStore -> FilePath -> FilePath -> Context a
forall a. FileStore -> FilePath -> FilePath -> Context a
fsAuthorEmailsFieldWith FileStore
gitStore

--------------------------------------------------------------------------------