yesod-gitrev (empty) → 0.1.0.0
raw patch · 6 files changed
+172/−0 lines, 6 filesdep +aesondep +basedep +gitrevsetup-changed
Dependencies added: aeson, base, gitrev, template-haskell, yesod-core
Files
- LICENSE +24/−0
- README.md +35/−0
- Setup.hs +2/−0
- src/Yesod/GitRev.hs +38/−0
- src/Yesod/GitRev/Data.hs +43/−0
- yesod-gitrev.cabal +30/−0
+ LICENSE view
@@ -0,0 +1,24 @@+Copyright (c) 2015 FP Complete Corporation+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:+ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.+ * Redistributions in binary form must reproduce the above copyright+ notice, this list of conditions and the following disclaimer in the+ documentation and/or other materials provided with the distribution.+ * Neither the name of optparse-simple nor the+ names of its contributors may be used to endorse or promote products+ derived from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,35 @@+A subsite for displaying git information.++You can use the `gitRev` splice (or `tGitRev` typed splice)+to generate a value of type `GitRev`.+Put this in your app's foundation,+add a route to the subsite,+and you're good to go.++See [Haskell and Yesod > Creating a Subsite]+(http://www.yesodweb.com/book/creating-a-subsite)+for details on how Yesod subsites work.++```+-- examples/Main.hs++{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeFamilies #-}++import Yesod+import Yesod.GitRev++data Master = Master+ { getGitRev :: GitRev+ }++mkYesod "Master" [parseRoutes|+/build-version GitRevR GitRev getGitRev+|]++instance Yesod Master++main = warp 3000 $ Master $$(tGitRev)+```
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Yesod/GitRev.hs view
@@ -0,0 +1,38 @@+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings #-}++module Yesod.GitRev+ ( GitRev (..)+ , gitRev+ , tGitRev+ ) where++import Data.Aeson+import Yesod.Core+import Yesod.GitRev.Data++getGitRevR :: Yesod master => HandlerT GitRev (HandlerT master IO) TypedContent+getGitRevR = getYesod >>= \GitRev{..} -> lift $ selectRep $ do+ provideRep $ defaultLayout $ do+ [whamlet|+ <dl>+ <dt>Hash+ <dd>#{gitRevHash}+ <dt>Branch+ <dd>#{gitRevBranch}+ <dt>Dirty+ <dd>#{gitRevDirty}+ |]+ provideRep $ return $ object+ [ "hash" .= gitRevHash+ , "branch" .= gitRevBranch+ , "dirty" .= gitRevDirty+ ]++instance Yesod master => YesodSubDispatch GitRev (HandlerT master IO) where+ yesodSubDispatch = $(mkYesodSubDispatch resourcesGitRev)
+ src/Yesod/GitRev/Data.hs view
@@ -0,0 +1,43 @@+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE TypeFamilies #-}++module Yesod.GitRev.Data where++import Development.GitRev (gitHash, gitBranch, gitDirty)+import Language.Haskell.TH.Syntax (Lift(lift), Q, TExp, Exp, unsafeTExpCoerce)+import Yesod.Core hiding (lift)++data GitRev = GitRev+ { gitRevHash :: String+ , gitRevBranch :: String+ , gitRevDirty :: Bool+ }++mkYesodSubData "GitRev" [parseRoutes|+/ GitRevR GET+|]++instance Lift GitRev where+ lift GitRev{..} =+ [|+ GitRev+ { gitRevHash = $(lift gitRevHash)+ , gitRevBranch = $(lift gitRevBranch)+ , gitRevDirty = $(lift gitRevDirty)+ }+ |]++tGitRev :: Q (TExp GitRev)+tGitRev = unsafeTExpCoerce gitRev++gitRev :: Q Exp+gitRev =+ [|+ GitRev+ { gitRevHash = $gitHash+ , gitRevBranch = $gitBranch+ , gitRevDirty = $gitDirty+ }+ |]
+ yesod-gitrev.cabal view
@@ -0,0 +1,30 @@+name: yesod-gitrev+version: 0.1.0.0+synopsis:+ A subsite for displaying git information.+author: Dan Burton+maintainer: danburton.email@gmail.com++copyright: 2015 FP Complete Corporation+license: BSD3+license-file: LICENSE++build-type: Simple+cabal-version: >=1.10++extra-source-files:+ README.md++library+ exposed-modules:+ Yesod.GitRev+ other-modules:+ Yesod.GitRev.Data+ build-depends:+ base >=4 && <5+ , aeson+ , gitrev+ , template-haskell+ , yesod-core+ hs-source-dirs: src+ default-language: Haskell2010