herringbone-0.1.1: A library for compiling and serving static web assets.

Safe HaskellNone
LanguageHaskell2010

Web.Herringbone.Internal.Types

Synopsis

Documentation

data AssetError Source

A value describing an error that occurred while trying to produce an Asset.

data PPReader Source

Data which is given to preprocessors on the off-chance that they need it (eg, Fay)

Constructors

PPReader 

Fields

ppReaderHb :: Herringbone

The Herringbone which was used to build the asset

ppReaderSourcePath :: FilePath

The file path to the source file

ppReaderPPs :: [PP]

Preprocessors being invoked. Currently this will only ever have zero or one elements; in the future, Herringbone may be able to run multiple preprocessors on a single file.

newtype PPM a Source

A monad in which preprocessor actions happen.

Constructors

PPM 

Fields

unPPM :: ReaderT PPReader IO a
 

runPPM :: PPM a -> PPReader -> IO a Source

data PP Source

A preprocessor something which is run on the asset before it is served. Preprocessors are run when a file matches its rule. For example, if you have a preprocessor which takes "coffee" files and emits "js" files, there is a file named "application.coffee", and you request "application.js", Herringbone will run the coffee preprocessor on "application.coffee" and serve you the result.

Constructors

PP 

Fields

ppName :: Text

Identifies a preprocessor. Mainly useful for debugging compile errors.

ppConsumes :: Text

Extension for files this preprocessor consumes.

ppProduces :: Text

Extension for files this preprocessor produces.

ppAction :: PPAction

Performs the compilation.

Instances

type PPAction Source

Arguments

 = ByteString

Input file contents

-> PPM (Either CompileError ByteString)

Output file contents, or a compile error.

A function which performs the compilation.

type CompileError = ByteString Source

A string which should contain information about why an asset failed to compile.

newtype PPs Source

A collection of preprocessors. This can store many preprocessors which produce files with the same extension, but may not store more than one preprocessor which consumes files of a particular extension.

Constructors

PPs 

Fields

unPPs :: Map Text PP
 

Instances

lookupPP :: Text -> PPs -> Maybe PP Source

Given a file extension, find the preprocessor (if any) which consumes it.

insertPP :: PP -> PPs -> PPs Source

Inserts a preprocessor into a PPs. If a preprocessor already exists with the given extension, it is discarded.

fromList :: [PP] -> PPs Source

Turn a list of PPs into a proper PPs.

data BuildSpec Source

A BuildSpec specifies how an asset should be built.

Constructors

BuildSpec 

Fields

bsSourcePath :: FilePath

Source path (relative)

bsDestPath :: FilePath

Destination path (again, relative)

bsPP :: Maybe PP

Preprocessor to run (if any)

Instances

type BuildMapping = [BuildSpec] Source

A BuildMapping contains the information to build all of the assets Herringbone is aware of.

data Herringbone Source

The 'main' datatype in this library. All of the important functions will take a Herringbone as their first argument.

data HerringboneSettings Source

Contains configuration.

Constructors

HerringboneSettings 

Fields

settingsSourceDir :: FilePath

The directory to take asset sources from.

settingsDestDir :: FilePath

Where to copy assets to after they've been compiled.

settingsPPs :: PPs

Preprocessors

settingsVerbose :: Bool

Dump debugging data to stdout on every request.

hbSourceDir :: Herringbone -> FilePath Source

The directory where Herringbone will look when searching for assets.

hbDestDir :: Herringbone -> FilePath Source

The directory to place assets in after compilation.

hbPPs :: Herringbone -> PPs Source

The collection of preprocessors that will be used when preprocessing assets.

hbVerbose :: Herringbone -> Bool Source

True iff the Herringbone has the verbose setting enabled.

verbosePut :: Herringbone -> String -> IO () Source

Log a message to stdout if hbVerbose is enabled.

newtype LogicalPath Source

All assets in Herringbone are referenced by their logical path. This is the path to an asset, relative to the source directory.

Constructors

LogicalPath 

Fields

fromLogicalPath :: [Text]
 

makeLogicalPath :: [Text] -> Maybe LogicalPath Source

Create a LogicalPath from a list of path segments. For example, ["data", "dogs.txt"] would map to data/dogs.txt (relative to the source directory). This returns Nothing if the path would be unsafe (that is, if it contains ".."), to prevent directory traversal attacks.

unsafeMakeLogicalPath :: [Text] -> LogicalPath Source

Create a LogicalPath without checking any of the values.

data Asset Source

A preprocessed asset. Any function that returns this will already have done the preprocessing (if necessary).

Constructors

Asset 

Fields

assetSize :: Integer

Size of the asset in bytes.

assetSourcePath :: FilePath

Path to the asset's source file on disk.

assetFilePath :: FilePath

Path to the preprocessed asset on disk. Note that assets which do not require preprocessing will still be copied to the destination directory.

assetModifiedTime :: UTCTime

Modification time of the asset's source file.

Instances