tonyday567.github.io repo Build Status

tonyday567's haskell blog

An attempt to automate blogging via readme-lhs, pandoc and turtle.

repos

Notes around stack new new-project readme-lhs

readme-lhs repoBuild Status

A small but growing collection of charts, constructed in the spirit of scale invariant, standardised diagram units.

chart-unit repoBuild Status

stack install && readme && pandoc -f markdown+lhs -t html -i readme.lhs -o index.html --filter pandoc-include

turtle

At the moment, the last mile of turning readme.lhs's into a blog is a manual copy/paste. The code below is the start of using turtle to automate.

{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}

import Protolude
import Turtle hiding ((&))
import Filesystem.Path.CurrentOS

import Data.Default
import Control.Lens hiding (Context, (&), has, view)
import Control.Monad.Primitive (unsafeInlineIO)

data Project =
  Project
  { _projName :: Text
  , _projDir :: Text
  , _projBlog :: Maybe Text
  , _projOther :: [(Text, Pattern Text)]
  }

instance Default Project where
  def = Project "default" "~/git/default" Nothing []

makeLenses ''Project

projects :: [Project]
projects =
  [ (def &
     projName .~ "chart-unit" &
     projDir .~ "git/chart-unit" &
     projBlog .~ Just "readme.lhs" &
     projOther .~ [("other", Turtle.has ".svg|.png")])
  , (def &
     projName .~ "readme-lhs" &
     projBlog .~ Just "readme.lhs" &
     projOther .~ [("other", "lhs.css")
                  ,("other", "header.md")])
  ]


site :: Text
site = "tonyday567.github.io"

The process needs to:

other (Project n d _ p) = do
  h <- home
  let all = fmap toText <$> (\x -> ls $ h <> fromText d <> fromText x) <$> fst <$> p
  let which = (grep <$> Turtle.has <$> snd <$> p)
  pure ()
  
blog p@(Project _ _ Nothing _) = Nothing
blog p@(Project _ d (Just b) _) = Just $ d<>"/"<>b
main :: IO ()
main = do
  echo $ "building " <> site
  mapM_ (\p -> do
        let b = blog p
        o <- other p 
        pure ()) projects

let (Just p) = head projects let (Project n d (Just b) (Just (fp,patt))) = p