CABAL_FILE = Rakka.cabal
GHC = ghc
-EXECUTABLE = sudo rakka -p 8989 -l DEBUG
+EXECUTABLE = sudo ./dist/build/rakka/rakka -p 8989 -l DEBUG
build: .setup-config Setup
./Setup build
-run: install
+run: build
$(EXECUTABLE)
.setup-config: $(CABAL_FILE) configure Setup Rakka.buildinfo.in
Web
Tested-With:
GHC == 6.6.1
-Extensions:
- Arrows
-GHC-Options:
- -fwarn-unused-imports -fglasgow-exts
Build-Depends:
Crypto, HUnit, HsSVN, Lucu, base, encoding, filepath, hslogger,
hxt, mtl, network, parsec, stm, unix
-Exposed-Modules:
- Rakka.Page
- Rakka.Plugin
- Rakka.Storage
- Rakka.SystemConfig
- Rakka.Utils
- Rakka.Wiki
- Rakka.Wiki.Interpreter
-Other-Modules:
- Rakka.Storage.DefaultPage
Data-Files:
defaultpages/Help/SampleImage/Large
defaultpages/Help/SampleImage/Small
Main.hs
Other-Modules:
Rakka.Environment
+ Rakka.Page
+ Rakka.Plugin
Rakka.Resource
Rakka.Resource.Index
Rakka.Resource.Object
Rakka.Resource.Render
+ Rakka.Storage
+ Rakka.Storage.DefaultPage
+ Rakka.SystemConfig
+ Rakka.Utils
+ Rakka.Wiki
+ Rakka.Wiki.Interpreter
Rakka.Wiki.Interpreter.Base
- Rakka.Wiki.Interpreter.Base.Image
- Rakka.Wiki.Interpreter.Base.Outline
+ Rakka.Wiki.Interpreter.Image
+ Rakka.Wiki.Interpreter.Outline
Rakka.Wiki.Engine
Rakka.Wiki.Formatter
Rakka.Wiki.Parser
( Environment(..)
, InterpTable
, setupEnv
- , getInterpTable
- , getInterpTableA
)
where
-import Control.Concurrent.STM
-import Control.Arrow.ArrowIO
import Data.Map (Map)
import qualified Data.Map as M
import Network
import Rakka.Storage
import Rakka.SystemConfig
import Rakka.Wiki.Interpreter
-import Rakka.Wiki.Interpreter.Base
+import qualified Rakka.Wiki.Interpreter.Base as Base
+import qualified Rakka.Wiki.Interpreter.Image as Image
+import qualified Rakka.Wiki.Interpreter.Outline as Outline
import Subversion.Repository
import System.Directory
import System.FilePath
, envRepository :: !Repository
, envStorage :: !Storage
, envSysConf :: !SystemConfig
- , envInterpTable :: !(TVar InterpTable)
+ , envInterpTable :: !InterpTable
}
setupEnv :: FilePath -> PortNumber -> IO Environment
setupEnv lsdir portNum
- = do let lucuConf = LC.defaultConfig {
- LC.cnfServerPort = PortNumber portNum
- }
- reposPath = lsdir `combine` "repos"
- storage = mkStorage
+ = do let lucuConf = LC.defaultConfig {
+ LC.cnfServerPort = PortNumber portNum
+ }
+ reposPath = lsdir `combine` "repos"
+ storage = mkStorage
+ interpTable = mkInterpTable
reposExist <- doesDirectoryExist reposPath
repos <- if reposExist then
do noticeM logger ("Creating a subversion repository on " ++ reposPath)
createRepository reposPath [] []
sysConf <- mkSystemConfig lucuConf repos
- interpTable <- mkInterpTable
+
return $ Environment {
envLocalStateDir = lsdir
}
-mkInterpTable :: IO (TVar InterpTable)
-mkInterpTable = newTVarIO (listToTable baseInterpreters)
+mkInterpTable :: InterpTable
+mkInterpTable = listToTable $
+ foldl (++) [] [ Base.interpreters
+ , Image.interpreters
+ , Outline.interpreters
+ ]
where
listToTable :: [Interpreter] -> InterpTable
listToTable xs
= M.fromList [ (commandName x, x) | x <- xs ]
-
-
-getInterpTable :: Environment -> IO InterpTable
-getInterpTable = atomically . readTVar . envInterpTable
-
-
-getInterpTableA :: ArrowIO a => Environment -> a b InterpTable
-getInterpTableA = arrIO0 . getInterpTable
formatPage env
= proc page
-> do BaseURI baseURI <- getSysConfA (envSysConf env) (BaseURI undefined) -< ()
- interpTable <- getInterpTableA env -< ()
- wiki <- wikifyPage env -< (interpTable, page)
- xs <- interpretCommandsA env -< (interpTable, (pageName page, (Just wiki, wiki)))
+ wiki <- wikifyPage env -< page
+ xs <- interpretCommandsA env -< (pageName page, (Just wiki, wiki))
formatWikiBlocks -< (baseURI, xs)
formatSubPage env
= proc (mainPageName, (mainPage, subPage))
-> do BaseURI baseURI <- getSysConfA (envSysConf env) (BaseURI undefined) -< ()
- interpTable <- getInterpTableA env -< ()
mainWiki <- case mainPage of
Just page
- -> do wiki <- wikifyPage env -< (interpTable, page)
+ -> do wiki <- wikifyPage env -< page
returnA -< Just wiki
Nothing
-> returnA -< Nothing
- subWiki <- wikifyPage env -< (interpTable, subPage)
- xs <- interpretCommandsA env -< (interpTable, (mainPageName, (mainWiki, subWiki)))
+ subWiki <- wikifyPage env -< subPage
+ xs <- interpretCommandsA env -< (mainPageName, (mainWiki, subWiki))
formatWikiBlocks -< (baseURI, xs)
wikifyPage :: (ArrowXml a, ArrowChoice a, ArrowIO a) =>
Environment
- -> a (InterpTable, Page) WikiPage
+ -> a Page WikiPage
wikifyPage env
- = proc (interpTable, page)
+ = proc page
-> case pageType page of
MIMEType "text" "x-rakka" _
-> do let source = decodeLazy UTF8 (pageContent page)
- parser = wikiPage (tableToFunc interpTable)
+ parser = wikiPage tableToFunc
case parse parser "" source of
Left err
Right xs
-> returnA -< xs
where
- tableToFunc :: InterpTable -> String -> Maybe CommandType
- tableToFunc table name
- = fmap commandType (M.lookup name table)
+ tableToFunc :: String -> Maybe CommandType
+ tableToFunc name
+ = fmap commandType (M.lookup name (envInterpTable env))
interpretCommandsA :: ArrowIO a =>
Environment
- -> a (InterpTable, (PageName, (Maybe WikiPage, WikiPage))) WikiPage
-interpretCommandsA = arrIO4 . interpretCommands
+ -> a (PageName, (Maybe WikiPage, WikiPage)) WikiPage
+interpretCommandsA = arrIO3 . interpretCommands
-interpretCommands :: Environment -> InterpTable -> PageName -> Maybe WikiPage -> WikiPage -> IO WikiPage
-interpretCommands _ _ _ _ [] = return []
-interpretCommands env table name mainTree targetTree
+interpretCommands :: Environment -> PageName -> Maybe WikiPage -> WikiPage -> IO WikiPage
+interpretCommands _ _ _ [] = return []
+interpretCommands env name mainTree targetTree
= everywhereM' (mkM interpBlockCmd) targetTree
>>=
everywhereM' (mkM interpInlineCmd)
interpBlockCmd' :: BlockCommand -> IO BlockElement
interpBlockCmd' cmd
- = case M.lookup (bCmdName cmd) table of
+ = case M.lookup (bCmdName cmd) (envInterpTable env) of
Nothing
-> fail ("no such interpreter: " ++ bCmdName cmd)
interpInlineCmd' :: InlineCommand -> IO InlineElement
interpInlineCmd' cmd
- = case M.lookup (iCmdName cmd) table of
+ = case M.lookup (iCmdName cmd) (envInterpTable env) of
Nothing
-> fail ("no such interpreter: " ++ iCmdName cmd)
module Rakka.Wiki.Interpreter.Base
- ( baseInterpreters
+ ( interpreters
)
where
import Rakka.Wiki
import Rakka.Wiki.Interpreter
-import Rakka.Wiki.Interpreter.Base.Image
-import Rakka.Wiki.Interpreter.Base.Outline
-baseInterpreters :: [Interpreter]
-baseInterpreters = [ lineBreakInterp
- , spanInterp
- , divInterp
- , imageInterp
- , imgFrameInterp
-
- , pageNameInterp
- , outlineInterp
- ]
+interpreters :: [Interpreter]
+interpreters = [ lineBreakInterp
+ , spanInterp
+ , divInterp
+ , pageNameInterp
+ ]
lineBreakInterp :: Interpreter
-module Rakka.Wiki.Interpreter.Base.Image
- ( imageInterp
- , imgFrameInterp
+module Rakka.Wiki.Interpreter.Image
+ ( interpreters
)
where
import Rakka.Wiki
+interpreters :: [Interpreter]
+interpreters = [ imageInterp
+ , imgFrameInterp
+ ]
+
+
-- <a href="..." class="inlineImage ...">
-- <img src="..." alt="..." />
-- </a>
-module Rakka.Wiki.Interpreter.Base.Outline
- ( outlineInterp
+module Rakka.Wiki.Interpreter.Outline
+ ( interpreters
)
where
import Rakka.Wiki.Interpreter
+interpreters :: [Interpreter]
+interpreters = [ outlineInterp ]
+
+
outlineInterp :: Interpreter
outlineInterp = BlockCommandInterpreter {
bciName = "outline"