Embed.hs 1.42 KB
Newer Older
1
{-- Author: Henrik Tramberend <henrik@tramberend.de> --}
2 3 4
{-# LANGUAGE TemplateHaskell #-}

module Embed
5 6 7
  ( deckerHelpText
  , deckerExampleDir
  , deckerSupportDir
Henrik Tramberend's avatar
Henrik Tramberend committed
8
  , deckerTemplateDir
9 10 11 12 13
  , deckTemplate
  , pageTemplate
  , pageLatexTemplate
  , handoutTemplate
  , handoutLatexTemplate
Henrik Tramberend's avatar
Henrik Tramberend committed
14 15
  , defaultTemplate
  , defaultTemplateString
16
  ) where
17 18

import qualified Data.ByteString.Char8 as B
Henrik Tramberend's avatar
Henrik Tramberend committed
19 20 21
import Data.FileEmbed
import Data.List
import Data.Maybe
22 23 24 25 26 27 28

deckerExampleDir :: [(FilePath, B.ByteString)]
deckerExampleDir = $(makeRelativeToProject "resource/example" >>= embedDir)

deckerSupportDir :: [(FilePath, B.ByteString)]
deckerSupportDir = $(makeRelativeToProject "resource/support" >>= embedDir)

Henrik Tramberend's avatar
Henrik Tramberend committed
29 30 31 32 33 34 35 36 37 38
deckerTemplateDir :: [(FilePath, B.ByteString)]
deckerTemplateDir = $(makeRelativeToProject "resource/template" >>= embedDir)

defaultTemplate :: FilePath -> Maybe B.ByteString
defaultTemplate path = snd <$> find (\(k, _) -> k == path) deckerTemplateDir

defaultTemplateString :: FilePath -> Maybe String
defaultTemplateString path = B.unpack <$> defaultTemplate path

deckerHelpText = fromJust $ defaultTemplateString "help-page.md"
39

Henrik Tramberend's avatar
Henrik Tramberend committed
40
deckTemplate = fromJust $ defaultTemplateString "deck.html"
41

Henrik Tramberend's avatar
Henrik Tramberend committed
42
pageTemplate = fromJust $ defaultTemplateString "page.html"
43

Henrik Tramberend's avatar
Henrik Tramberend committed
44
pageLatexTemplate = fromJust $ defaultTemplateString "page.tex"
Henrik Tramberend's avatar
Henrik Tramberend committed
45

Henrik Tramberend's avatar
Henrik Tramberend committed
46
handoutTemplate = fromJust $ defaultTemplateString "handout.html"
47

Henrik Tramberend's avatar
Henrik Tramberend committed
48
handoutLatexTemplate = fromJust $ defaultTemplateString "handout.tex"