Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Export getDefaultConfig in Network.Gitit.

  • Loading branch information...
commit eaaabafd6506df2bbcea7c4b2541ce6d652c3f37 1 parent 65e1e24
@jgm authored
Showing with 14 additions and 4 deletions.
  1. +2 −2 Network/Gitit.hs
  2. +12 −2 Network/Gitit/Config.hs
View
4 Network/Gitit.hs
@@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
module Network.Gitit ( initializeAppState
+ , getDefaultConfig
, Config(..)
, User(..)
, Cache(..)
@@ -35,10 +36,9 @@ import Network.Gitit.State
import Network.Gitit.Server
import Network.Gitit.Plugins (loadPlugin)
import Network.Gitit.Handlers
-import Network.Gitit.Config (readMimeTypesFile)
+import Network.Gitit.Config (readMimeTypesFile, getDefaultConfig)
import Control.Monad.Reader
--- TODO: parameterize on getLoggedInUser
wikiHandler :: Config -> ServerPart Response
wikiHandler conf = do
let staticHandler = dir "_static" $
View
14 Network/Gitit/Config.hs
@@ -20,7 +20,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- Functions for parsing command line options and reading the config file.
-}
-module Network.Gitit.Config ( getConfigFromOpts, readMimeTypesFile )
+module Network.Gitit.Config ( getConfigFromOpts
+ , readMimeTypesFile
+ , getDefaultConfig )
where
import Network.Gitit.Types
import Network.Gitit.Server (mimeTypes)
@@ -150,10 +152,12 @@ extractConfig cp = do
"latex" -> (LaTeX,False)
"latex+lhs" -> (LaTeX,True)
x -> error $ "Unknown page type: " ++ x
+
let markupHelpFile = show pt ++ if lhs then "+LHS" else ""
markupHelpPath <- liftIO $ getDataFileName $ "data" </> "markupHelp" </> markupHelpFile
markupHelpText <- liftM (writeHtmlString defaultWriterOptions . readMarkdown defaultParserState) $
- liftIO $ readFile markupHelpPath
+ liftIO $ readFile markupHelpPath
+
mimeMap' <- liftIO $ readMimeTypesFile cfMimeTypesFile
-- create template file if it doesn't exist
@@ -250,6 +254,12 @@ lrStrip :: String -> String
lrStrip = reverse . dropWhile isWhitespace . reverse . dropWhile isWhitespace
where isWhitespace = (`elem` " \t\n")
+getDefaultConfig :: IO Config
+getDefaultConfig = do
+ cp <- getDataFileName "data/default.conf" >>= readfile emptyCP
+ let cp' = forceEither cp
+ extractConfig cp'
+
getConfigFromOpts :: IO Config
getConfigFromOpts = do
cp <- getDataFileName "data/default.conf" >>= readfile emptyCP
Please sign in to comment.
Something went wrong with that request. Please try again.