{-# LANGUAGE DeriveLift #-}
module Drasil.Assets.Core
(
Asset,
mkAsset,
content,
description,
toFile,
)
where
import Data.ByteString qualified as B (ByteString)
import Data.Text (Text)
import Language.Haskell.TH.Syntax (Lift)
import Prelude hiding (readFile)
import Drasil.FileHandling (FileLayout, PathSegment, exactFile)
data Asset = Asset Text B.ByteString
deriving ((forall (m :: * -> *). Quote m => Asset -> m Exp)
-> (forall (m :: * -> *). Quote m => Asset -> Code m Asset)
-> Lift Asset
forall t.
(forall (m :: * -> *). Quote m => t -> m Exp)
-> (forall (m :: * -> *). Quote m => t -> Code m t) -> Lift t
forall (m :: * -> *). Quote m => Asset -> m Exp
forall (m :: * -> *). Quote m => Asset -> Code m Asset
$clift :: forall (m :: * -> *). Quote m => Asset -> m Exp
lift :: forall (m :: * -> *). Quote m => Asset -> m Exp
$cliftTyped :: forall (m :: * -> *). Quote m => Asset -> Code m Asset
liftTyped :: forall (m :: * -> *). Quote m => Asset -> Code m Asset
Lift)
description :: Asset -> Text
description :: Asset -> Text
description (Asset Text
desc ByteString
_) = Text
desc
content :: Asset -> B.ByteString
content :: Asset -> ByteString
content (Asset Text
_ ByteString
c) = ByteString
c
mkAsset :: Text -> B.ByteString -> Asset
mkAsset :: Text -> ByteString -> Asset
mkAsset = Text -> ByteString -> Asset
Asset
toFile :: Asset -> PathSegment -> FileLayout
toFile :: Asset -> PathSegment -> FileLayout
toFile Asset
a = (PathSegment -> ByteString -> FileLayout)
-> ByteString -> PathSegment -> FileLayout
forall a b c. (a -> b -> c) -> b -> a -> c
flip PathSegment -> ByteString -> FileLayout
forall doc. Writeable doc => PathSegment -> doc -> FileLayout
exactFile (Asset -> ByteString
content Asset
a)