-----------------------------------------------------------
{-# LANGUAGE Arrows            #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where

-----------------------------------------------------------
import           Control.Applicative ((<$>))
import           Data.Monoid         (mappend, mconcat)
import           Prelude             hiding (id)
import           System.FilePath     (replaceExtension, takeDirectory)
import qualified Text.Pandoc         as Pandoc


-----------------------------------------------------------
import Hakyll


-----------------------------------------------------------
-- | Entry point
main :: IO ()
main = hakyllWith config $ do

    match ("images/*" .||. "favicon.png" .||. "files/*" .||. "font/**") $ do
        route   idRoute
        compile copyFileCompiler

    match "css/*" $ do
        route   idRoute
        compile compressCssCompiler

    match "templates/*" $ compile $ templateCompiler

    match ("*.md" .||. "projects/*/*.md") $ do
        route   $ setExtension "html"
        compile $ pandocCompiler
            >>= loadAndApplyTemplate "templates/default.html" defaultContext
            >>= relativizeUrls


--------------------------------------------------------------------------------
config :: Configuration
config = defaultConfiguration
    { deployCommand = "rsync --checksum -ave 'ssh -p 4242' \
                      \_site/* fab@ffreling.com:public_html/ffreling.com/public/"
    }
