-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Wiki using happstack, git or darcs, and pandoc. -- -- Gitit is a wiki backed by a git, darcs, or mercurial filestore. Pages -- and uploaded files can be modified either directly via the VCS's -- command-line tools or through the wiki's web interface. Pandoc is used -- for markup processing, so pages may be written in (extended) markdown, -- reStructuredText, LaTeX, HTML, or literate Haskell, and exported in -- ten different formats, including LaTeX, ConTeXt, DocBook, RTF, -- OpenOffice ODT, and MediaWiki markup. -- -- Notable features include -- -- -- -- You can see a running demo at http://gitit.net. -- -- For usage information: gitit --help @package gitit @version 0.12.2 module Paths_gitit version :: Version getBinDir :: IO FilePath getLibDir :: IO FilePath getDataDir :: IO FilePath getLibexecDir :: IO FilePath getDataFileName :: FilePath -> IO FilePath getSysconfDir :: IO FilePath module Network.Gitit.Server withExpiresHeaders :: ServerMonad m => m Response -> m Response setContentType :: String -> Response -> Response setFilename :: String -> Response -> Response lookupIPAddr :: String -> IO (Maybe String) getHost :: ServerMonad m => m (Maybe String) -- | reads the Accept-Encoding header. Then, if possible will -- compress the response body with methods gzip or -- deflate. -- -- This function uses standardEncodingHandlers. If you want to -- provide alternative handers (perhaps to change compression levels), -- see compressedResponseFilter' -- --
--   main =
--     simpleHTTP nullConf $
--        do str <- compressedResponseFilter
--           return $ toResponse ("This response compressed using: " ++ str)
--   
compressedResponseFilter :: (FilterMonad Response m, MonadPlus m, WebMonad Response m, ServerMonad m) => m String -- | Types for Gitit modules. module Network.Gitit.Types data PageType Markdown :: PageType CommonMark :: PageType RST :: PageType LaTeX :: PageType HTML :: PageType Textile :: PageType Org :: PageType DocBook :: PageType MediaWiki :: PageType data FileStoreType Git :: FileStoreType Darcs :: FileStoreType Mercurial :: FileStoreType data MathMethod MathML :: MathMethod JsMathScript :: MathMethod WebTeX :: String -> MathMethod RawTeX :: MathMethod MathJax :: String -> MathMethod data AuthenticationLevel Never :: AuthenticationLevel ForModify :: AuthenticationLevel ForRead :: AuthenticationLevel -- | Data structure for information read from config file. data Config Config :: FilePath -> FileStoreType -> PageType -> String -> MathMethod -> Bool -> Bool -> (Handler -> Handler) -> AuthenticationLevel -> Handler -> FilePath -> Int -> FilePath -> FilePath -> Priority -> FilePath -> [String] -> Bool -> Integer -> Integer -> String -> Int -> Bool -> String -> [String] -> [String] -> String -> String -> Maybe (String, [String]) -> Bool -> String -> String -> String -> String -> Bool -> Bool -> FilePath -> Map String String -> String -> String -> String -> Bool -> String -> Bool -> String -> Integer -> Integer -> Bool -> Maybe FilePath -> Bool -> Int -> GithubConfig -> Config -- | Path of repository containing filestore [repositoryPath] :: Config -> FilePath -- | Type of repository [repositoryType] :: Config -> FileStoreType -- | Default page markup type for this wiki [defaultPageType] :: Config -> PageType -- | Default file extension for pages in this wiki [defaultExtension] :: Config -> String -- | How to handle LaTeX math in pages? [mathMethod] :: Config -> MathMethod -- | Treat as literate haskell by default? [defaultLHS] :: Config -> Bool -- | Show Haskell code with bird tracks [showLHSBirdTracks] :: Config -> Bool -- | Combinator to set REMOTE_USER request header [withUser] :: Config -> Handler -> Handler -- | Handler for login, logout, register, etc. [requireAuthentication] :: Config -> AuthenticationLevel -- | Specifies which actions require authentication. [authHandler] :: Config -> Handler -- | Path of users database [userFile] :: Config -> FilePath -- | Seconds of inactivity before session expires [sessionTimeout] :: Config -> Int -- | Directory containing page templates [templatesDir] :: Config -> FilePath -- | Path of server log file [logFile] :: Config -> FilePath -- | Severity filter for log messages (DEBUG, INFO, NOTICE, WARNING, ERROR, -- CRITICAL, ALERT, EMERGENCY) [logLevel] :: Config -> Priority -- | Path of static directory [staticDir] :: Config -> FilePath -- | Names of plugin modules to load [pluginModules] :: Config -> [String] -- | Show table of contents on each page? [tableOfContents] :: Config -> Bool -- | Max size of file uploads [maxUploadSize] :: Config -> Integer -- | Max size of page uploads [maxPageSize] :: Config -> Integer -- | IP address to bind to [address] :: Config -> String -- | Port number to serve content on [portNumber] :: Config -> Int -- | Print debug info to the console? [debugMode] :: Config -> Bool -- | The front page of the wiki [frontPage] :: Config -> String -- | Pages that cannot be edited via web [noEdit] :: Config -> [String] -- | Pages that cannot be deleted via web [noDelete] :: Config -> [String] -- | Default summary if description left blank [defaultSummary] :: Config -> String -- | Delete summary [deleteSummary] :: Config -> String -- | Nothing = anyone can register. Just (prompt, -- answers) = a user will be given the prompt and must give one of -- the answers to register. [accessQuestion] :: Config -> Maybe (String, [String]) -- | Use ReCAPTCHA for user registration. [useRecaptcha] :: Config -> Bool [recaptchaPublicKey] :: Config -> String [recaptchaPrivateKey] :: Config -> String -- | RPX domain and key [rpxDomain] :: Config -> String [rpxKey] :: Config -> String -- | Should responses be compressed? [compressResponses] :: Config -> Bool -- | Should responses be cached? [useCache] :: Config -> Bool -- | Directory to hold cached pages [cacheDir] :: Config -> FilePath -- | Map associating mime types with file extensions [mimeMap] :: Config -> Map String String -- | Command to send notification emails [mailCommand] :: Config -> String -- | Text of password reset email [resetPasswordMessage] :: Config -> String -- | Markup syntax help for edit sidebar [markupHelp] :: Config -> String -- | Provide an atom feed? [useFeed] :: Config -> Bool -- | Base URL of wiki, for use in feed [baseUrl] :: Config -> String -- | Title of wiki, used in feed [useAbsoluteUrls] :: Config -> Bool -- | Should WikiLinks be absolute w.r.t. the base URL? [wikiTitle] :: Config -> String -- | Number of days history to be included in feed [feedDays] :: Config -> Integer -- | Number of minutes to cache feeds before refreshing [feedRefreshTime] :: Config -> Integer -- | Allow PDF export? [pdfExport] :: Config -> Bool -- | Directory to search for pandoc customizations [pandocUserData] :: Config -> Maybe FilePath -- | Filter HTML through xss-sanitize [xssSanitize] :: Config -> Bool -- | The default number of days in the past to look for "recent" activity [recentActivityDays] :: Config -> Int -- | Github client data for authentication (id, secret, callback, authorize -- endpoint, access token endpoint) [githubAuth] :: Config -> GithubConfig -- | Data for rendering a wiki page. data Page Page :: String -> PageType -> Bool -> Bool -> String -> [String] -> String -> [(String, String)] -> Page [pageName] :: Page -> String [pageFormat] :: Page -> PageType [pageLHS] :: Page -> Bool [pageTOC] :: Page -> Bool [pageTitle] :: Page -> String [pageCategories] :: Page -> [String] [pageText] :: Page -> String [pageMeta] :: Page -> [(String, String)] type SessionKey = Integer data SessionData sessionData :: String -> SessionData sessionDataGithubState :: String -> SessionData sessionUser :: SessionData -> Maybe String sessionGithubState :: SessionData -> Maybe String data User User :: String -> Password -> String -> User [uUsername] :: User -> String [uPassword] :: User -> Password [uEmail] :: User -> String data Sessions a Sessions :: Map SessionKey a -> Sessions a [unsession] :: Sessions a -> Map SessionKey a data Password Password :: String -> String -> Password [pSalt] :: Password -> String [pHashed] :: Password -> String -- | Common state for all gitit wikis in an application. data GititState GititState :: Sessions SessionData -> Map String User -> FilePath -> (PageLayout -> Html -> Handler) -> [Plugin] -> GititState [sessions] :: GititState -> Sessions SessionData [users] :: GititState -> Map String User [templatesPath] :: GititState -> FilePath [renderPage] :: GititState -> PageLayout -> Html -> Handler [plugins] :: GititState -> [Plugin] class (Monad m) => HasContext m getContext :: HasContext m => m Context modifyContext :: HasContext m => (Context -> Context) -> m () modifyContext :: HasContext m => (Context -> Context) -> m () getContext :: HasContext m => m Context type ContentTransformer = StateT Context GititServerPart data Plugin PageTransform :: (Pandoc -> PluginM Pandoc) -> Plugin PreParseTransform :: (String -> PluginM String) -> Plugin PreCommitTransform :: (String -> PluginM String) -> Plugin data PluginData PluginData :: Config -> Maybe User -> Request -> FileStore -> PluginData [pluginConfig] :: PluginData -> Config [pluginUser] :: PluginData -> Maybe User [pluginRequest] :: PluginData -> Request [pluginFileStore] :: PluginData -> FileStore type PluginM = ReaderT PluginData (StateT Context IO) runPluginM :: PluginM a -> PluginData -> Context -> IO (a, Context) data Context Context :: String -> PageLayout -> Bool -> Bool -> Bool -> [String] -> [(String, String)] -> Context [ctxFile] :: Context -> String [ctxLayout] :: Context -> PageLayout [ctxCacheable] :: Context -> Bool [ctxTOC] :: Context -> Bool [ctxBirdTracks] :: Context -> Bool [ctxCategories] :: Context -> [String] [ctxMeta] :: Context -> [(String, String)] -- | Abstract representation of page layout (tabs, scripts, etc.) data PageLayout PageLayout :: String -> Maybe String -> Bool -> [String] -> String -> [String] -> Bool -> Bool -> Maybe String -> [Tab] -> Tab -> Bool -> PageLayout [pgPageName] :: PageLayout -> String [pgRevision] :: PageLayout -> Maybe String [pgPrintable] :: PageLayout -> Bool [pgMessages] :: PageLayout -> [String] [pgTitle] :: PageLayout -> String [pgScripts] :: PageLayout -> [String] [pgShowPageTools] :: PageLayout -> Bool [pgShowSiteNav] :: PageLayout -> Bool [pgMarkupHelp] :: PageLayout -> Maybe String [pgTabs] :: PageLayout -> [Tab] [pgSelectedTab] :: PageLayout -> Tab [pgLinkToFeed] :: PageLayout -> Bool data Tab ViewTab :: Tab EditTab :: Tab HistoryTab :: Tab DiscussTab :: Tab DiffTab :: Tab data Recaptcha Recaptcha :: String -> String -> Recaptcha [recaptchaChallengeField] :: Recaptcha -> String [recaptchaResponseField] :: Recaptcha -> String data Params Params :: String -> String -> String -> Maybe String -> String -> Maybe String -> Maybe UTCTime -> String -> Int -> [String] -> String -> String -> Maybe String -> [String] -> Maybe String -> Maybe String -> String -> String -> String -> String -> String -> String -> String -> Bool -> Bool -> String -> FilePath -> Bool -> Maybe SessionKey -> Recaptcha -> String -> Maybe Bool -> Params [pUsername] :: Params -> String [pPassword] :: Params -> String [pPassword2] :: Params -> String [pRevision] :: Params -> Maybe String [pDestination] :: Params -> String [pForUser] :: Params -> Maybe String [pSince] :: Params -> Maybe UTCTime [pRaw] :: Params -> String [pLimit] :: Params -> Int [pPatterns] :: Params -> [String] [pGotoPage] :: Params -> String [pFileToDelete] :: Params -> String [pEditedText] :: Params -> Maybe String [pMessages] :: Params -> [String] [pFrom] :: Params -> Maybe String [pTo] :: Params -> Maybe String [pFormat] :: Params -> String [pSHA1] :: Params -> String [pLogMsg] :: Params -> String [pEmail] :: Params -> String [pFullName] :: Params -> String [pAccessCode] :: Params -> String [pWikiname] :: Params -> String [pPrintable] :: Params -> Bool [pOverwrite] :: Params -> Bool [pFilename] :: Params -> String [pFilePath] :: Params -> FilePath [pConfirm] :: Params -> Bool [pSessionKey] :: Params -> Maybe SessionKey [pRecaptcha] :: Params -> Recaptcha [pResetCode] :: Params -> String [pRedirect] :: Params -> Maybe Bool data Command Command :: (Maybe String) -> Command -- | State for a single wiki. data WikiState WikiState :: Config -> FileStore -> WikiState [wikiConfig] :: WikiState -> Config [wikiFileStore] :: WikiState -> FileStore type GititServerPart = ServerPartT (ReaderT WikiState IO) type Handler = GititServerPart Response fromEntities :: String -> String data GithubConfig oAuth2 :: GithubConfig -> OAuth2 org :: GithubConfig -> Maybe Text githubConfig :: OAuth2 -> Maybe Text -> GithubConfig instance GHC.Show.Show Network.Gitit.Types.Command instance GHC.Show.Show Network.Gitit.Types.Params instance GHC.Show.Show Network.Gitit.Types.Recaptcha instance GHC.Read.Read Network.Gitit.Types.Recaptcha instance GHC.Show.Show Network.Gitit.Types.Tab instance GHC.Classes.Eq Network.Gitit.Types.Tab instance GHC.Read.Read Network.Gitit.Types.User instance GHC.Show.Show Network.Gitit.Types.User instance GHC.Classes.Eq Network.Gitit.Types.Password instance GHC.Show.Show Network.Gitit.Types.Password instance GHC.Read.Read Network.Gitit.Types.Password instance GHC.Classes.Eq a => GHC.Classes.Eq (Network.Gitit.Types.Sessions a) instance GHC.Show.Show a => GHC.Show.Show (Network.Gitit.Types.Sessions a) instance GHC.Read.Read a => GHC.Read.Read (Network.Gitit.Types.Sessions a) instance GHC.Classes.Eq Network.Gitit.Types.SessionData instance GHC.Show.Show Network.Gitit.Types.SessionData instance GHC.Read.Read Network.Gitit.Types.SessionData instance GHC.Show.Show Network.Gitit.Types.Page instance GHC.Read.Read Network.Gitit.Types.Page instance GHC.Classes.Ord Network.Gitit.Types.AuthenticationLevel instance GHC.Classes.Eq Network.Gitit.Types.AuthenticationLevel instance GHC.Show.Show Network.Gitit.Types.AuthenticationLevel instance GHC.Read.Read Network.Gitit.Types.AuthenticationLevel instance GHC.Classes.Eq Network.Gitit.Types.MathMethod instance GHC.Show.Show Network.Gitit.Types.MathMethod instance GHC.Read.Read Network.Gitit.Types.MathMethod instance GHC.Show.Show Network.Gitit.Types.FileStoreType instance GHC.Classes.Eq Network.Gitit.Types.PageType instance GHC.Show.Show Network.Gitit.Types.PageType instance GHC.Read.Read Network.Gitit.Types.PageType instance Network.Gitit.Types.HasContext Network.Gitit.Types.ContentTransformer instance Network.Gitit.Types.HasContext Network.Gitit.Types.PluginM instance Happstack.Server.RqData.FromData Network.Gitit.Types.SessionKey instance Happstack.Server.Internal.Types.FromReqURI [GHC.Base.String] instance Happstack.Server.RqData.FromData Network.Gitit.Types.Params instance Happstack.Server.RqData.FromData Network.Gitit.Types.Command module Network.Gitit.State gititstate :: IORef GititState updateGititState :: MonadIO m => (GititState -> GititState) -> m () queryGititState :: MonadIO m => (GititState -> a) -> m a debugMessage :: String -> GititServerPart () mkUser :: String -> String -> String -> IO User genSalt :: IO String hashPassword :: String -> String -> String authUser :: String -> String -> GititServerPart Bool isUser :: String -> GititServerPart Bool addUser :: String -> User -> GititServerPart () adjustUser :: String -> User -> GititServerPart () delUser :: String -> GititServerPart () writeUserFile :: Config -> IO () getUser :: String -> GititServerPart (Maybe User) isSession :: MonadIO m => SessionKey -> m Bool setSession :: MonadIO m => SessionKey -> SessionData -> m () newSession :: MonadIO m => SessionData -> m SessionKey delSession :: MonadIO m => SessionKey -> m () getSession :: MonadIO m => SessionKey -> m (Maybe SessionData) getConfig :: GititServerPart Config getFileStore :: GititServerPart FileStore getDefaultPageType :: GititServerPart PageType getDefaultLHS :: GititServerPart Bool module Network.Gitit.Util -- | Read file as UTF-8 string. Encode filename as UTF-8. readFileUTF8 :: FilePath -> IO String -- | Perform a function a directory and return to working directory. inDir :: FilePath -> IO a -> IO a -- | Perform a function in a temporary directory and clean up. withTempDir :: FilePath -> (FilePath -> IO a) -> IO a -- | Returns a list, if it is not null, or a backup, if it is. orIfNull :: [a] -> [a] -> [a] -- | Split a string containing a list of categories. splitCategories :: String -> [String] -- | Trim leading and trailing spaces. trim :: String -> String -- | Show Bool as "yes" or "no". yesOrNo :: Bool -> String parsePageType :: String -> (PageType, Bool) encUrl :: String -> String module Network.Gitit.Rpxnow -- | Information received from Rpxnow after a valid login. data Identifier Identifier :: String -> [(String, String)] -> Identifier [userIdentifier] :: Identifier -> String [userData] :: Identifier -> [(String, String)] -- | Attempt to log a user in. authenticate :: Monad m => String -> String -> IO (m Identifier) instance GHC.Show.Show Network.Gitit.Rpxnow.Identifier module Network.Gitit.Plugins loadPlugin :: FilePath -> IO Plugin loadPlugins :: [FilePath] -> IO [Plugin] module Network.Gitit.Page -- | Read a string (the contents of a page file) and produce a Page object, -- using defaults except when overridden by metadata. stringToPage :: Config -> String -> String -> Page -- | Write a string (the contents of a page file) corresponding to a Page -- object, using explicit metadata only when needed. pageToString :: Config -> Page -> String -- | Read categories from metadata strictly. readCategories :: FilePath -> IO [String] -- | Useful functions for defining wiki handlers. module Network.Gitit.Framework -- | Run the handler after setting REMOTE_USER with the user from -- the session. withUserFromSession :: Handler -> Handler -- | Run the handler after setting REMOTE_USER from the -- "authorization" header. Works with simple HTTP authentication or -- digest authentication. withUserFromHTTPAuth :: Handler -> Handler -- | Like authenticate, but with a predicate that the user must -- satisfy. authenticateUserThat :: (User -> Bool) -> AuthenticationLevel -> Handler -> Handler -- | Require a logged in user if the authentication level demands it. Run -- the handler if a user is logged in, otherwise redirect to login page. authenticate :: AuthenticationLevel -> Handler -> Handler -- | Returns Just logged in user or Nothing. getLoggedInUser :: GititServerPart (Maybe User) -- | unlessNoEdit responder fallback runs responder -- unless the page has been designated not editable in configuration; in -- that case, runs fallback. unlessNoEdit :: Handler -> Handler -> Handler -- | unlessNoDelete responder fallback runs responder -- unless the page has been designated not deletable in configuration; in -- that case, runs fallback. unlessNoDelete :: Handler -> Handler -> Handler guardCommand :: String -> GititServerPart () guardPath :: (String -> Bool) -> GititServerPart () -- | Succeeds if path is an index path: e.g. /foo/bar/. guardIndex :: GititServerPart () guardBareBase :: GititServerPart () -- | Returns the current path (subtracting initial commands like -- /_edit). getPath :: ServerMonad m => m String -- | Returns the current page name (derived from the path). getPage :: GititServerPart String -- | Returns the contents of the "referer" header. getReferer :: ServerMonad m => m String -- | Returns the base URL of the wiki in the happstack server. So, if the -- wiki handlers are behind a dir foo, getWikiBase will -- return /foo/. getWikiBase doesn't know anything about HTTP -- proxies, so if you use proxies to map a gitit wiki to /foo/, -- you'll still need to follow the instructions in README. getWikiBase :: ServerMonad m => m String -- | Returns path portion of URI, without initial /. Consecutive -- spaces are collapsed. We don't want to distinguish Hi There -- and Hi There. uriPath :: String -> String isPage :: String -> Bool isPageFile :: FilePath -> GititServerPart Bool isDiscussPage :: String -> Bool isDiscussPageFile :: FilePath -> GititServerPart Bool isNotDiscussPageFile :: FilePath -> GititServerPart Bool isSourceCode :: String -> Bool -- | Runs a server monad in a local context after setting the "message" -- request header. withMessages :: ServerMonad m => [String] -> m a -> m a -- | Returns encoded URL path for the page with the given name, relative to -- the wiki base. urlForPage :: String -> String -- | Returns the filestore path of the file containing the page's source. pathForPage :: String -> String -> FilePath -- | Retrieves a mime type based on file extension. getMimeTypeForExtension :: String -> GititServerPart String -- | Simple helper for validation of forms. validate :: [(Bool, String)] -> [String] -- | Returns a filestore object derived from the repository path and -- filestore type specified in configuration. filestoreFromConfig :: Config -> FileStore -- | Functions for creating Atom feeds for Gitit wikis and pages. module Network.Gitit.Feed data FeedConfig FeedConfig :: String -> String -> Integer -> FeedConfig [fcTitle] :: FeedConfig -> String [fcBaseUrl] :: FeedConfig -> String [fcFeedDays] :: FeedConfig -> Integer filestoreToXmlFeed :: FeedConfig -> FileStore -> Maybe FilePath -> IO String instance GHC.Show.Show Network.Gitit.Feed.FeedConfig instance GHC.Read.Read Network.Gitit.Feed.FeedConfig module Network.Gitit.Compat.Except -- | A monad transformer that adds exceptions to other monads. -- -- ExceptT constructs a monad parameterized over two things: -- -- -- -- The return function yields a computation that produces the -- given value, while >>= sequences two subcomputations, -- exiting on the first exception. data ExceptT e (m :: * -> *) a :: * -> (* -> *) -> * -> * -- | The parameterizable exception monad. -- -- Computations are either exceptions or normal values. -- -- The return function returns a normal value, while -- >>= exits on the first exception. For a variant that -- continues after an error and collects all the errors, see -- Errors. type Except e = ExceptT e Identity class Error a where noMsg = strMsg "" strMsg _ = noMsg noMsg :: Error a => a strMsg :: Error a => String -> a -- | The inverse of ExceptT. runExceptT :: ExceptT e m a -> m (Either e a) -- | Extractor for computations in the exception monad. (The inverse of -- except). runExcept :: Except e a -> Either e a -- | The strategy of combining computations that can throw exceptions by -- bypassing bound functions from the point an exception is thrown to the -- point that it is handled. -- -- Is parameterized over the type of error information and the monad type -- constructor. It is common to use Either String as the -- monad type constructor for an error monad in which error descriptions -- take the form of strings. In that case and many other common cases the -- resulting monad is already defined as an instance of the -- MonadError class. You can also define your own error type -- and/or use a monad type constructor other than Either -- String or Either IOError. In -- these cases you will have to explicitly define instances of the -- Error and/or MonadError classes. class Monad m => MonadError e (m :: * -> *) | m -> e -- | Is used within a monadic computation to begin exception processing. throwError :: MonadError e m => e -> m a -- | A handler function to handle previous errors and return to normal -- execution. A common idiom is: -- --
--   do { action1; action2; action3 } `catchError` handler
--   
-- -- where the action functions can call throwError. Note -- that handler and the do-block must have the same return type. catchError :: MonadError e m => m a -> (e -> m a) -> m a -- | Is used within a monadic computation to begin exception processing. throwError :: MonadError e m => forall a. e -> m a -- | A handler function to handle previous errors and return to normal -- execution. A common idiom is: -- --
--   do { action1; action2; action3 } `catchError` handler
--   
-- -- where the action functions can call throwError. Note -- that handler and the do-block must have the same return type. catchError :: MonadError e m => forall a. m a -> (e -> m a) -> m a module Network.Gitit.Cache -- | Expire a cached file, identified by its filename in the filestore. If -- there is an associated exported PDF, expire it too. Returns () after -- deleting a file from the cache, fails if no cached file. expireCachedFile :: String -> GititServerPart () lookupCache :: String -> GititServerPart (Maybe (UTCTime, ByteString)) cacheContents :: String -> ByteString -> GititServerPart () module Network.Gitit.Export exportFormats :: Config -> [(String, String -> Pandoc -> Handler)] module Network.Gitit.Layout defaultPageLayout :: PageLayout -- | Given a compiled string template, returns a page renderer. defaultRenderPage :: StringTemplate String -> PageLayout -> Html -> Handler -- | Returns formatted page formattedPage :: PageLayout -> Html -> Handler -- | Returns a page template with gitit variables filled in. filledPageTemplate :: String -> Config -> PageLayout -> Html -> StringTemplate String -> StringTemplate String uploadsAllowed :: Config -> Bool module Network.Gitit.ContentTransformer runPageTransformer :: ToMessage a => ContentTransformer a -> GititServerPart a runFileTransformer :: ToMessage a => ContentTransformer a -> GititServerPart a -- | Converts a ContentTransformer into a -- GititServerPart; specialized to wiki pages. -- runPageTransformer :: ToMessage a => ContentTransformer a -> -- GititServerPart a runPageTransformer = runTransformer pathForPage -- -- Converts a ContentTransformer into a -- GititServerPart; specialized to non-pages. runFileTransformer -- :: ToMessage a => ContentTransformer a -> GititServerPart a -- runFileTransformer = runTransformer id -- -- Responds with raw page source. showRawPage :: Handler -- | Responds with raw source (for non-pages such as source code files). showFileAsText :: Handler -- | Responds with rendered wiki page. showPage :: Handler -- | Responds with page exported into selected format. exportPage :: Handler -- | Responds with highlighted source code. showHighlightedSource :: Handler -- | Responds with non-highlighted source code. showFile :: Handler -- | Responds with rendered page derived from form data. preview :: Handler -- | Applies pre-commit plugins to raw page source, possibly modifying it. applyPreCommitPlugins :: String -> GititServerPart String -- | Caches a response (actually just the response body) on disk, unless -- the context indicates that the page is not cacheable. cacheHtml :: Response -> ContentTransformer Response -- | Returns cached page if available, otherwise mzero. cachedHtml :: ContentTransformer Response -- | Returns raw file contents. rawContents :: ContentTransformer (Maybe String) -- | Converts raw contents to a text/plain response. textResponse :: Maybe String -> ContentTransformer Response -- | Converts raw contents to a response that is appropriate with a mime -- type derived from the page's extension. mimeFileResponse :: Maybe String -> ContentTransformer Response mimeResponse :: Monad m => String -> String -> m Response -- | Converts Pandoc to response using format specified in parameters. exportPandoc :: Pandoc -> ContentTransformer Response -- | Adds the sidebar, page tabs, and other elements of the wiki page -- layout to the raw content. applyWikiTemplate :: Html -> ContentTransformer Response -- | Converts Page to Pandoc, applies page transforms, and adds page title. pageToWikiPandoc :: Page -> ContentTransformer Pandoc -- | Converts source text to Pandoc using default page type. pageToPandoc :: Page -> ContentTransformer Pandoc -- | Converts pandoc document to HTML. pandocToHtml :: Pandoc -> ContentTransformer Html -- | Returns highlighted source code. highlightSource :: Maybe String -> ContentTransformer Html -- | Applies all the page transform plugins to a Pandoc document. applyPageTransforms :: Pandoc -> ContentTransformer Pandoc -- | Puts rendered page content into a wikipage div, adding categories. wikiDivify :: Html -> ContentTransformer Html -- | Adds page title to a Pandoc document. addPageTitleToPandoc :: String -> Pandoc -> ContentTransformer Pandoc -- | Adds javascript links for math support. addMathSupport :: a -> ContentTransformer a -- | Adds javascripts to page layout. addScripts :: PageLayout -> [String] -> PageLayout getFileName :: ContentTransformer FilePath getPageName :: ContentTransformer String getLayout :: ContentTransformer PageLayout getParams :: ContentTransformer Params getCacheable :: ContentTransformer Bool -- | Derives a URL from a list of Pandoc Inline elements. inlinesToURL :: [Inline] -> String -- | Convert a list of inlines into a string. inlinesToString :: [Inline] -> String -- | Interface for plugins. -- -- A plugin is a Haskell module that is dynamically loaded by gitit. -- -- There are three kinds of plugins: PageTransforms, -- PreParseTransforms, and PreCommitTransforms. These -- plugins differ chiefly in where they are applied. -- PreCommitTransform plugins are applied just before changes to a -- page are saved and may transform the raw source that is saved. -- PreParseTransform plugins are applied when a page is viewed and -- may alter the raw page source before it is parsed as a Pandoc -- document. Finally, PageTransform plugins modify the -- Pandoc document that results after a page's source is parsed, -- but before it is converted to HTML: -- --
--      +--------------------------+
--      | edited text from browser |
--      +--------------------------+
--                   ||         <----  PreCommitTransform plugins
--                   \/
--                   ||         <----  saved to repository
--                   \/
--   +---------------------------------+
--   | raw page source from repository |
--   +---------------------------------+
--                   ||         <----  PreParseTransform plugins
--                   \/
--                   ||         <----  markdown or RST reader
--                   \/
--          +-----------------+
--          | Pandoc document |
--          +-----------------+
--                   ||         <---- PageTransform plugins
--                   \/
--        +---------------------+
--        | new Pandoc document |
--        +---------------------+
--                   ||         <---- HTML writer
--                   \/
--        +----------------------+
--        | HTML version of page |
--        +----------------------+
--   
-- -- Note that PreParseTransform and PageTransform plugins do -- not alter the page source stored in the repository. They only affect -- what is visible on the website. Only PreCommitTransform plugins -- can alter what is stored in the repository. -- -- Note also that PreParseTransform and PageTransform -- plugins will not be run when the cached version of a page is used. -- Plugins can use the doNotCache command to prevent a page from -- being cached, if their behavior is sensitive to things that might -- change from one time to another (such as the time or currently -- logged-in user). -- -- You can use the helper functions mkPageTransform and -- mkPageTransformM to create PageTransform plugins from a -- transformation of any of the basic types used by Pandoc (for example, -- Inline, Block, [Inline], even -- String). Here is a simple (if silly) example: -- --
--   -- Deprofanizer.hs
--   module Deprofanizer (plugin) where
--   
--   -- This plugin replaces profane words with "XXXXX".
--   
--   import Network.Gitit.Interface
--   import Data.Char (toLower)
--   
--   plugin :: Plugin
--   plugin = mkPageTransform deprofanize
--   
--   deprofanize :: Inline -> Inline
--   deprofanize (Str x) | isBadWord x = Str "XXXXX"
--   deprofanize x                     = x
--   
--   isBadWord :: String -> Bool
--   isBadWord x = (map toLower x) `elem` ["darn", "blasted", "stinker"]
--   -- there are more, but this is a family program
--   
-- -- Further examples can be found in the plugins directory in the -- source distribution. If you have installed gitit using Cabal, you can -- also find them in the directory -- CABALDIR/share/gitit-X.Y.Z/plugins, where CABALDIR -- is the cabal install directory and X.Y.Z is the version -- number of gitit. module Network.Gitit.Interface data Plugin PageTransform :: (Pandoc -> PluginM Pandoc) -> Plugin PreParseTransform :: (String -> PluginM String) -> Plugin PreCommitTransform :: (String -> PluginM String) -> Plugin type PluginM = ReaderT PluginData (StateT Context IO) -- | Lifts a function from a -> a (for example, Inline -- -> Inline, Block -> Block, [Inline] -> -- [Inline], or String -> String) to a -- PageTransform plugin. mkPageTransform :: Data a => (a -> a) -> Plugin -- | Monadic version of mkPageTransform. Lifts a function from a -- -> m a to a PageTransform plugin. mkPageTransformM :: Data a => (a -> PluginM a) -> Plugin -- | Data structure for information read from config file. data Config Config :: FilePath -> FileStoreType -> PageType -> String -> MathMethod -> Bool -> Bool -> (Handler -> Handler) -> AuthenticationLevel -> Handler -> FilePath -> Int -> FilePath -> FilePath -> Priority -> FilePath -> [String] -> Bool -> Integer -> Integer -> String -> Int -> Bool -> String -> [String] -> [String] -> String -> String -> Maybe (String, [String]) -> Bool -> String -> String -> String -> String -> Bool -> Bool -> FilePath -> Map String String -> String -> String -> String -> Bool -> String -> Bool -> String -> Integer -> Integer -> Bool -> Maybe FilePath -> Bool -> Int -> GithubConfig -> Config -- | Path of repository containing filestore [repositoryPath] :: Config -> FilePath -- | Type of repository [repositoryType] :: Config -> FileStoreType -- | Default page markup type for this wiki [defaultPageType] :: Config -> PageType -- | Default file extension for pages in this wiki [defaultExtension] :: Config -> String -- | How to handle LaTeX math in pages? [mathMethod] :: Config -> MathMethod -- | Treat as literate haskell by default? [defaultLHS] :: Config -> Bool -- | Show Haskell code with bird tracks [showLHSBirdTracks] :: Config -> Bool -- | Combinator to set REMOTE_USER request header [withUser] :: Config -> Handler -> Handler -- | Handler for login, logout, register, etc. [requireAuthentication] :: Config -> AuthenticationLevel -- | Specifies which actions require authentication. [authHandler] :: Config -> Handler -- | Path of users database [userFile] :: Config -> FilePath -- | Seconds of inactivity before session expires [sessionTimeout] :: Config -> Int -- | Directory containing page templates [templatesDir] :: Config -> FilePath -- | Path of server log file [logFile] :: Config -> FilePath -- | Severity filter for log messages (DEBUG, INFO, NOTICE, WARNING, ERROR, -- CRITICAL, ALERT, EMERGENCY) [logLevel] :: Config -> Priority -- | Path of static directory [staticDir] :: Config -> FilePath -- | Names of plugin modules to load [pluginModules] :: Config -> [String] -- | Show table of contents on each page? [tableOfContents] :: Config -> Bool -- | Max size of file uploads [maxUploadSize] :: Config -> Integer -- | Max size of page uploads [maxPageSize] :: Config -> Integer -- | IP address to bind to [address] :: Config -> String -- | Port number to serve content on [portNumber] :: Config -> Int -- | Print debug info to the console? [debugMode] :: Config -> Bool -- | The front page of the wiki [frontPage] :: Config -> String -- | Pages that cannot be edited via web [noEdit] :: Config -> [String] -- | Pages that cannot be deleted via web [noDelete] :: Config -> [String] -- | Default summary if description left blank [defaultSummary] :: Config -> String -- | Delete summary [deleteSummary] :: Config -> String -- | Nothing = anyone can register. Just (prompt, -- answers) = a user will be given the prompt and must give one of -- the answers to register. [accessQuestion] :: Config -> Maybe (String, [String]) -- | Use ReCAPTCHA for user registration. [useRecaptcha] :: Config -> Bool [recaptchaPublicKey] :: Config -> String [recaptchaPrivateKey] :: Config -> String -- | RPX domain and key [rpxDomain] :: Config -> String [rpxKey] :: Config -> String -- | Should responses be compressed? [compressResponses] :: Config -> Bool -- | Should responses be cached? [useCache] :: Config -> Bool -- | Directory to hold cached pages [cacheDir] :: Config -> FilePath -- | Map associating mime types with file extensions [mimeMap] :: Config -> Map String String -- | Command to send notification emails [mailCommand] :: Config -> String -- | Text of password reset email [resetPasswordMessage] :: Config -> String -- | Markup syntax help for edit sidebar [markupHelp] :: Config -> String -- | Provide an atom feed? [useFeed] :: Config -> Bool -- | Base URL of wiki, for use in feed [baseUrl] :: Config -> String -- | Title of wiki, used in feed [useAbsoluteUrls] :: Config -> Bool -- | Should WikiLinks be absolute w.r.t. the base URL? [wikiTitle] :: Config -> String -- | Number of days history to be included in feed [feedDays] :: Config -> Integer -- | Number of minutes to cache feeds before refreshing [feedRefreshTime] :: Config -> Integer -- | Allow PDF export? [pdfExport] :: Config -> Bool -- | Directory to search for pandoc customizations [pandocUserData] :: Config -> Maybe FilePath -- | Filter HTML through xss-sanitize [xssSanitize] :: Config -> Bool -- | The default number of days in the past to look for "recent" activity [recentActivityDays] :: Config -> Int -- | Github client data for authentication (id, secret, callback, authorize -- endpoint, access token endpoint) [githubAuth] :: Config -> GithubConfig -- | an HTTP request data Request :: * Request :: Bool -> Method -> [String] -> String -> String -> [(String, Input)] -> MVar [(String, Input)] -> [(String, Cookie)] -> HttpVersion -> Headers -> MVar RqBody -> Host -> Request -- | request uses https:// [rqSecure] :: Request -> Bool -- | request method [rqMethod] :: Request -> Method -- | the uri, split on /, and then decoded [rqPaths] :: Request -> [String] -- | the raw rqUri [rqUri] :: Request -> String -- | the QUERY_STRING [rqQuery] :: Request -> String -- | the QUERY_STRING decoded as key/value pairs [rqInputsQuery] :: Request -> [(String, Input)] -- | the request body decoded as key/value pairs (when appropriate) [rqInputsBody] :: Request -> MVar [(String, Input)] -- | cookies [rqCookies] :: Request -> [(String, Cookie)] -- | HTTP version [rqVersion] :: Request -> HttpVersion -- | the HTTP request headers [rqHeaders] :: Request -> Headers -- | the raw, undecoded request body [rqBody] :: Request -> MVar RqBody -- | (hostname, port) of the client making the request [rqPeer] :: Request -> Host data User User :: String -> Password -> String -> User [uUsername] :: User -> String [uPassword] :: User -> Password [uEmail] :: User -> String data Context Context :: String -> PageLayout -> Bool -> Bool -> Bool -> [String] -> [(String, String)] -> Context [ctxFile] :: Context -> String [ctxLayout] :: Context -> PageLayout [ctxCacheable] :: Context -> Bool [ctxTOC] :: Context -> Bool [ctxBirdTracks] :: Context -> Bool [ctxCategories] :: Context -> [String] [ctxMeta] :: Context -> [(String, String)] data PageType Markdown :: PageType CommonMark :: PageType RST :: PageType LaTeX :: PageType HTML :: PageType Textile :: PageType Org :: PageType DocBook :: PageType MediaWiki :: PageType -- | Abstract representation of page layout (tabs, scripts, etc.) data PageLayout PageLayout :: String -> Maybe String -> Bool -> [String] -> String -> [String] -> Bool -> Bool -> Maybe String -> [Tab] -> Tab -> Bool -> PageLayout [pgPageName] :: PageLayout -> String [pgRevision] :: PageLayout -> Maybe String [pgPrintable] :: PageLayout -> Bool [pgMessages] :: PageLayout -> [String] [pgTitle] :: PageLayout -> String [pgScripts] :: PageLayout -> [String] [pgShowPageTools] :: PageLayout -> Bool [pgShowSiteNav] :: PageLayout -> Bool [pgMarkupHelp] :: PageLayout -> Maybe String [pgTabs] :: PageLayout -> [Tab] [pgSelectedTab] :: PageLayout -> Tab [pgLinkToFeed] :: PageLayout -> Bool -- | Returns the current wiki configuration. askConfig :: PluginM Config -- | Returns Just the logged in user, or Nothing if -- nobody is logged in. askUser :: PluginM (Maybe User) -- | Returns the complete HTTP request. askRequest :: PluginM Request -- | Returns the wiki filestore. askFileStore :: PluginM FileStore -- | Returns the page meta data askMeta :: PluginM [(String, String)] -- | Indicates that the current page or file is not to be cached. doNotCache :: PluginM () getContext :: HasContext m => m Context modifyContext :: HasContext m => (Context -> Context) -> m () -- | Derives a URL from a list of Pandoc Inline elements. inlinesToURL :: [Inline] -> String -- | Convert a list of inlines into a string. inlinesToString :: [Inline] -> String -- | Lift a computation from the IO monad. liftIO :: MonadIO m => forall a. IO a -> m a -- | Perform a function in a temporary directory and clean up. withTempDir :: FilePath -> (FilePath -> IO a) -> IO a -- | Functions for initializing a Gitit wiki. module Network.Gitit.Initialize -- | Initialize Gitit State. initializeGititState :: Config -> IO () -- | Recompile the page template. recompilePageTemplate :: IO () compilePageTemplate :: FilePath -> IO (StringTemplate String) -- | Create static directory unless it exists. createStaticIfMissing :: Config -> IO () -- | Create page repository unless it exists. createRepoIfMissing :: Config -> IO () createDefaultPages :: Config -> IO () -- | Create templates dir if it doesn't exist. createTemplateIfMissing :: Config -> IO () module Network.Gitit.Handlers handleAny :: Handler debugHandler :: Handler randomPage :: Handler discussPage :: Handler createPage :: Handler showActivity :: Handler goToPage :: Handler searchResults :: Handler uploadForm :: Handler uploadFile :: Handler indexPage :: Handler categoryPage :: Handler categoryListPage :: Handler -- | Responds with rendered page derived from form data. preview :: Handler -- | Converts a ContentTransformer into a -- GititServerPart; specialized to wiki pages. -- runPageTransformer :: ToMessage a => ContentTransformer a -> -- GititServerPart a runPageTransformer = runTransformer pathForPage -- -- Converts a ContentTransformer into a -- GititServerPart; specialized to non-pages. runFileTransformer -- :: ToMessage a => ContentTransformer a -> GititServerPart a -- runFileTransformer = runTransformer id -- -- Responds with raw page source. showRawPage :: Handler -- | Responds with raw source (for non-pages such as source code files). showFileAsText :: Handler showPageHistory :: Handler showFileHistory :: Handler -- | Responds with rendered wiki page. showPage :: Handler showPageDiff :: Handler showFileDiff :: Handler -- | Responds with page exported into selected format. exportPage :: Handler updatePage :: Handler editPage :: Handler deletePage :: Handler confirmDelete :: Handler -- | Responds with highlighted source code. showHighlightedSource :: Handler expireCache :: Handler feedHandler :: Handler module Network.Gitit.Authentication.Github loginGithubUser :: OAuth2 -> Handler getGithubUser :: GithubConfig -> GithubCallbackPars -> String -> GititServerPart (Either GithubLoginError User) data GithubCallbackPars data GithubLoginError ghUserMessage :: GithubLoginError -> String ghDetails :: GithubLoginError -> Maybe String instance GHC.Classes.Eq Network.Gitit.Authentication.Github.GithubUserMail instance GHC.Show.Show Network.Gitit.Authentication.Github.GithubUserMail instance GHC.Classes.Eq Network.Gitit.Authentication.Github.GithubUser instance GHC.Show.Show Network.Gitit.Authentication.Github.GithubUser instance GHC.Show.Show Network.Gitit.Authentication.Github.GithubCallbackPars instance Happstack.Server.RqData.FromData Network.Gitit.Authentication.Github.GithubCallbackPars instance Data.Aeson.Types.FromJSON.FromJSON Network.Gitit.Authentication.Github.GithubUser instance Data.Aeson.Types.FromJSON.FromJSON Network.Gitit.Authentication.Github.GithubUserMail module Network.Gitit.Authentication loginUserForm :: Handler formAuthHandlers :: [Handler] httpAuthHandlers :: [Handler] rpxAuthHandlers :: [Handler] githubAuthHandlers :: GithubConfig -> [Handler] instance GHC.Show.Show Network.Gitit.Authentication.RPars instance GHC.Read.Read Network.Gitit.Authentication.ValidationType instance GHC.Show.Show Network.Gitit.Authentication.ValidationType instance Happstack.Server.RqData.FromData Network.Gitit.Authentication.RPars -- | Functions for parsing command line options and reading the config -- file. module Network.Gitit.Config -- | Get configuration from config file. getConfigFromFile :: FilePath -> IO Config -- | Get configuration from config files. getConfigFromFiles :: [FilePath] -> IO Config -- | Returns the default gitit configuration. getDefaultConfig :: IO Config -- | Read a file associating mime types with extensions, and return a map -- from extensions to types. Each line of the file consists of a mime -- type, followed by space, followed by a list of zero or more -- extensions, separated by spaces. Example: text/plain txt text readMimeTypesFile :: FilePath -> IO (Map String String) -- | Functions for embedding a gitit wiki into a Happstack application. -- -- The following is a minimal standalone wiki program: -- --
--   import Network.Gitit
--   import Happstack.Server.SimpleHTTP
--   
--   main = do
--     conf <- getDefaultConfig
--     createStaticIfMissing conf
--     createTemplateIfMissing conf
--     createRepoIfMissing conf
--     initializeGititState conf
--     simpleHTTP nullConf{port = 5001} $ wiki conf
--   
-- -- Here is a more complex example, which serves different wikis under -- different paths, and uses a custom authentication scheme: -- --
--   import Network.Gitit
--   import Control.Monad
--   import Text.XHtml hiding (dir)
--   import Happstack.Server.SimpleHTTP
--   
--   type WikiSpec = (String, FileStoreType, PageType)
--   
--   wikis = [ ("markdownWiki", Git, Markdown)
--           , ("latexWiki", Darcs, LaTeX) ]
--   
--   -- custom authentication
--   myWithUser :: Handler -> Handler
--   myWithUser handler = do
--     -- replace the following with a function that retrieves
--     -- the logged in user for your happstack app:
--     user <- return "testuser"
--     localRq (setHeader "REMOTE_USER" user) handler
--   
--   myAuthHandler = msum
--     [ dir "_login"  $ seeOther "/your/login/url"  $ toResponse ()
--     , dir "_logout" $ seeOther "/your/logout/url" $ toResponse () ]
--   
--   handlerFor :: Config -> WikiSpec -> ServerPart Response
--   handlerFor conf (path', fstype, pagetype) = dir path' $
--     wiki conf{ repositoryPath = path'
--              , repositoryType = fstype
--              , defaultPageType = pagetype}
--   
--   indexPage :: ServerPart Response
--   indexPage = ok $ toResponse $
--     (p << "Wiki index") +++
--     ulist << map (\(path', _, _) -> li << hotlink (path' ++ "/") << path') wikis
--   
--   main = do
--     conf <- getDefaultConfig
--     let conf' = conf{authHandler = myAuthHandler, withUser = myWithUser}
--     forM wikis $ \(path', fstype, pagetype) -> do
--       let conf'' = conf'{ repositoryPath = path'
--                         , repositoryType = fstype
--                         , defaultPageType = pagetype
--                         }
--       createStaticIfMissing conf''
--       createRepoIfMissing conf''
--     createTemplateIfMissing conf'
--     initializeGititState conf'
--     simpleHTTP nullConf{port = 5001} $
--       (nullDir >> indexPage) `mplus` msum (map (handlerFor conf') wikis)
--   
module Network.Gitit -- | Happstack handler for a gitit wiki. wiki :: Config -> ServerPart Response -- | Recompiles the gitit templates. reloadTemplates :: ServerPart Response -- | Converts a gitit Handler into a standard happstack ServerPart. runHandler :: WikiState -> Handler -> ServerPart Response loginUserForm :: Handler getFileStore :: GititServerPart FileStore getUser :: String -> GititServerPart (Maybe User) getConfig :: GititServerPart Config queryGititState :: MonadIO m => (GititState -> a) -> m a updateGititState :: MonadIO m => (GititState -> GititState) -> m ()