-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A simple static site generator library. -- -- A simple static site generator library, mainly aimed at creating blogs -- and brochure sites. @package hakyll @version 1.3 -- | A module that exports a simple regex interface. This code is mostly -- copied from the regex-compat package at hackage. I decided to write -- this module because I want to abstract the regex package used. module Text.Hakyll.Regex -- | Split a list at a certain element. splitRegex :: String -> String -> [String] -- | Substitute a regex. Simplified interface. This function performs a -- global substitution. substituteRegex :: String -> String -> String -> String -- | Simple regex matching. matchesRegex :: String -> String -> Bool -- | Module containing various functions to manipulate contexts. module Text.Hakyll.Context -- | Type for a context. type Context = Map String String -- | Type for context manipulating functions. type ContextManipulation = Context -> Context -- | Do something with a value in a Context, but keep the old -- value as well. This is probably the most common function to construct -- a ContextManipulation. renderValue :: String -> String -> (String -> String) -> ContextManipulation -- | Change a value in a Context. -- --
-- import Data.Char (toUpper) -- changeValue "title" (map toUpper) ---- -- Will put the title in UPPERCASE. changeValue :: String -> (String -> String) -> ContextManipulation -- | When the context has a key called path in a -- yyyy-mm-dd-title.extension format (default for pages), this -- function can render the date. -- --
-- renderDate "date" "%B %e, %Y" "Date unknown" ---- -- Will render something like January 32, 2010. renderDate :: String -> String -> String -> ContextManipulation -- | Change the extension of a file. This is only needed when you want to -- render, for example, mardown to .php files instead of -- .html files. -- --
-- renderChainWith (changeExtension "php") -- ["templates/default.html"] -- (createPagePath "test.markdown") ---- -- Will render to test.php instead of test.html. changeExtension :: String -> ContextManipulation -- | Module describing the Hakyll monad stack. module Text.Hakyll.Hakyll -- | Hakyll global configuration type. data HakyllConfiguration HakyllConfiguration :: Context -> FilePath -> FilePath -> HakyllConfiguration -- | An additional context to use when rendering. This additional context -- is used globally. additionalContext :: HakyllConfiguration -> Context -- | Directory where the site is placed. siteDirectory :: HakyllConfiguration -> FilePath -- | Directory for cache files. cacheDirectory :: HakyllConfiguration -> FilePath -- | Our custom monad stack. type Hakyll = ReaderT HakyllConfiguration IO -- | Simplified ask function for the Hakyll monad stack. askHakyll :: (HakyllConfiguration -> a) -> Hakyll a -- | A module containing various function for manipulating and examinating -- files and directories. module Text.Hakyll.File -- | Convert a relative filepath to a filepath in the destination (default: -- _site). toDestination :: FilePath -> Hakyll FilePath -- | Convert a relative filepath to a filepath in the cache (default: -- _cache). toCache :: FilePath -> Hakyll FilePath -- | Get the url for a given page. toURL :: FilePath -> FilePath -- | Get the relative url to the site root, for a given (absolute) url toRoot :: FilePath -> FilePath -- | Swaps spaces for -. removeSpaces :: FilePath -> FilePath -- | Given a path to a file, try to make the path writable by making all -- directories on the path. makeDirectories :: FilePath -> Hakyll () -- | Get all contents of a directory. Note that files starting with a dot -- (.) will be ignored. getRecursiveContents :: FilePath -> Hakyll [FilePath] -- | Sort a list of filenames on the basename. sortByBaseName :: [FilePath] -> [FilePath] -- | A filter that takes all file names with a given extension. Prefix the -- extension with a dot: -- --
-- havingExtension ".markdown" [ "index.markdown" -- , "style.css" -- ] == ["index.markdown"] --havingExtension :: String -> [FilePath] -> [FilePath] -- | Check if a file is newer then a number of given files. isMoreRecent :: FilePath -> [FilePath] -> Hakyll Bool -- | Perform a Hakyll action on every file in a given directory. directory :: (FilePath -> Hakyll ()) -> FilePath -> Hakyll () module Text.Hakyll.Internal.Cache -- | We can store all datatypes instantiating Binary to the cache. -- The cache directory is specified by the HakyllConfiguration, -- usually _cache. storeInCache :: (Binary a) => a -> FilePath -> Hakyll () -- | Get a value from the cache. The filepath given should not be located -- in the cache. This function performs a timestamp check on the filepath -- and the filepath in the cache, and only returns the cached value when -- it is still up-to-date. getFromCache :: (Binary a) => FilePath -> Hakyll a -- | Check if a file in the cache is more recent than a number of other -- files. isCacheMoreRecent :: FilePath -> [FilePath] -> Hakyll Bool module Text.Hakyll.Renderable -- | A class for datatypes that can be rendered to pages. class Renderable a toContext :: (Renderable a) => a -> Hakyll Context getDependencies :: (Renderable a) => a -> [FilePath] getURL :: (Renderable a) => a -> FilePath module Text.Hakyll.Internal.Template -- | Datatype used for template substitutions. data Template -- | Construct a Template from a string. fromString :: String -> Template -- | Read a Template from a file. This function might fetch the -- Template from the cache, if available. readTemplate :: FilePath -> Hakyll Template -- | Substitutes $identifiers in the given Template by -- values from the given Context. When a key is not found, it is -- left as it is. You can specify the characters used to replace escaped -- dollars ($$) here. substitute :: String -> Template -> Context -> String -- | substitute for use during a chain. This will leave escaped -- characters as they are. regularSubstitute :: Template -> Context -> String -- | substitute for the end of a chain (just before writing). This -- renders escaped characters. finalSubstitute :: Template -> Context -> String instance Show Template instance Read Template instance Eq Template instance Arbitrary Template instance Binary Template -- | Module used for CSS compression. The compression is currently in a -- simple state, but would typically reduce the number of bytes by about -- 25%. module Text.Hakyll.Internal.CompressCSS -- | Compress CSS to speed up your site. compressCSS :: String -> String -- | Miscellaneous text manipulation functions. module Text.Hakyll.Util -- | Trim a string (drop spaces, tabs and newlines at both sides). trim :: String -> String -- | Strip html tags from the given string. stripHTML :: String -> String -- | Make a HTML link. -- --
-- link "foo" "bar.html" == "<a href='bar.html'>foo</a>" --link :: String -> String -> String -- | A module for dealing with Pages. This module is mostly -- internally used. module Text.Hakyll.Page -- | A Page is basically key-value mapping. Certain keys have special -- meanings, like for example url, body and title. data Page -- | Create a Page from a key-value mapping. fromContext :: Context -> Page -- | Obtain a value from a page. Will resturn an empty string when nothing -- is found. getValue :: String -> Page -> String -- | Get the body for a certain page. When not defined, the body will be -- empty. getBody :: Page -> String -- | Read a page. Might fetch it from the cache if available. Otherwise, it -- will read it from the file given and store it in the cache. readPage :: FilePath -> Hakyll Page instance Show Page instance Read Page instance Eq Page instance Arbitrary Page instance Binary Page instance Renderable Page -- | Internal module do some low-level rendering. module Text.Hakyll.Internal.Render -- | Substitutes $identifiers in the given Template by -- values from the given Context. When a key is not found, it is -- left as it is. You can specify the characters used to replace escaped -- dollars ($$) here. substitute :: String -> Template -> Context -> String -- | substitute for use during a chain. This will leave escaped -- characters as they are. regularSubstitute :: Template -> Context -> String -- | substitute for the end of a chain (just before writing). This -- renders escaped characters. finalSubstitute :: Template -> Context -> String -- | A pure render function. pureRenderWith :: ContextManipulation -> Template -> Context -> Context -- | A pure renderAndConcat function. pureRenderAndConcatWith :: ContextManipulation -> [Template] -> [Context] -> String -- | A pure renderChain function. pureRenderChainWith :: ContextManipulation -> [Template] -> Context -> Context -- | Write a page to the site destination. Final action after render chains -- and such. writePage :: Page -> Hakyll () -- | Module containing rendering functions. All these functions are used to -- render files to the _site directory. module Text.Hakyll.Render -- | Execute an IO action only when the cache is invalid. depends :: FilePath -> [FilePath] -> Hakyll () -> Hakyll () -- | Render to a Page. render :: (Renderable a) => FilePath -> a -> Hakyll Page -- | Render to a Page. This function allows you to manipulate the context -- first. renderWith :: (Renderable a) => ContextManipulation -> FilePath -> a -> Hakyll Page -- | Render each renderable with the given templates, then concatenate the -- result. So, basically this function: -- --
-- renderChain [ "templates/notice.html" -- , "templates/default.html" -- ] $ createPagePath "warning.html" ---- -- This code will first render warning.html using -- templates/notice.html, and will then render the result with -- templates/default.html. renderChain :: (Renderable a) => [FilePath] -> a -> Hakyll () -- | A more custom render chain that allows you to specify a -- ContextManipulation which to apply on the context when it is -- read first. renderChainWith :: (Renderable a) => ContextManipulation -> [FilePath] -> a -> Hakyll () -- | Mark a certain file as static, so it will just be copied when the site -- is generated. static :: FilePath -> Hakyll () -- | Render a css file, compressing it. css :: FilePath -> Hakyll () module Text.Hakyll.Renderables -- | A custom page. data CustomPage -- | Create a custom page. -- -- The association list given maps keys to values for substitution. Note -- that as value, you can either give a String or a Hakyll -- String. A Hakyll String is preferred for more complex -- data, since it allows dependency checking. A String is -- obviously more simple to use in some cases. createCustomPage :: String -> [FilePath] -> [(String, Either String (Hakyll String))] -> CustomPage -- | A createCustomPage function specialized in creating listings. -- -- This function creates a listing of a certain list of -- Renderables. Every item in the list is created by applying -- the given template to every renderable. You can also specify -- additional context to be included in the CustomPage. -- --
-- let customPage = createListingWith
-- "index.html" -- Destination of the page.
-- "templates/postitem.html" -- Path to template to
-- -- render the items with.
-- posts -- ^ Renderables to create the list with.
-- [("title", "Home")] -- ^ Additional context
--
createListing :: (Renderable a) => String -> FilePath -> [a] -> [(String, String)] -> CustomPage
-- | A createCustomPage function specialized in creating listings.
--
-- In addition to createListing, this function allows you to
-- specify an extra ContextManipulation for all
-- Renderables given.
createListingWith :: (Renderable a) => ContextManipulation -> String -> FilePath -> [a] -> [(String, String)] -> CustomPage
-- | PagePath is a class that wraps a FilePath. This is used to render
-- Pages without reading them first through use of caching.
data PagePath
-- | Create a PagePath from a FilePath.
createPagePath :: FilePath -> PagePath
-- | A combination of two other renderables.
data CombinedRenderable a b
-- | Combine two renderables. The url will always be taken from the first
-- Renderable. Also, if a `$key` is present in both renderables,
-- the value from the first Renderable will be taken as well.
--
-- Since renderables are always more or less key-value maps, you can see
-- this as a union between two maps.
combine :: (Renderable a, Renderable b) => a -> b -> CombinedRenderable a b
-- | Combine two renderables and set a custom URL. This behaves like
-- combine, except that for the url field, the given
-- URL is always chosen.
combineWithURL :: (Renderable a, Renderable b) => FilePath -> a -> b -> CombinedRenderable a b
instance (Renderable a, Renderable b) => Renderable (CombinedRenderable a b)
instance Binary PagePath
instance Renderable PagePath
instance Renderable CustomPage
-- | Module containing some specialized functions to deal with tags. This
-- Module follows certain conventions. Stick with them.
--
-- More concrete: all functions in this module assume that the tags are
-- located in the tags field, and separated by commas. An
-- example file foo.markdown could look like:
--
-- -- --- -- author: Philip K. Dick -- title: Do androids dream of electric sheep? -- tags: future, science fiction, humanoid -- --- -- The novel is set in a post-apocalyptic near future, where the Earth and -- its populations have been damaged greatly by Nuclear... ---- -- All the following functions would work with such a format. In addition -- to tags, Hakyll also supports categories. The convention when using -- categories is to place pages in subdirectories. -- -- An example, the page -- posts/coding/2010-01-28-hakyll-categories.markdown would be -- placed under the coding category. -- -- Tags or categories are read using the readTagMap and -- readCategoryMap functions. Because categories are implemented -- using tags - categories can be seen as tags, with the restriction that -- a page can only have one category - all functions for tags also work -- with categories. -- -- When reading a TagMap (which is also used for category maps) -- using the readTagMap or readCategoryMap function, -- you also have to give a unique identifier to it. This identifier is -- simply for caching reasons, so Hakyll can tell different maps apart; -- it has no other use. module Text.Hakyll.Tags -- | Type for a tag map. -- -- This is a map associating tags or categories to the appropriate pages -- using that tag or category. In the case of categories, each path will -- only appear under one category - this is not the case with tags. type TagMap = Map String [PagePath] -- | Read a TagMap, using the tags metadata field. readTagMap :: String -> [PagePath] -> Hakyll TagMap -- | Read a TagMap, using the subdirectories the pages are placed -- in. readCategoryMap :: String -> [PagePath] -> Hakyll TagMap -- | Render a tag cloud. renderTagCloud :: TagMap -> (String -> String) -> Float -> Float -> String -- | Render all tags to links. -- -- On your site, it is nice if you can display the tags on a page, but -- naturally, most people would expect these are clickable. -- -- So, this function takes a function to produce an url for a given tag, -- and applies it on all tags. -- -- Note that it is your own responsibility to ensure a page with such an -- url exists. renderTagLinks :: (String -> String) -> ContextManipulation -- | Module containing a small, simple http file server for testing and -- preview purposes. module Network.Hakyll.SimpleServer -- | Start a simple http server on the given PortNumber, serving the -- given directory. simpleServer :: PortNumber -> FilePath -> IO () instance Ord Response instance Eq Response instance Ord Request instance Eq Request instance Show Response instance Show Request module Text.Hakyll -- | Default hakyll configuration. defaultHakyllConfiguration :: HakyllConfiguration -- | Hakyll with a default configuration. hakyll :: Hakyll () -> IO () -- | Main function to run hakyll with a configuration. hakyllWithConfiguration :: HakyllConfiguration -> Hakyll () -> IO ()