Copyright | (c) Scrive 2012 |
---|---|
License | BSD-style (see the LICENSE file in the distribution) |
Maintainer | mariusz@scrive.com |
Stability | development |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
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>"
- htmlImportList :: String -> ResourceSetsForImport -> String
- getResourceSetsForImport :: ImportType -> FilePath -> FilePath -> IO (Either String ResourceSetsForImport)
- cleanResourceFiles :: String -> ResourceSpec -> IO ()
- data ResourceSpec
- parseSpec :: FilePath -> IO ResourceSpec
- check :: String -> ResourceSpec -> IO (Either String ())
- data ImportType
- data ResourceSetsForImport = ResourceSetsForImport {}
- generateResources :: ImportType -> String -> ResourceSpec -> FilePath -> IO ResourceSetsForImport
- resourcesMTime :: FilePath -> IO UTCTime
Main interface
htmlImportList :: String -> ResourceSetsForImport -> String Source
Generating import list for HTML resources
getResourceSetsForImport Source
:: 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.
parseSpec :: FilePath -> IO ResourceSpec Source
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.
data ResourceSetsForImport Source
Set of ResourceSetForImport
generateResources :: ImportType -> String -> ResourceSpec -> FilePath -> IO ResourceSetsForImport Source
Generate each set of resources.
resourcesMTime :: FilePath -> IO UTCTime Source
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