static-resources-0.1.7: JavaScript and Css files concat for http optimization. Now with LESS support.

Portabilityportable
Stabilitydevelopment
Maintainermariusz@scrive.com
Safe HaskellNone

Static.Resources

Contents

Description

Put resources.spec into your public HTTP directory. List there your css, less and js files. Devide them over some sets.

Sample resources.spec:

 set mainPage
  css mainPage.css
  js  mainPage.js
  js  jQuery.js

Usage:

 do
 rs <- getResourceSetsForImport Development "public/resources.js" ""
 return "<html><head>"++(htmlImportList "mainPage" rs)++"</head><body/></html>"

Synopsis

Main interface

htmlImportList :: String -> ResourceSetsForImport -> StringSource

Generating import list for HTML resources

getResourceSetsForImportSource

Arguments

:: ImportType

Import for production or dev.

-> FilePath

Configuration file.

-> FilePath

Outputted import declaration path prefix (if any).

-> IO (Either String ResourceSetsForImport) 

Make ResourceSetsForImport ready. It will generate aggregated css and js files if needed. It will change directory to one of spec file. Aggregated files will be placed there. Will change back to original dir when done.

cleanResourceFiles :: String -> ResourceSpec -> IO ()Source

Cleans all files that could be created by this system based on spec. It requires current directory to be in specification file directory

Parsing specification

data ResourceSpec Source

ResourceSpec is a list of ResourceSet and list of files or directories that can be ignored by check function.

Instances

Check if your spec file is compleate and consistent with FS

check :: String -> ResourceSpec -> IO (Either String ())Source

Performs check. Left is error with some description. * Fails with css and js files avaible but not listed in spec. * Fails with css and js files that are in spec, but not avaible.

data ImportType Source

We can import resources for development (no joined, gziped or minified) or for production.

Constructors

Development 
Production 

Instances

resourcesMTime :: FilePath -> IO UTCTimeSource

Time when last resource file was changed. Param is configuration file location (same that was used for generation). This time can be compared to generationTime of ResourceSetsForImport