1 module Rakka.Wiki.Engine
7 import Control.Arrow.ArrowIO
8 import Control.Arrow.ArrowTree
10 import Data.Encoding.UTF8
11 import Network.HTTP.Lucu
12 import Rakka.Environment
14 import Rakka.SystemConfig
15 import Rakka.Wiki.Parser
16 import Rakka.Wiki.Formatter
17 import Text.ParserCombinators.Parsec
18 import Text.XML.HXT.Arrow.XmlArrow
19 import Text.XML.HXT.DOM.TypeDefs
22 formatPage :: (ArrowXml a, ArrowChoice a, ArrowIO a) =>
27 -> do tree <- case pageType page of
28 MIMEType "text" "x-rakka" _
29 -> formatWikiPage env -< page
33 formatWikiPage :: (ArrowXml a, ArrowChoice a, ArrowIO a) =>
38 -> do let source = decodeLazy UTF8 (pageContent page)
39 case parse wikiPage "" source of
41 -> formatParseError -< err
44 -> do BaseURI baseURI <- getSysConfA (envSysConf env) (BaseURI undefined) -< ()
45 formatWikiBlocks -< (baseURI, blocks)
48 formatParseError :: ArrowXml a => a ParseError XmlTree
50 = proc err -> (eelem "pre" += txt (show err)) -<< ()
53 attachXHtmlNs :: ArrowXml a => a XmlTree XmlTree
54 attachXHtmlNs = processBottomUp (changeQName attach')
56 attach' :: QName -> QName
59 , namespaceUri = "http://www.w3.org/1999/xhtml"