packages feed

hakyll-filestore (empty) → 0.1.0

raw patch · 8 files changed

+787/−0 lines, 8 filesdep +basedep +filestoredep +hakyllsetup-changed

Dependencies added: base, filestore, hakyll, time, time-locale-compat

Files

+ LICENSE view
@@ -0,0 +1,133 @@+hakyll-filestore - FileStore utilities for Hakyll++---++Written in 2016 by Aras Ergus <arasergus@posteo.net>++---++To the extent possible under law, the author(s) have dedicated all copyright+and related and neighboring rights to this software to the public domain+worldwide by associating CC0 with it. This software is distributed without+any warranty.++---++CC0 1.0 Universal++Statement of Purpose++The laws of most jurisdictions throughout the world automatically confer+exclusive Copyright and Related Rights (defined below) upon the creator and+subsequent owner(s) (each and all, an "owner") of an original work of+authorship and/or a database (each, a "Work").++Certain owners wish to permanently relinquish those rights to a Work for the+purpose of contributing to a commons of creative, cultural and scientific+works ("Commons") that the public can reliably and without fear of later+claims of infringement build upon, modify, incorporate in other works, reuse+and redistribute as freely as possible in any form whatsoever and for any+purposes, including without limitation commercial purposes. These owners may+contribute to the Commons to promote the ideal of a free culture and the+further production of creative, cultural and scientific works, or to gain+reputation or greater distribution for their Work in part through the use and+efforts of others.++For these and/or other purposes and motivations, and without any expectation+of additional consideration or compensation, the person associating CC0 with a+Work (the "Affirmer"), to the extent that he or she is an owner of Copyright+and Related Rights in the Work, voluntarily elects to apply CC0 to the Work+and publicly distribute the Work under its terms, with knowledge of his or her+Copyright and Related Rights in the Work and the meaning and intended legal+effect of CC0 on those rights.++1. Copyright and Related Rights. A Work made available under CC0 may be+protected by copyright and related or neighboring rights ("Copyright and+Related Rights"). Copyright and Related Rights include, but are not limited+to, the following:++  i. the right to reproduce, adapt, distribute, perform, display, communicate,+  and translate a Work;++  ii. moral rights retained by the original author(s) and/or performer(s);++  iii. publicity and privacy rights pertaining to a person's image or likeness+  depicted in a Work;++  iv. rights protecting against unfair competition in regards to a Work,+  subject to the limitations in paragraph 4(a), below;++  v. rights protecting the extraction, dissemination, use and reuse of data in+  a Work;++  vi. database rights (such as those arising under Directive 96/9/EC of the+  European Parliament and of the Council of 11 March 1996 on the legal+  protection of databases, and under any national implementation thereof,+  including any amended or successor version of such directive); and++  vii. other similar, equivalent or corresponding rights throughout the world+  based on applicable law or treaty, and any national implementations thereof.++2. Waiver. To the greatest extent permitted by, but not in contravention of,+applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and+unconditionally waives, abandons, and surrenders all of Affirmer's Copyright+and Related Rights and associated claims and causes of action, whether now+known or unknown (including existing as well as future claims and causes of+action), in the Work (i) in all territories worldwide, (ii) for the maximum+duration provided by applicable law or treaty (including future time+extensions), (iii) in any current or future medium and for any number of+copies, and (iv) for any purpose whatsoever, including without limitation+commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes+the Waiver for the benefit of each member of the public at large and to the+detriment of Affirmer's heirs and successors, fully intending that such Waiver+shall not be subject to revocation, rescission, cancellation, termination, or+any other legal or equitable action to disrupt the quiet enjoyment of the Work+by the public as contemplated by Affirmer's express Statement of Purpose.++3. Public License Fallback. Should any part of the Waiver for any reason be+judged legally invalid or ineffective under applicable law, then the Waiver+shall be preserved to the maximum extent permitted taking into account+Affirmer's express Statement of Purpose. In addition, to the extent the Waiver+is so judged Affirmer hereby grants to each affected person a royalty-free,+non transferable, non sublicensable, non exclusive, irrevocable and+unconditional license to exercise Affirmer's Copyright and Related Rights in+the Work (i) in all territories worldwide, (ii) for the maximum duration+provided by applicable law or treaty (including future time extensions), (iii)+in any current or future medium and for any number of copies, and (iv) for any+purpose whatsoever, including without limitation commercial, advertising or+promotional purposes (the "License"). The License shall be deemed effective as+of the date CC0 was applied by Affirmer to the Work. Should any part of the+License for any reason be judged legally invalid or ineffective under+applicable law, such partial invalidity or ineffectiveness shall not+invalidate the remainder of the License, and in such case Affirmer hereby+affirms that he or she will not (i) exercise any of his or her remaining+Copyright and Related Rights in the Work or (ii) assert any associated claims+and causes of action with respect to the Work, in either case contrary to+Affirmer's express Statement of Purpose.++4. Limitations and Disclaimers.++  a. No trademark or patent rights held by Affirmer are waived, abandoned,+  surrendered, licensed or otherwise affected by this document.++  b. Affirmer offers the Work as-is and makes no representations or warranties+  of any kind concerning the Work, express, implied, statutory or otherwise,+  including without limitation warranties of title, merchantability, fitness+  for a particular purpose, non infringement, or the absence of latent or+  other defects, accuracy, or the present or absence of errors, whether or not+  discoverable, all to the greatest extent permissible under applicable law.++  c. Affirmer disclaims responsibility for clearing rights of other persons+  that may apply to the Work or any use thereof, including without limitation+  any person's Copyright and Related Rights in the Work. Further, Affirmer+  disclaims responsibility for obtaining any necessary consents, permissions+  or other rights required for any use of the Work.++  d. Affirmer understands and acknowledges that Creative Commons is not a+  party to this document and has no duty or obligation with respect to this+  CC0 or use of the Work.++---++For more information, please see+<http://creativecommons.org/publicdomain/zero/1.0/>
+ README.md view
@@ -0,0 +1,12 @@+# hakyll-filestore++[FileStore][filestore] utilities for [Hakyll][hakyll].++It can (in particular) be used for extracting date and author information for+`Item`s from a [darcs][darcs], [git][git] or [mercurial][mercurial] repository.++[filestore]:  https://hackage.haskell.org/package/filestore+[hakyll]: https://hackage.haskell.org/package/hakyll+[darcs]: http://darcs.net/+[git]: https://git-scm.com/+[mercurial]: https://www.mercurial-scm.org/
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ hakyll-filestore.cabal view
@@ -0,0 +1,32 @@+Name:                hakyll-filestore+Version:             0.1.0+Synopsis:            FileStore utilities for Hakyll+Description:         These utilities can (in particular) be used for extracting+                     date and author information for items from a darcs, git or+                     mercurial repository.+Homepage:            https://gitlab.com/aergus/hakyll-filestore+License:             PublicDomain+License-file:        LICENSE+Author:              Aras Ergus+Maintainer:          arasergus@posteo.net+Category:            Web+Build-Type:          Simple+Extra-Source-Files:  README.md+Cabal-Version:       >=1.10+++Library+  HS-Source-Dirs:    src+  GHC-Options:       -O3 -Wall+  Default-Language:  Haskell2010+  Exposed-Modules:+      Hakyll.FileStore.Context+    , Hakyll.FileStore.Mercurial.Context+    , Hakyll.FileStore.Git.Context+    , Hakyll.FileStore.Darcs.Context+  Build-Depends:+      base >=4.8 && <4.9+    , time >=1.5 && <1.6+    , filestore >=0.6 && <0.7+    , time-locale-compat >=0.1 && <0.2+    , hakyll >=4.7 && <4.8
+ src/Hakyll/FileStore/Context.hs view
@@ -0,0 +1,218 @@+module Hakyll.FileStore.Context+    ( fsGetItemUTC+    , fsGetItemUTC'+    , fsDateField+    , fsDateFieldWith+    , fsGetItemModificationTime+    , fsGetItemModificationTime'+    , fsModificationTimeField+    , fsModificationTimeFieldWith+    , fsGetRevisions+    , fsGetAuthors+    , fsGetAuthorNames+    , fsAuthorNamesField+    , fsAuthorNamesFieldWith+    , fsGetAuthorEmails+    , fsAuthorEmailsField+    , fsAuthorEmailsFieldWith+    ) where+--------------------------------------------------------------------------------++import           Control.Monad               (liftM)+import           Data.Time.Clock             (UTCTime)+import           Data.FileStore              (Author,+                                              FileStore,+                                              Revision,+                                              TimeRange (TimeRange),+                                              authorEmail,+                                              authorName,+                                              history,+                                              revAuthor,+                                              revDateTime)+import           Data.List                   (intercalate, nub)+import           Data.Maybe                  (listToMaybe)+import           Data.Time.Format            (formatTime)+import           Data.Time.Locale.Compat     (TimeLocale, defaultTimeLocale)+import           Hakyll.Core.Compiler        (Compiler, unsafeCompiler)+import           Hakyll.Core.Identifier      (Identifier, toFilePath)+import           Hakyll.Core.Item            (itemIdentifier)+import           Hakyll.Web.Template.Context (Context,+                                              field,+                                              getItemModificationTime,+                                              getItemUTC)++--------------------------------------------------------------------------------++fsGetWithFallback :: Monad m+                  => (FileStore -> Identifier -> m (Maybe a))+                  -> (Identifier -> m a)+                  -> FileStore+                  -> Identifier+                  -> m a+fsGetWithFallback fsF f fs i = do+    maybeIt <- fsF fs i+    maybe (f i) return maybeIt++extractFromRevisions :: ([Revision] -> a)+                     -> FileStore+                     -> Identifier+                     -> Compiler a+extractFromRevisions f fs i = unsafeCompiler $ do+    let path = toFilePath i+    revisions <- history fs [path] (TimeRange Nothing Nothing) Nothing+    return $ f revisions++generateFsField :: (FileStore -> Identifier -> Compiler String)+                -> FileStore+                -> String+                -> Context a+generateFsField fsF fs key =+    field key (fsF fs . itemIdentifier)++fsIntercalateToContext :: (FileStore -> Identifier -> Compiler [String])+                       -> FileStore+                       -> String+                       -> String+                       -> Context a+fsIntercalateToContext fsF fs delimeter =+    generateFsField (\ fs' -> liftM (intercalate delimeter) . fsF fs') fs++generateFsTimeFieldWith :: (FileStore -> Identifier -> Compiler UTCTime)+                        -> FileStore+                        -> TimeLocale+                        -> String+                        -> String+                        -> Context a+generateFsTimeFieldWith fsF fs locale key fmt = field key $ \ i -> do+    time <- fsF fs $ itemIdentifier i+    return $ formatTime locale fmt time++--------------------------------------------------------------------------------++fsGetItemUTC :: FileStore        -- ^ 'FileStore' to work in+             -> TimeLocale       -- ^ Output time locale+             -> Identifier       -- ^ Input page+             -> Compiler UTCTime -- ^ Returns the time of the first revision if+                                 -- revisions are available, date of the+                                 -- identifier otherwise+fsGetItemUTC fs locale =+    fsGetWithFallback fsGetItemUTC' (getItemUTC locale) fs++fsGetItemUTC' :: FileStore                -- ^ 'FileStore' to work  in+              -> Identifier               -- ^ Input page+              -> Compiler (Maybe UTCTime) -- ^ Returns 'Just' the time of the+                                          -- first revision if the file has+                                          -- some revisions, 'Nothing'+                                          -- otherwise+fsGetItemUTC' =+    extractFromRevisions (listToMaybe . map revDateTime . reverse)++fsDateField :: FileStore -- ^ 'FileStore' to work in+            -> String    -- ^ Destination key+            -> String    -- ^ Format to use on the date+            -> Context a -- ^ Resulting context+fsDateField fs = fsDateFieldWith fs defaultTimeLocale++fsDateFieldWith :: FileStore  -- ^ 'FileStore' to work in+                -> TimeLocale -- ^ Output time locale+                -> String     -- ^ Destination key+                -> String     -- ^ Format to use on the date+                -> Context a  -- ^ Resulting context+fsDateFieldWith fs locale =+    generateFsTimeFieldWith (`fsGetItemUTC` locale) fs locale++fsGetItemModificationTime :: FileStore        -- ^ 'FileStore' to work in+                          -> Identifier       -- ^ Input page+                          -> Compiler UTCTime -- ^ Returns the time of the last+                                              -- revision if revisions are+                                              -- available, modification time+                                              -- of the file otherwise.+fsGetItemModificationTime =+    fsGetWithFallback fsGetItemModificationTime' getItemModificationTime++fsGetItemModificationTime' :: FileStore                -- ^ 'FileStore' to+                                                       -- work in+                           -> Identifier               -- ^ Identifier in+                                                       -- question+                           -> Compiler (Maybe UTCTime) -- ^ Returns 'Just' the+                                                       -- time of last revision+                                                       -- if the file has some+                                                       -- revisions, 'Nothing'+                                                       -- otherwise.+fsGetItemModificationTime' =+    extractFromRevisions (listToMaybe . map revDateTime)++fsModificationTimeField :: FileStore -- ^ 'FileStore' to work in+                        -> String    -- ^ Destination key+                        -> String    -- ^ Format to use on the date+                        -> Context a -- ^ Resulting context+fsModificationTimeField fs = fsModificationTimeFieldWith fs defaultTimeLocale++fsModificationTimeFieldWith :: FileStore  -- ^ 'FileStore' to work in+                            -> TimeLocale -- ^ Output time locale+                            -> String     -- ^ Destination key+                            -> String     -- ^ Format to use on the date+                            -> Context a  -- ^ Resulting context+fsModificationTimeFieldWith = generateFsTimeFieldWith fsGetItemModificationTime++--------------------------------------------------------------------------------++-- TODO: Add "getters" for other fields of "Revision"?++fsGetRevisions :: FileStore           -- ^ 'FileStore' to work  in+               -> Identifier          -- ^ Input Page+               -> Compiler [Revision] -- ^ Returns the revisions of the page+                                      -- in reverse chronological order+fsGetRevisions = extractFromRevisions id++fsGetAuthors :: FileStore         -- ^ 'FileStore' to work  in+             -> Identifier        -- ^ Input Page+             -> Compiler [Author] -- ^ Returns the authors of the page in+                                  -- chronological order of occurence in the+                                  -- revisions+fsGetAuthors fs i = (nub . map revAuthor . reverse) <$> fsGetRevisions fs i++fsGetAuthorNames :: FileStore         -- ^ 'FileStore' to work  in+                 -> Identifier        -- ^ Input Page+                 -> Compiler [String] -- ^ Returns the names of the authors of+                                      -- the page in chronological order of+                                      -- occurence in the revisions+fsGetAuthorNames fs i = map authorName <$> fsGetAuthors fs i++fsAuthorNamesField :: FileStore -- ^ 'FileStore' to work  in+                   -> String    -- ^ Destination key+                   -> Context a -- ^ Resulting context+fsAuthorNamesField = flip fsAuthorNamesFieldWith ","+-- ^ @fsAuthorNamesField = flip fsAuthorNamesFieldWith ","@++fsAuthorNamesFieldWith :: FileStore -- ^ 'FileStore' to work  in+                       -> String    -- ^ Intercalation delimeter+                       -> String    -- ^ Destination key+                       -> Context a -- ^ Resulting context+fsAuthorNamesFieldWith = fsIntercalateToContext fsGetAuthorNames+-- ^ Field consisting of the names of the authors separated by the+-- given delimeter.++fsGetAuthorEmails :: FileStore         -- ^ 'FileStore' to work  in+                  -> Identifier        -- ^ Input Page+                  -> Compiler [String] -- ^ Returns the email addresses of the+                                       -- authors of the page in chronological+                                       -- chronological order of occurence+                                       -- in the revisions+fsGetAuthorEmails fs i = map authorEmail <$> fsGetAuthors fs i++fsAuthorEmailsField :: FileStore -- ^ 'FileStore' to work  in+                    -> String    -- ^ Destination key+                    -> Context a -- ^ Resulting context+fsAuthorEmailsField = flip fsAuthorEmailsFieldWith ","+-- ^ @fsAuthorEmailsField = flip fsAuthorEmailsFieldWith ","@++fsAuthorEmailsFieldWith :: FileStore -- ^ 'FileStore' to work  in+                       -> String    -- ^ Intercalation delimeter+                       -> String    -- ^ Destination key+                       -> Context a -- ^ Resulting context+fsAuthorEmailsFieldWith = fsIntercalateToContext fsGetAuthorEmails+-- ^ Field consisting of the email addresses of the authors separated+-- by the given delimeter.++--------------------------------------------------------------------------------
+ src/Hakyll/FileStore/Darcs/Context.hs view
@@ -0,0 +1,130 @@+{- |+   The functions in this module are trivial wrappers around the functions+   in "Hakyll.FileStore.Context":++   @darcsSomething@ is equivalent to @fsSomething darcsStore@, where+   @darcsStore = darcsFileStore "."@.+-}++--------------------------------------------------------------------------------++module Hakyll.FileStore.Darcs.Context+    ( darcsStore+    , darcsGetItemUTC+    , darcsGetItemUTC'+    , darcsDateField+    , darcsDateFieldWith+    , darcsGetItemModificationTime+    , darcsGetItemModificationTime'+    , darcsModificationTimeField+    , darcsModificationTimeFieldWith+    , darcsGetRevisions+    , darcsGetAuthors+    , darcsGetAuthorNames+    , darcsAuthorNamesField+    , darcsAuthorNamesFieldWith+    , darcsGetAuthorEmails+    , darcsAuthorEmailsField+    , darcsAuthorEmailsFieldWith+    ) where++--------------------------------------------------------------------------------++import           Data.Time.Clock             (UTCTime)+import           Data.FileStore              (Author,+                                              FileStore,+                                              Revision,+                                              darcsFileStore)+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!++--------------------------------------------------------------------------------++darcsStore :: FileStore+darcsStore = darcsFileStore "."+-- ^ @darcsStore = darcsFileStore "."@++--------------------------------------------------------------------------------++darcsGetItemUTC :: TimeLocale+               -> Identifier+               -> Compiler UTCTime+darcsGetItemUTC = fsGetItemUTC darcsStore++darcsGetItemUTC' :: Identifier+                -> Compiler (Maybe UTCTime)+darcsGetItemUTC' = fsGetItemUTC' darcsStore++darcsDateField :: String+              -> String+              -> Context a+darcsDateField = fsDateField darcsStore++darcsDateFieldWith :: TimeLocale+                  -> String+                  -> String+                  -> Context a+darcsDateFieldWith = fsDateFieldWith darcsStore++darcsGetItemModificationTime :: Identifier+                            -> Compiler UTCTime+darcsGetItemModificationTime = fsGetItemModificationTime darcsStore++darcsGetItemModificationTime' :: Identifier+                             -> Compiler (Maybe UTCTime)+darcsGetItemModificationTime' = fsGetItemModificationTime' darcsStore++darcsModificationTimeField :: String+                          -> String+                          -> Context a+darcsModificationTimeField = fsModificationTimeField darcsStore++darcsModificationTimeFieldWith :: TimeLocale+                              -> String+                              -> String+                              -> Context a+darcsModificationTimeFieldWith = fsModificationTimeFieldWith darcsStore++--------------------------------------------------------------------------------++darcsGetRevisions :: Identifier+                 -> Compiler [Revision]+darcsGetRevisions = fsGetRevisions darcsStore++darcsGetAuthors :: Identifier+               -> Compiler [Author]+darcsGetAuthors = fsGetAuthors darcsStore++darcsGetAuthorNames :: Identifier+                   -> Compiler [String]+darcsGetAuthorNames = fsGetAuthorNames darcsStore++darcsAuthorNamesField :: String+                     -> Context a+darcsAuthorNamesField = fsAuthorNamesField darcsStore++darcsAuthorNamesFieldWith :: String+                         -> String+                         -> Context a+darcsAuthorNamesFieldWith = fsAuthorNamesFieldWith darcsStore++darcsGetAuthorEmails :: Identifier+                    -> Compiler [String]+darcsGetAuthorEmails = fsGetAuthorEmails darcsStore++darcsAuthorEmailsField :: String+                      -> Context a+darcsAuthorEmailsField = fsAuthorEmailsField darcsStore++darcsAuthorEmailsFieldWith :: String+                          -> String+                          -> Context a+darcsAuthorEmailsFieldWith = fsAuthorEmailsFieldWith darcsStore++--------------------------------------------------------------------------------
+ src/Hakyll/FileStore/Git/Context.hs view
@@ -0,0 +1,130 @@+{- |+   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 = gitFileStore "."+-- ^ @gitStore = gitFileStore "."@++--------------------------------------------------------------------------------++gitGetItemUTC :: TimeLocale+              -> Identifier+              -> Compiler UTCTime+gitGetItemUTC = fsGetItemUTC gitStore++gitGetItemUTC' :: Identifier+               -> Compiler (Maybe UTCTime)+gitGetItemUTC' = fsGetItemUTC' gitStore++gitDateField :: String+             -> String+             -> Context a+gitDateField = fsDateField gitStore++gitDateFieldWith :: TimeLocale+                 -> String+                 -> String+                 -> Context a+gitDateFieldWith = fsDateFieldWith gitStore++gitGetItemModificationTime :: Identifier+                           -> Compiler UTCTime+gitGetItemModificationTime = fsGetItemModificationTime gitStore++gitGetItemModificationTime' :: Identifier+                            -> Compiler (Maybe UTCTime)+gitGetItemModificationTime' = fsGetItemModificationTime' gitStore++gitModificationTimeField :: String+                         -> String+                         -> Context a+gitModificationTimeField = fsModificationTimeField gitStore++gitModificationTimeFieldWith :: TimeLocale+                             -> String+                             -> String+                             -> Context a+gitModificationTimeFieldWith = fsModificationTimeFieldWith gitStore++--------------------------------------------------------------------------------++gitGetRevisions :: Identifier+                -> Compiler [Revision]+gitGetRevisions = fsGetRevisions gitStore++gitGetAuthors :: Identifier+              -> Compiler [Author]+gitGetAuthors = fsGetAuthors gitStore++gitGetAuthorNames :: Identifier+                  -> Compiler [String]+gitGetAuthorNames = fsGetAuthorNames gitStore++gitAuthorNamesField :: String+                    -> Context a+gitAuthorNamesField = fsAuthorNamesField gitStore++gitAuthorNamesFieldWith :: String+                        -> String+                        -> Context a+gitAuthorNamesFieldWith = fsAuthorNamesFieldWith gitStore++gitGetAuthorEmails :: Identifier+                   -> Compiler [String]+gitGetAuthorEmails = fsGetAuthorEmails gitStore++gitAuthorEmailsField :: String+                     -> Context a+gitAuthorEmailsField = fsAuthorEmailsField gitStore++gitAuthorEmailsFieldWith :: String+                         -> String+                         -> Context a+gitAuthorEmailsFieldWith = fsAuthorEmailsFieldWith gitStore++--------------------------------------------------------------------------------
+ src/Hakyll/FileStore/Mercurial/Context.hs view
@@ -0,0 +1,130 @@+{- |+   The functions in this module are trivial wrappers around the functions+   in "Hakyll.FileStore.Context":++   @hgSomething@ is equivalent to @fsSomething hgStore@, where+   @hgStore = mercurialFileStore "."@.+-}++--------------------------------------------------------------------------------++module Hakyll.FileStore.Mercurial.Context+    ( hgStore+    , hgGetItemUTC+    , hgGetItemUTC'+    , hgDateField+    , hgDateFieldWith+    , hgGetItemModificationTime+    , hgGetItemModificationTime'+    , hgModificationTimeField+    , hgModificationTimeFieldWith+    , hgGetRevisions+    , hgGetAuthors+    , hgGetAuthorNames+    , hgAuthorNamesField+    , hgAuthorNamesFieldWith+    , hgGetAuthorEmails+    , hgAuthorEmailsField+    , hgAuthorEmailsFieldWith+    ) where++--------------------------------------------------------------------------------++import           Data.Time.Clock             (UTCTime)+import           Data.FileStore              (Author,+                                              FileStore,+                                              Revision,+                                              mercurialFileStore)+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++--------------------------------------------------------------------------------++hgStore :: FileStore+hgStore = mercurialFileStore "."+-- ^ @hgStore = mercurialFileStore "."@++--------------------------------------------------------------------------------++hgGetItemUTC :: TimeLocale+             -> Identifier+             -> Compiler UTCTime+hgGetItemUTC = fsGetItemUTC hgStore++hgGetItemUTC' :: Identifier+              -> Compiler (Maybe UTCTime)+hgGetItemUTC' = fsGetItemUTC' hgStore++hgDateField :: String+            -> String+            -> Context a+hgDateField = fsDateField hgStore++hgDateFieldWith :: TimeLocale+                -> String+                -> String+                -> Context a+hgDateFieldWith = fsDateFieldWith hgStore++hgGetItemModificationTime :: Identifier+                          -> Compiler UTCTime+hgGetItemModificationTime = fsGetItemModificationTime hgStore++hgGetItemModificationTime' :: Identifier+                           -> Compiler (Maybe UTCTime)+hgGetItemModificationTime' = fsGetItemModificationTime' hgStore++hgModificationTimeField :: String+                        -> String+                        -> Context a+hgModificationTimeField = fsModificationTimeField hgStore++hgModificationTimeFieldWith :: TimeLocale+                            -> String+                            -> String+                            -> Context a+hgModificationTimeFieldWith = fsModificationTimeFieldWith hgStore++--------------------------------------------------------------------------------++hgGetRevisions :: Identifier+               -> Compiler [Revision]+hgGetRevisions = fsGetRevisions hgStore++hgGetAuthors :: Identifier+             -> Compiler [Author]+hgGetAuthors = fsGetAuthors hgStore++hgGetAuthorNames :: Identifier+                 -> Compiler [String]+hgGetAuthorNames = fsGetAuthorNames hgStore++hgAuthorNamesField :: String+                   -> Context a+hgAuthorNamesField = fsAuthorNamesField hgStore++hgAuthorNamesFieldWith :: String+                       -> String+                       -> Context a+hgAuthorNamesFieldWith = fsAuthorNamesFieldWith hgStore++hgGetAuthorEmails :: Identifier+                  -> Compiler [String]+hgGetAuthorEmails = fsGetAuthorEmails hgStore++hgAuthorEmailsField :: String+                    -> Context a+hgAuthorEmailsField = fsAuthorEmailsField hgStore++hgAuthorEmailsFieldWith :: String+                        -> String+                        -> Context a+hgAuthorEmailsFieldWith = fsAuthorEmailsFieldWith hgStore++--------------------------------------------------------------------------------