embed.hs 2.05 KB
Newer Older
Henrik Tramberend's avatar
Henrik Tramberend committed
1 2
{-- Author: Henrik Tramberend <henrik@tramberend.de> --} 

3 4 5
{-# LANGUAGE TemplateHaskell #-}

module Embed
6 7 8
  ( deckerHelpText
  , deckerExampleDir
  , deckerSupportDir
Henrik Tramberend's avatar
Henrik Tramberend committed
9
  , deckerTemplateDir
10 11 12 13 14 15 16 17 18 19 20
  , deckTemplate
  , pageTemplate
  , pageLatexTemplate
  , examLatexTemplate
  , handoutTemplate
  , handoutLatexTemplate
  , testerMultipleChoiceTemplate
  , testerMultipleAnswersTemplate
  , testerFillTextTemplate
  , testerFreeFormTemplate
  , testLatexTemplate
Henrik Tramberend's avatar
Henrik Tramberend committed
21 22
  , defaultTemplate
  , defaultTemplateString
23
  ) where
24 25

import qualified Data.ByteString.Char8 as B
Henrik Tramberend's avatar
Henrik Tramberend committed
26 27 28
import Data.FileEmbed
import Data.List
import Data.Maybe
29 30 31 32 33 34 35

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
36 37 38 39 40 41 42 43 44 45
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"
46

Henrik Tramberend's avatar
Henrik Tramberend committed
47
deckTemplate = fromJust $ defaultTemplateString "deck.html"
48

Henrik Tramberend's avatar
Henrik Tramberend committed
49
pageTemplate = fromJust $ defaultTemplateString "page.html"
50

Henrik Tramberend's avatar
Henrik Tramberend committed
51
pageLatexTemplate = fromJust $ defaultTemplateString "page.tex"
Henrik Tramberend's avatar
Henrik Tramberend committed
52

Henrik Tramberend's avatar
Henrik Tramberend committed
53
examLatexTemplate = fromJust $ defaultTemplateString "exam.tex"
54

Henrik Tramberend's avatar
Henrik Tramberend committed
55
handoutTemplate = fromJust $ defaultTemplateString "handout.html"
56

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

59
testerMultipleChoiceTemplate =
Henrik Tramberend's avatar
Henrik Tramberend committed
60
  fromJust $ defaultTemplate "mc-quest-catalog-template.md"
61 62

testerMultipleAnswersTemplate =
Henrik Tramberend's avatar
Henrik Tramberend committed
63
  fromJust $ defaultTemplate "ma-quest-catalog-template.md"
64

Henrik Tramberend's avatar
Henrik Tramberend committed
65
testerFillTextTemplate = fromJust $ defaultTemplate "ft-quest-catalog-template.md"
66

Henrik Tramberend's avatar
Henrik Tramberend committed
67
testerFreeFormTemplate = fromJust $ defaultTemplate "ff-quest-catalog-template.md"
Henrik Tramberend's avatar
Henrik Tramberend committed
68

Henrik Tramberend's avatar
Henrik Tramberend committed
69
testLatexTemplate = fromJust $ defaultTemplate "test.tex"