41 changed files with 228 additions and 223 deletions
@ -0,0 +1,4 @@ |
|||
import Green |
|||
|
|||
main :: IO () |
|||
main = author |
@ -1,4 +0,0 @@ |
|||
import GreenSite |
|||
|
|||
main :: IO () |
|||
main = green |
@ -1,4 +1,4 @@ |
|||
import GreenSite |
|||
import Green |
|||
|
|||
main :: IO () |
|||
main = site |
|||
|
@ -1,13 +1,13 @@ |
|||
cradle: |
|||
stack: |
|||
- path: "src" |
|||
component: "green-site:lib" |
|||
component: "green:lib" |
|||
|
|||
- path: "app/green" |
|||
component: "green-site:exe:green" |
|||
- path: "app/author" |
|||
component: "green:exe:author" |
|||
|
|||
- path: "app/site" |
|||
component: "green-site:exe:site" |
|||
component: "green:exe:site" |
|||
|
|||
- path: "test" |
|||
component: "green-site:test:green-site-test" |
|||
component: "green:test:green-test" |
|||
|
@ -0,0 +1,43 @@ |
|||
module Green.Command where |
|||
|
|||
import Green.Util |
|||
import Options.Applicative |
|||
|
|||
data AuthorCommand |
|||
= CreateDraft CreateDraftOpts |
|||
| PublishPost FilePath |
|||
deriving stock (Show, Eq) |
|||
|
|||
data CreateDraftOpts = CreateDraftOpts |
|||
{ draftTitle :: String, |
|||
draftCategory :: Maybe String |
|||
} |
|||
deriving stock (Show, Eq) |
|||
|
|||
authorCommands :: String -> ParserInfo AuthorCommand |
|||
authorCommands progName = authorOptions |
|||
where |
|||
--- commands |
|||
authorOptions = info (authorOptions' <**> helper) (fullDesc <> authorDesc) |
|||
authorOptions' = subparser draftCommand <|> subparser publishCommand |
|||
authorDesc = progDesc (progName ++ " -- an admin tool for the site") |
|||
--- draft command |
|||
draftCommand = command "draft" $ info draftOptions (progDesc "Create a new draft post") |
|||
draftOptions = CreateDraft <$> draftOptions' |
|||
draftOptions' = CreateDraftOpts |
|||
<$> strOption (long "title" <> short 't') |
|||
<*> optional (strOption (long "category" <> short 'c')) |
|||
--- publish command |
|||
publishCommand = command "publish" $ info publishOptions (progDesc "Publish an existing draft") |
|||
publishOptions = PublishPost <$> strOption (long "file" <> short 'f') |
|||
|
|||
processAuthorCommand :: AuthorCommand -> IO () |
|||
processAuthorCommand (CreateDraft draftOpts) = createDraft draftOpts |
|||
processAuthorCommand (PublishPost file) = putStrLn ("Publishing " ++ file) |
|||
|
|||
createDraft :: CreateDraftOpts -> IO () |
|||
createDraft (CreateDraftOpts title maybeCategory) = |
|||
putStrLn $ "Writing post '" ++ title ++ "' to file " ++ draftFilePath |
|||
where |
|||
draftFilePath = categoryPrefix ++ kebabCase title ++ ".md" |
|||
categoryPrefix = maybe "" ((++ "/") . kebabCase) maybeCategory |
@ -1,4 +1,4 @@ |
|||
module GreenSite.Compiler where |
|||
module Green.Compiler where |
|||
|
|||
import Control.Monad.Except (catchError) |
|||
import Hakyll |
@ -1,10 +1,10 @@ |
|||
module GreenSite.Compiler.Layout where |
|||
module Green.Compiler.Layout where |
|||
|
|||
import Control.Monad ((<=<)) |
|||
import Data.Binary as B |
|||
import Data.ByteString.Lazy as LBS |
|||
import GHC.Generics hiding (to) |
|||
import GreenSite.Config |
|||
import Green.Config |
|||
import Hakyll |
|||
import Lens.Micro |
|||
import Lens.Micro.TH |
@ -1,17 +1,17 @@ |
|||
module GreenSite.Context |
|||
( module GreenSite.Context.Field, |
|||
module GreenSite.Context.GitCommits, |
|||
module GreenSite.Context.Post, |
|||
module GreenSite.Context.Tag, |
|||
module Green.Context |
|||
( module Green.Context.Field, |
|||
module Green.Context.GitCommits, |
|||
module Green.Context.Post, |
|||
module Green.Context.Tag, |
|||
baseContext, |
|||
) |
|||
where |
|||
|
|||
import GreenSite.Config |
|||
import GreenSite.Context.Field |
|||
import GreenSite.Context.GitCommits |
|||
import GreenSite.Context.Post |
|||
import GreenSite.Context.Tag |
|||
import Green.Config |
|||
import Green.Context.Field |
|||
import Green.Context.GitCommits |
|||
import Green.Context.Post |
|||
import Green.Context.Tag |
|||
import Hakyll (Context, constField) |
|||
import Lens.Micro |
|||
|
@ -1,4 +1,4 @@ |
|||
module GreenSite.Context.GitCommits (gitCommits) where |
|||
module Green.Context.GitCommits (gitCommits) where |
|||
|
|||
import Data.Bool (bool) |
|||
import Data.Maybe (fromJust, isJust) |
@ -1,4 +1,4 @@ |
|||
module GreenSite.Context.Post where |
|||
module Green.Context.Post where |
|||
|
|||
import Hakyll |
|||
|
@ -1,4 +1,4 @@ |
|||
module GreenSite.Context.Tag where |
|||
module Green.Context.Tag where |
|||
|
|||
import Hakyll |
|||
|
@ -1,4 +1,4 @@ |
|||
module GreenSite.Lens where |
|||
module Green.Lens where |
|||
|
|||
import Language.Haskell.TH |
|||
import Lens.Micro |
@ -1,6 +1,6 @@ |
|||
module GreenSite.Lens.Hakyll where |
|||
module Green.Lens.Hakyll where |
|||
|
|||
import GreenSite.Lens |
|||
import Green.Lens |
|||
import Hakyll |
|||
|
|||
makeLensesWithL ''Configuration |
@ -1,4 +1,4 @@ |
|||
module GreenSite.Route where |
|||
module Green.Route where |
|||
|
|||
import Data.List (isSuffixOf) |
|||
import Data.String.Utils (join, split) |
@ -1,14 +1,14 @@ |
|||
module GreenSite.Rule where |
|||
module Green.Rule where |
|||
|
|||
import GreenSite.Compiler.Layout |
|||
import GreenSite.Config |
|||
import GreenSite.Rule.Blog |
|||
import GreenSite.Rule.Feed |
|||
import GreenSite.Rule.Js |
|||
import GreenSite.Rule.Page |
|||
import GreenSite.Rule.Robot |
|||
import GreenSite.Rule.Sass |
|||
import GreenSite.Rule.Sitemap |
|||
import Green.Compiler.Layout |
|||
import Green.Config |
|||
import Green.Rule.Blog |
|||
import Green.Rule.Feed |
|||
import Green.Rule.Js |
|||
import Green.Rule.Page |
|||
import Green.Rule.Robot |
|||
import Green.Rule.Sass |
|||
import Green.Rule.Sitemap |
|||
import Hakyll |
|||
|
|||
rules :: SiteConfig -> Rules () |
@ -1,6 +1,6 @@ |
|||
module GreenSite.Rule.Blog where |
|||
module Green.Rule.Blog where |
|||
|
|||
import GreenSite.Common |
|||
import Green.Common |
|||
|
|||
{-----------------------------------------------------------------------------} |
|||
{- Rules -} |
@ -1,7 +1,7 @@ |
|||
module GreenSite.Rule.Feed (feedRules) where |
|||
module Green.Rule.Feed (feedRules) where |
|||
|
|||
import GreenSite.Common |
|||
import GreenSite.Rule.Blog (loadPublishedPosts) |
|||
import Green.Common |
|||
import Green.Rule.Blog (loadPublishedPosts) |
|||
|
|||
feedRules :: SiteConfig -> Rules () |
|||
feedRules config = do |
@ -1,4 +1,4 @@ |
|||
module GreenSite.Rule.Js (jsRules) where |
|||
module Green.Rule.Js (jsRules) where |
|||
|
|||
import qualified Data.ByteString.Lazy.Char8 as C |
|||
import Hakyll |
@ -1,6 +1,6 @@ |
|||
module GreenSite.Rule.Page (pageRules) where |
|||
module Green.Rule.Page (pageRules) where |
|||
|
|||
import GreenSite.Common |
|||
import Green.Common |
|||
|
|||
pageRules :: SiteConfig -> Rules () |
|||
pageRules config = do |
@ -1,6 +1,6 @@ |
|||
module GreenSite.Rule.Robot where |
|||
module Green.Rule.Robot where |
|||
|
|||
import GreenSite.Common |
|||
import Green.Common |
|||
|
|||
robotsTxtRules :: SiteConfig -> Rules () |
|||
robotsTxtRules config = do |
@ -1,6 +1,6 @@ |
|||
module GreenSite.Rule.Sass (sassRules) where |
|||
module Green.Rule.Sass (sassRules) where |
|||
|
|||
import GreenSite.Common |
|||
import Green.Common |
|||
|
|||
sassRules :: SiteConfig -> Rules () |
|||
sassRules config = do |
@ -1,7 +1,7 @@ |
|||
module GreenSite.Rule.Sitemap (sitemapRules) where |
|||
module Green.Rule.Sitemap (sitemapRules) where |
|||
|
|||
import GreenSite.Common |
|||
import GreenSite.Rule.Blog (loadPublishedPosts) |
|||
import Green.Common |
|||
import Green.Rule.Blog (loadPublishedPosts) |
|||
|
|||
sitemapRules :: SiteConfig -> Rules () |
|||
sitemapRules config = |
@ -1,4 +1,4 @@ |
|||
module GreenSite.Util where |
|||
module Green.Util where |
|||
|
|||
import Data.Char |
|||
import Data.Foldable (sequenceA_) |
@ -1,40 +0,0 @@ |
|||
module GreenSite.Command where |
|||
|
|||
import GreenSite.Util |
|||
import Options.Applicative |
|||
|
|||
data GreenCommand |
|||
= CreateDraft CreateDraftOpts |
|||
| PublishPost FilePath |
|||
deriving stock (Show, Eq) |
|||
|
|||
data CreateDraftOpts = CreateDraftOpts |
|||
{ draftTitle :: String, |
|||
draftCategory :: Maybe String |
|||
} |
|||
deriving stock (Show, Eq) |
|||
|
|||
greenCommands :: String -> ParserInfo GreenCommand |
|||
greenCommands progName = greenOptions |
|||
where |
|||
--- commands |
|||
greenOptions = info (greenOptions' <**> helper) (fullDesc <> greenDesc) |
|||
greenOptions' = subparser draftCommand <|> subparser publishCommand |
|||
greenDesc = progDesc (progName ++ " -- an admin tool for the site") |
|||
--- draft command |
|||
draftCommand = command "draft" $ info (draftOptions <**> helper) (progDesc "Create a new draft post") |
|||
draftOptions = CreateDraft <$> (CreateDraftOpts <$> strOption (long "title" <> short 't') <*> optional (strOption (long "category" <> short 'c'))) |
|||
--- publish command |
|||
publishCommand = command "publish" $ info (publishOptions <**> helper) (progDesc "Publish an existing draft") |
|||
publishOptions = PublishPost <$> strOption (long "file" <> short 'f') |
|||
|
|||
processGreenCommand :: GreenCommand -> IO () |
|||
processGreenCommand (CreateDraft draftOpts) = createDraft draftOpts |
|||
processGreenCommand (PublishPost file) = putStrLn ("Publishing " ++ file) |
|||
|
|||
createDraft :: CreateDraftOpts -> IO () |
|||
createDraft (CreateDraftOpts title maybeCategory) = |
|||
putStrLn $ "Writing post '" ++ title ++ "' to file " ++ draftFilePath |
|||
where |
|||
draftFilePath = categoryPrefix ++ kebabCase title ++ ".md" |
|||
categoryPrefix = maybe "" ((++ "/") . kebabCase) maybeCategory |
@ -1,7 +1,7 @@ |
|||
module GreenSite.Compiler.LayoutSpec where |
|||
module Green.Compiler.LayoutSpec where |
|||
|
|||
import GreenSite.Compiler.Layout |
|||
import GreenSite.TestSupport |
|||
import Green.Compiler.Layout |
|||
import Green.TestSupport |
|||
|
|||
spec :: Spec |
|||
spec = do |
@ -1,7 +1,7 @@ |
|||
module GreenSite.RouteSpec where |
|||
module Green.RouteSpec where |
|||
|
|||
import Data.Bifunctor |
|||
import GreenSite.TestSupport |
|||
import Green.TestSupport |
|||
|
|||
spec :: Spec |
|||
spec = do |
@ -1,7 +1,7 @@ |
|||
module GreenSite.Rule.BlogSpec where |
|||
module Green.Rule.BlogSpec where |
|||
|
|||
import GreenSite.Rule.Blog |
|||
import GreenSite.TestSupport |
|||
import Green.Rule.Blog |
|||
import Green.TestSupport |
|||
|
|||
spec :: Spec |
|||
spec = do |
@ -0,0 +1,22 @@ |
|||
module Green.TestSupport |
|||
( module Green.Common, |
|||
module Green.TestSupport, |
|||
module Green.TestSupport.Compiler, |
|||
module Green.TestSupport.Config, |
|||
module Green.TestSupport.Resource, |
|||
module Green.TestSupport.Routes, |
|||
module Green.TestSupport.TestEnv, |
|||
module Test.Hspec, |
|||
) |
|||
where |
|||
|
|||
import Green.Common |
|||
import Green.TestSupport.Compiler |
|||
import Green.TestSupport.Config |
|||
import Green.TestSupport.Resource |
|||
import Green.TestSupport.Routes |
|||
import Green.TestSupport.TestEnv |
|||
import Test.Hspec |
|||
|
|||
runAll :: [SpecWith a] -> SpecWith a |
|||
runAll = sequenceA_ |
@ -1,10 +1,10 @@ |
|||
module GreenSite.TestSupport.Compiler where |
|||
module Green.TestSupport.Compiler where |
|||
|
|||
import Data.Set as S |
|||
import Hakyll as H |
|||
import Hakyll.Core.Compiler.Internal |
|||
import qualified Hakyll.Core.Logger as Logger |
|||
import GreenSite.TestSupport.TestEnv |
|||
import Green.TestSupport.TestEnv |
|||
import Test.Hspec |
|||
|
|||
type RunCompiler a = Compiler a -> Identifier -> IO (CompilerResult a) |
@ -1,8 +1,8 @@ |
|||
module GreenSite.TestSupport.Config where |
|||
module Green.TestSupport.Config where |
|||
|
|||
import Data.Time |
|||
import Hakyll as H |
|||
import GreenSite.Common |
|||
import Green.Common |
|||
|
|||
defaultTestTimeString :: String |
|||
defaultTestTimeString = "2013-06-16T21:12:00-07:00" |
@ -1,4 +1,4 @@ |
|||
module GreenSite.TestSupport.Resource where |
|||
module Green.TestSupport.Resource where |
|||
|
|||
-- | Creates a spec resource dependent on a bracketed resource and runs the spec with it |
|||
-- |
@ -1,9 +1,9 @@ |
|||
module GreenSite.TestSupport.Routes where |
|||
module Green.TestSupport.Routes where |
|||
|
|||
import Data.Foldable (traverse_) |
|||
import Hakyll as H |
|||
import GreenSite.Common |
|||
import GreenSite.TestSupport.TestEnv |
|||
import Green.Common |
|||
import Green.TestSupport.TestEnv |
|||
import Test.Hspec |
|||
|
|||
type RunRoutes = Routes -> Identifier -> IO (Maybe FilePath, UsedMetadata) |
@ -1,11 +1,11 @@ |
|||
module GreenSite.TestSupport.TestEnv where |
|||
module Green.TestSupport.TestEnv where |
|||
|
|||
import Data.Time |
|||
import Hakyll as H |
|||
import qualified Hakyll.Core.Provider as HP |
|||
import qualified Hakyll.Core.Store as HS |
|||
import GreenSite.Common |
|||
import GreenSite.TestSupport.Config |
|||
import Green.Common |
|||
import Green.TestSupport.Config |
|||
|
|||
data TestEnv = TestEnv |
|||
{ testTime :: ZonedTime, |
@ -1,22 +0,0 @@ |
|||
module GreenSite.TestSupport |
|||
( module GreenSite.Common, |
|||
module GreenSite.TestSupport, |
|||
module GreenSite.TestSupport.Compiler, |
|||
module GreenSite.TestSupport.Config, |
|||
module GreenSite.TestSupport.Resource, |
|||
module GreenSite.TestSupport.Routes, |
|||
module GreenSite.TestSupport.TestEnv, |
|||
module Test.Hspec, |
|||
) |
|||
where |
|||
|
|||
import GreenSite.Common |
|||
import GreenSite.TestSupport.Compiler |
|||
import GreenSite.TestSupport.Config |
|||
import GreenSite.TestSupport.Resource |
|||
import GreenSite.TestSupport.Routes |
|||
import GreenSite.TestSupport.TestEnv |
|||
import Test.Hspec |
|||
|
|||
runAll :: [SpecWith a] -> SpecWith a |
|||
runAll = sequenceA_ |
Loading…
Reference in new issue