-- 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 2.0 -- | This (quite small) module exports the datatype used for contexts. A -- Context is a simple key-value mapping. You can render these -- Contexts with templates, and manipulate them in various ways. module Text.Hakyll.Context -- | Datatype used for key-value mappings. type Context = Map String String -- | Module describing the Hakyll monad stack. module Text.Hakyll.HakyllMonad -- | Hakyll global configuration type. data HakyllConfiguration HakyllConfiguration :: String -> Context -> FilePath -> FilePath -> Bool -> Int -> HakyllConfiguration -- | Absolute URL of the site. absoluteUrl :: HakyllConfiguration -> String -- | 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 -- | Enable index links. enableIndexUrl :: HakyllConfiguration -> Bool -- | Delay between polls in preview mode. previewPollDelay :: HakyllConfiguration -> Int -- | Our custom monad stack. type Hakyll = ReaderT HakyllConfiguration IO -- | Simplified ask function for the Hakyll monad stack. -- -- Usage would typically be something like: -- --
-- doSomething :: a -> b -> Hakyll c -- doSomething arg1 arg2 = do -- siteDirectory' <- askHakyll siteDirectory -- ... --askHakyll :: (HakyllConfiguration -> a) -> Hakyll a getAdditionalContext :: HakyllConfiguration -> Context -- | 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. For most extensions, this would be the -- path itself. It's only for rendered extensions (.markdown, -- .rst, .lhs this function returns a path with a -- .html extension instead. toUrl :: FilePath -> Hakyll 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] -- | Perform a Hakyll action on every file in a given directory. directory :: (FilePath -> Hakyll ()) -> FilePath -> Hakyll () -- | Check if a timestamp is newer then a number of given files. isMoreRecent :: ClockTime -> [FilePath] -> Hakyll Bool -- | Check if a file is newer then a number of given files. isFileMoreRecent :: FilePath -> [FilePath] -> Hakyll Bool -- | This is the module which exports HakyllAction. module Text.Hakyll.HakyllAction -- | Type used for rendering computations that carry along dependencies. data HakyllAction a b HakyllAction :: [FilePath] -> Maybe (Hakyll FilePath) -> (a -> Hakyll b) -> HakyllAction a b -- | Dependencies of the HakyllAction. actionDependencies :: HakyllAction a b -> [FilePath] -- | URL pointing to the result of this HakyllAction. actionUrl :: HakyllAction a b -> Maybe (Hakyll FilePath) -- | The actual render function. actionFunction :: HakyllAction a b -> a -> Hakyll b -- | Create a HakyllAction from a function. createHakyllAction :: (a -> Hakyll b) -> HakyllAction a b -- | Create a HakyllAction from a simple Hakyll value. createSimpleHakyllAction :: Hakyll b -> HakyllAction () b -- | Create a HakyllAction that operates on one file. createFileHakyllAction :: FilePath -> Hakyll b -> HakyllAction () b -- | Chain a number of HakyllAction computations. chain :: [HakyllAction a a] -> HakyllAction a a -- | Run a HakyllAction now. runHakyllAction :: HakyllAction () a -> Hakyll a -- | Run a HakyllAction, but only when it is out-of-date. At this -- point, the actionUrl field must be set. runHakyllActionIfNeeded :: HakyllAction () () -> Hakyll () instance Arrow HakyllAction instance Category HakyllAction -- | 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 -- | This module exports a number of functions that produce -- HakyllActions to manipulate Contexts. module Text.Hakyll.ContextManipulations -- | Do something with a value in a Context, but keep the old -- value as well. If the key given is not present in the -- Context, nothing will happen. renderValue :: String -> String -> (String -> String) -> HakyllAction Context Context -- | Change a value in a Context. -- --
-- import Data.Char (toUpper) -- changeValue "title" (map toUpper) ---- -- Will put the title in UPPERCASE. changeValue :: String -> (String -> String) -> HakyllAction Context Context -- | Copy a value from one key to another in a Context. copyValue :: String -> String -> HakyllAction Context Context -- | When the context has a key called path in a -- folder/yyyy-mm-dd-title.extension format (the convention 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 -> HakyllAction Context Context -- | 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. -- --
-- changeExtension "php" ---- -- Will render test.markdown to test.php instead of -- test.html. changeExtension :: String -> HakyllAction Context Context -- | Change the body of a file using a certain manipulation. -- --
-- import Data.Char (toUpper) -- renderBody (map toUpper) ---- -- Will put the entire body of the page in UPPERCASE. renderBody :: (String -> String) -> HakyllAction Context Context -- | Module containing rendering functions. All these functions are used to -- render files to the _site directory. module Text.Hakyll.Render -- | This is the most simple render action. You render a Context -- with a template, and get back the result. render :: FilePath -> HakyllAction Context Context -- | Render each Context 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 :: [FilePath] -> HakyllAction () Context -> 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 () -- | Write a page to the site destination. Final action after render chains -- and such. writePage :: HakyllAction Context () -- | 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 that provides different ways to create a Context. -- These functions all use the HakyllAction arrow, so they -- produce values of the type HakyllAction () Context. module Text.Hakyll.CreateContext -- | Create a Context from a page file stored on the disk. This is -- probably the most common way to create a Context. createPage :: FilePath -> HakyllAction () Context -- | Create a custom page Context. -- -- The association list given maps keys to values for substitution. Note -- that as value, you can either give a String or a -- HakyllAction () String. The latter is preferred for more -- complex data, since it allows dependency checking. A String -- is obviously more simple to use in some cases. createCustomPage :: FilePath -> [(String, Either String (HakyllAction () String))] -> HakyllAction () Context -- | A createCustomPage function specialized in creating listings. -- -- This function creates a listing of a certain list of -- Contexts. 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. createListing :: FilePath -> [FilePath] -> [HakyllAction () Context] -> [(String, Either String (HakyllAction () String))] -> HakyllAction () Context -- | Combine two Contexts. The url will always be taken from the -- first Renderable. Also, if a `$key` is present in both -- renderables, the value from the first Context will be taken -- as well. -- -- You can see this as a this as a union between two mappings. combine :: HakyllAction () Context -> HakyllAction () Context -> HakyllAction () Context -- | Combine two Contexts and set a custom URL. This behaves like -- combine, except that for the url field, the given -- URL is always chosen. combineWithUrl :: FilePath -> HakyllAction () Context -> HakyllAction () Context -> HakyllAction () Context -- | A Module that allows easy rendering of RSS feeds. If you use this -- module, you must make sure you set the absoluteUrl field in the main -- Hakyll configuration. -- -- Apart from that, the main rendering functions (renderRss, -- renderAtom) all assume that you pass the list of items so -- that the most recent entry in the feed is the first item in the list. -- -- Also note that the Contexts should have (at least) the -- following fields to produce a correct feed: -- --
-- --- -- 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 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 [HakyllAction () Context] -- | Read a TagMap, using the tags metadata field. readTagMap :: String -> [FilePath] -> HakyllAction () TagMap -- | Read a TagMap, using the subdirectories the pages are placed -- in. readCategoryMap :: String -> [FilePath] -> HakyllAction () TagMap withTagMap :: HakyllAction () TagMap -> (String -> [HakyllAction () Context] -> Hakyll ()) -> Hakyll () -- | Render a tag cloud. renderTagCloud :: (String -> String) -> Float -> Float -> HakyllAction TagMap 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) -> HakyllAction Context Context -- | 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 -- | This is the main Hakyll module, exporting the important hakyl -- function. -- -- Most configurations would use this hakyll function more or -- less as the main function: -- --
-- main = hakyll $ do -- directory css "css" -- directory static "images" --module Text.Hakyll -- | The default hakyll configuration. defaultHakyllConfiguration :: HakyllConfiguration -- | Main function to run Hakyll with the default configuration. The -- absolute URL is only used in certain cases, for example RSS feeds et -- cetera. hakyll :: String -> Hakyll () -> IO () -- | Main function to run hakyll with a custom configuration. hakyllWithConfiguration :: HakyllConfiguration -> Hakyll () -> IO ()