-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | JavaScript and Css files concat for http optimization. Now with LESS suppor. -- -- You need to add static resources to your web page. For production you -- want to decrease number of files. For development you need them -- separated. Support for distinct sets of JS, CSS and LESS files for -- different views. @package static-resources @version 0.1.5.1 -- | All types used by this module. module Static.Resources.Types -- | All resources have to be typed data ResourceType -- | CSS file CSS :: ResourceType -- | LESS support. See http://lesscss.org/. LESS :: ResourceType -- | JavaScript file JS :: ResourceType -- | Special JavaScript. System will not join this one with other scripts. JSX :: ResourceType -- | Resource is a file with a type. data Resource Resource :: !ResourceType -> !FilePath -> Resource rtype :: Resource -> !ResourceType path :: Resource -> !FilePath -- | ResourceSet is named list of resources. data ResourceSet ResourceSet :: !String -> ![Resource] -> ResourceSet name :: ResourceSet -> !String resources :: ResourceSet -> ![Resource] -- | ResourceSpec is a list of ResourceSet and list of files -- or directories that can be ignored by check function. data ResourceSpec ResourceSpec :: ![ResourceSet] -> ![FilePath] -> ResourceSpec sets :: ResourceSpec -> ![ResourceSet] ignored :: ResourceSpec -> ![FilePath] -- | We can import resources for development (no joined, gziped or -- minified) or for production. data ImportType Development :: ImportType Production :: ImportType -- | ResourceSet that is ready to be imported. It's all you need to -- generate import list for html. data ResourceSetForImport ResourceSetForImport :: !ResourceSet -> ![FilePath] -> ![FilePath] -> ![FilePath] -> ResourceSetForImport set :: ResourceSetForImport -> !ResourceSet cssFiles :: ResourceSetForImport -> ![FilePath] jsFiles :: ResourceSetForImport -> ![FilePath] lessFiles :: ResourceSetForImport -> ![FilePath] -- | Set of ResourceSetForImport data ResourceSetsForImport ResourceSetsForImport :: [ResourceSetForImport] -> ClockTime -> ResourceSetsForImport _sets :: ResourceSetsForImport -> [ResourceSetForImport] generationTime :: ResourceSetsForImport -> ClockTime -- | Utils for getting specyfic parts of ResourceSet filterByType :: (ResourceType -> Bool) -> ResourceSet -> [Resource] instance Typeable ResourceType instance Show ResourceType instance Data ResourceType instance Eq ResourceType instance Show Resource instance Show ResourceSet instance Show ResourceSpec instance Show ImportType instance Show ResourceSetForImport instance Show ResourceSetsForImport -- | Parsing static resources spec. -- -- -- -- Sample spec -- --
--   ignore main.css
--   
--   set a
--     js  a.js 
--     css a.css
--     css common.css
--   
--   set b
--     js  b.js    
--     css b.css
--     css common.css
--   
module Static.Resources.Spec parseSpec :: FilePath -> IO ResourceSpec -- | Basic consistency checker. module Static.Resources.Checker -- | 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. check :: ResourceSpec -> IO (Either String ()) isStaticResourceFile :: String -> Bool -- | Module for generaing joined js and css files from spec module Static.Resources.Generation -- | Generate each set of resources. generateResources :: ImportType -> ResourceSpec -> FilePath -> IO ResourceSetsForImport -- | Generating list of imports to be embedded in html module Static.Resources.Import -- | Generating import list for HTML resources htmlImportList :: String -> ResourceSetsForImport -> String -- | 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>"
--   
module Static.Resources -- | Generating import list for HTML resources htmlImportList :: String -> ResourceSetsForImport -> String -- | Make ResourceSetsForImport ready. It will generate agregated -- css and js files if needed. It will change directory to one of spec -- file. It agregates will be placed there. When done it will change back -- to the original dir getResourceSetsForImport :: ImportType -> FilePath -> FilePath -> IO (Either String ResourceSetsForImport) -- | Cleans all files that could be created by this system based on spec. -- It requires current directory to be in specification file directory cleanResourceFiles :: ResourceSpec -> IO () -- | ResourceSpec is a list of ResourceSet and list of files -- or directories that can be ignored by check function. data ResourceSpec parseSpec :: FilePath -> IO ResourceSpec -- | 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. check :: ResourceSpec -> IO (Either String ()) -- | We can import resources for development (no joined, gziped or -- minified) or for production. data ImportType Development :: ImportType Production :: ImportType -- | Set of ResourceSetForImport data ResourceSetsForImport ResourceSetsForImport :: [ResourceSetForImport] -> ClockTime -> ResourceSetsForImport _sets :: ResourceSetsForImport -> [ResourceSetForImport] generationTime :: ResourceSetsForImport -> ClockTime -- | Generate each set of resources. generateResources :: ImportType -> ResourceSpec -> FilePath -> IO ResourceSetsForImport -- | 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 resourcesMTime :: FilePath -> IO ClockTime