From: pho Date: Sun, 21 Oct 2007 08:42:02 +0000 (+0900) Subject: Record before an experiment X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=4608e8de5f9d72f12055494467283b4dea2faeb5;p=Rakka.git Record before an experiment darcs-hash:20071021084202-62b54-e9616ae706efdb9aed9acdf17139e24763ffcaed.gz --- diff --git a/Rakka.cabal b/Rakka.cabal index 495148e..859d305 100644 --- a/Rakka.cabal +++ b/Rakka.cabal @@ -31,12 +31,14 @@ Exposed-Modules: Rakka.Page Rakka.Storage Rakka.SystemConfig + Rakka.Utils Rakka.Wiki Rakka.Wiki.Interpreter Other-Modules: Rakka.Storage.DefaultPage - Rakka.Utils Data-Files: + defaultpages/Help/SampleImage/Large + defaultpages/Help/SampleImage/Small defaultPages/Help/Syntax defaultPages/MainPage defaultPages/StyleSheet/Default @@ -47,6 +49,17 @@ Executable: rakka Main-Is: Main.hs +Other-Modules: + Rakka.Environment + Rakka.Resource + Rakka.Resource.Index + Rakka.Resource.Object + Rakka.Resource.Render + Rakka.Wiki.Interpreter.Base + Rakka.Wiki.Interpreter.Base.Image + Rakka.Wiki.Engine + Rakka.Wiki.Formatter + Rakka.Wiki.Parser Extensions: Arrows GHC-Options: @@ -56,6 +69,8 @@ GHC-Options: Executable: RakkaUnitTest Main-Is: - tests/RakkaUnitTest.hs + RakkaUnitTest.hs Hs-Source-Dirs: tests +Other-Modules: + WikiParserTest \ No newline at end of file diff --git a/Rakka/Wiki/Engine.hs b/Rakka/Wiki/Engine.hs index 66e2ccc..3300181 100644 --- a/Rakka/Wiki/Engine.hs +++ b/Rakka/Wiki/Engine.hs @@ -67,6 +67,14 @@ interpretCommands :: Environment -> InterpTable -> Maybe Page -> WikiPage -> IO interpretCommands _ _ _ [] = return [] interpretCommands env table page blocks = mapM interpBlock blocks where + ctx :: InterpreterContext + ctx = InterpreterContext { + ctxPage = page + , ctxTree = blocks + , ctxStorage = envStorage env + , ctxSysConf = envSysConf env + } + interpBlock :: BlockElement -> IO BlockElement interpBlock (List list) = interpList list >>= return . List interpBlock (DefinitionList defs) = mapM interpDefinition defs >>= return . DefinitionList @@ -101,7 +109,7 @@ interpretCommands env table page blocks = mapM interpBlock blocks -> fail ("no such interpreter: " ++ bCmdName cmd) Just interp - -> bciInterpret interp cmd page (envStorage env) (envSysConf env) + -> bciInterpret interp ctx cmd >>= interpBlock @@ -119,7 +127,7 @@ interpretCommands env table page blocks = mapM interpBlock blocks -> fail ("no such interpreter: " ++ iCmdName cmd) Just interp - -> iciInterpret interp cmd page (envStorage env) (envSysConf env) + -> iciInterpret interp ctx cmd >>= interpInline diff --git a/Rakka/Wiki/Interpreter.hs b/Rakka/Wiki/Interpreter.hs index bfaab67..09f7414 100644 --- a/Rakka/Wiki/Interpreter.hs +++ b/Rakka/Wiki/Interpreter.hs @@ -1,11 +1,9 @@ module Rakka.Wiki.Interpreter ( Interpreter(..) + , InterpreterContext(..) , commandName -- private , commandType -- private - - , pureInlineInterp - , pureBlockInterp ) where @@ -18,19 +16,20 @@ import Rakka.Wiki data Interpreter = InlineCommandInterpreter { iciName :: String - , iciInterpret :: InlineCommand - -> Maybe Page - -> Storage - -> SystemConfig - -> IO InlineElement + , iciInterpret :: InterpreterContext -> InlineCommand -> IO InlineElement } | BlockCommandInterpreter { bciName :: String - , bciInterpret :: BlockCommand - -> Maybe Page - -> Storage - -> SystemConfig - -> IO BlockElement + , bciInterpret :: InterpreterContext -> BlockCommand -> IO BlockElement + } + + +data InterpreterContext + = InterpreterContext { + ctxPage :: Maybe Page + , ctxTree :: WikiPage + , ctxStorage :: Storage + , ctxSysConf :: SystemConfig } @@ -42,17 +41,3 @@ commandName (BlockCommandInterpreter name _) = name commandType :: Interpreter -> CommandType commandType (InlineCommandInterpreter _ _) = InlineCommandType commandType (BlockCommandInterpreter _ _) = BlockCommandType - - -pureInlineInterp :: String - -> (InlineCommand -> Maybe Page -> InlineElement) - -> Interpreter -pureInlineInterp name f - = InlineCommandInterpreter name $ \ cmd page _ _ -> return $ f cmd page - - -pureBlockInterp :: String - -> (BlockCommand -> Maybe Page -> BlockElement) - -> Interpreter -pureBlockInterp name f - = BlockCommandInterpreter name $ \ cmd page _ _ -> return $ f cmd page diff --git a/Rakka/Wiki/Interpreter/Base.hs b/Rakka/Wiki/Interpreter/Base.hs index 437705d..1475f46 100644 --- a/Rakka/Wiki/Interpreter/Base.hs +++ b/Rakka/Wiki/Interpreter/Base.hs @@ -18,18 +18,24 @@ baseInterpreters = [ lineBreakInterp lineBreakInterp :: Interpreter -lineBreakInterp = pureInlineInterp "br" interpret - where - interpret (InlineCommand _ attrs _) _ = LineBreak attrs +lineBreakInterp = InlineCommandInterpreter { + iciName = "br" + , iciInterpret + = \ _ (InlineCommand _ attrs _) -> return $ LineBreak attrs + } spanInterp :: Interpreter -spanInterp = pureInlineInterp "span" interpret - where - interpret (InlineCommand _ attrs contents) _ = Span attrs contents +spanInterp = InlineCommandInterpreter { + iciName = "span" + , iciInterpret + = \ _ (InlineCommand _ attrs contents) -> return $ Span attrs contents + } divInterp :: Interpreter -divInterp = pureBlockInterp "div" interpret - where - interpret (BlockCommand _ attrs contents) _ = Div attrs contents \ No newline at end of file +divInterp = BlockCommandInterpreter { + bciName = "div" + , bciInterpret + = \ _ (BlockCommand _ attrs contents) -> return $ Div attrs contents + } diff --git a/Rakka/Wiki/Interpreter/Base/Image.hs b/Rakka/Wiki/Interpreter/Base/Image.hs index d23ec78..f73b205 100644 --- a/Rakka/Wiki/Interpreter/Base/Image.hs +++ b/Rakka/Wiki/Interpreter/Base/Image.hs @@ -21,8 +21,8 @@ imageInterp = InlineCommandInterpreter { iciName = "img" , iciInterpret - = \ (InlineCommand _ attrs inside) _ _ sysConf -> - do BaseURI baseURI <- getSysConf sysConf (BaseURI undefined) + = \ ctx (InlineCommand _ attrs inside) -> + do BaseURI baseURI <- getSysConf (ctxSysConf ctx) (BaseURI undefined) let pageName = lookup "src" attrs when (pageName == Nothing) @@ -61,8 +61,8 @@ imgFrameInterp = BlockCommandInterpreter { bciName = "imgframe" , bciInterpret - = \ (BlockCommand _ attrs inside) _ _ sysConf -> - do BaseURI baseURI <- getSysConf sysConf (BaseURI undefined) + = \ ctx (BlockCommand _ attrs inside) -> + do BaseURI baseURI <- getSysConf (ctxSysConf ctx) (BaseURI undefined) let pageName = lookup "src" attrs when (pageName == Nothing) diff --git a/defaultPages/StyleSheet/Default b/defaultPages/StyleSheet/Default index a51a053..49dce5c 100644 --- a/defaultPages/StyleSheet/Default +++ b/defaultPages/StyleSheet/Default @@ -195,8 +195,8 @@ img { padding: 5px; border-color: #cccccc; - border-width: 2px; - border-style: dotted; + border-width: 1px; + border-style: solid; } .imageFrame p {