Skip to content
Browse files

Added loadPlugins function.

  • Loading branch information...
1 parent 2e7f4e9 commit 757c028196fdd21979f55689f2bf8d29ff98530a @jgm committed
Showing with 14 additions and 5 deletions.
  1. +2 −1 Network/Gitit.hs
  2. +11 −1 Network/Gitit/Plugins.hs
  3. +1 −3 gitit.hs
View
3 Network/Gitit.hs
@@ -26,6 +26,7 @@ module Network.Gitit ( initializeGititState
, Cache(..)
, emptyCache
, loadPlugin
+ , loadPlugins
, wikiHandler
, readMimeTypesFile
, createRepoIfMissing
@@ -37,7 +38,7 @@ import Network.Gitit.Types
import Network.Gitit.Framework
import Network.Gitit.State
import Network.Gitit.Server
-import Network.Gitit.Plugins (loadPlugin)
+import Network.Gitit.Plugins (loadPlugin, loadPlugins)
import Network.Gitit.Handlers
import Network.Gitit.Initialize
import Network.Gitit.Config (readMimeTypesFile, getDefaultConfig)
View
12 Network/Gitit/Plugins.hs
@@ -20,10 +20,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- Functions for loading plugins.
-}
-module Network.Gitit.Plugins ( loadPlugin )
+module Network.Gitit.Plugins ( loadPlugin, loadPlugins )
where
import Network.Gitit.Types
import System.FilePath
+import Control.Monad (unless)
+import System.Log.Logger (logM, Priority(..))
#ifdef _PLUGINS
import Control.Monad (unless)
import Data.List (isInfixOf, isPrefixOf)
@@ -36,6 +38,7 @@ loadPlugin :: FilePath -> IO Plugin
loadPlugin pluginName =
defaultCleanupHandler defaultDynFlags $
runGhc (Just libdir) $ do
+ logM "gitit" WARNING ("Loading plugin '" ++ pluginName ++ "'...")
dflags <- getSessionDynFlags
setSessionDynFlags dflags
unless ("Network.Gitit.Plugin." `isPrefixOf` pluginName)
@@ -68,3 +71,10 @@ loadPlugin pluginName = do
return undefined
#endif
+
+loadPlugins :: [FilePath] -> IO [Plugin]
+loadPlugins pluginNames = do
+ plugins' <- mapM loadPlugin pluginNames
+ unless (null pluginNames) $ logM "gitit" WARNING "Finished loading plugins."
+ return plugins'
+
View
4 gitit.hs
@@ -75,9 +75,7 @@ main = do
let conf' = conf{jsMath = jsMathExists, logLevel = level}
-- load plugins
- let loadPluginAndLog plg = logM "gitit" WARNING ("Loading plugin '" ++ plg ++ "'...") >> loadPlugin plg
- plugins' <- mapM loadPluginAndLog (pluginModules conf')
- unless (null $ pluginModules conf') $ logM "gitit" WARNING "Finished loading plugins."
+ plugins' <- loadPlugins $ pluginModules conf'
-- initialize state
initializeGititState users' plugins'

0 comments on commit 757c028

Please sign in to comment.
Something went wrong with that request. Please try again.