Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Project starter

  • Loading branch information...
commit 44baca99820f082b9f8a7503754091f39b6ed243 1 parent b09ef16
@jaspervdj authored
Showing with 77 additions and 1 deletion.
  1. +1 −1  .ghci
  2. +17 −0 hakyll-contrib.cabal
  3. +59 −0 src/Hakyll/Contrib/Main.hs
View
2  .ghci
@@ -1 +1 @@
-:set -isrc
+:set -isrc -idist/build/autogen
View
17 hakyll-contrib.cabal
@@ -10,6 +10,12 @@ Category: Web
Cabal-version: >=1.6
Build-type: Simple
+Data-dir: data
+
+Data-files:
+ small-blog/hakyll.hs
+ small-blog/index.html
+ small-blog/css/default.css
Source-Repository head
Type: git
@@ -26,3 +32,14 @@ Library
Exposed-modules:
Hakyll.Contrib.SmallBlog
+
+Executable hakyll-contrib
+ Ghc-options: -Wall
+ Hs-source-dirs: src
+ Main-is: Hakyll/Contrib/Main.hs
+
+ Build-depends:
+ base >= 4 && < 5,
+ hakyll >= 3.2 && < 3.3,
+ directory >= 1.1 && < 1.3,
+ filepath >= 1.1 && < 1.3
View
59 src/Hakyll/Contrib/Main.hs
@@ -0,0 +1,59 @@
+-- | Hakyll project starter
+--
+module Main
+ ( main
+ ) where
+
+import Control.Monad (forM_)
+import System.Environment (getArgs, getProgName)
+import System.FilePath (splitPath, joinPath, (</>))
+import System.Directory (copyFile)
+
+import Hakyll.Core.Util.File (getRecursiveContents, makeDirectories)
+
+import Paths_hakyll_contrib (getDataDir)
+
+-- | Available projects
+--
+projects :: [String]
+projects =
+ [ "small-blog"
+ ]
+
+-- | Start a project: just copy the directory
+--
+startProject :: String -> String -> IO ()
+startProject p d = do
+ source <- fmap (</> p) getDataDir
+ contents <- getRecursiveContents False $ source
+ forM_ contents $ \file -> do
+ let dest = d </> stripDir source file
+ putStrLn $ "Creating " ++ dest
+ makeDirectories dest
+ copyFile file dest
+ where
+ stripDir dir = joinPath . (drop $ length $ splitPath dir) . splitPath
+
+-- | Print usage information
+--
+usage :: IO ()
+usage = do
+ progName <- getProgName
+ putStr $ unlines
+ [ "hakyll-contrib project starter"
+ , ""
+ , "Usage: " ++ progName ++ " <project> [dirname]"
+ , ""
+ , "Where project is one of:"
+ ]
+ forM_ projects $ \p -> putStrLn $ " " ++ p
+
+-- | Main function
+--
+main :: IO ()
+main = do
+ args <- getArgs
+ case args of
+ (p : d : _) -> if p `elem` projects then startProject p d else usage
+ (p : _) -> if p `elem` projects then startProject p p else usage
+ _ -> usage
Please sign in to comment.
Something went wrong with that request. Please try again.