X-Git-Url: https://ruin.nu/git/?p=yawbih.git;a=blobdiff_plain;f=Main.hs;h=471fee40b9b45dc439b1acf8a5851ef2b4e1495b;hp=8df5e74512d59202e045879579251682846208ce;hb=69ecfedf2b7e27f50f7c2cedf534a036fe16907e;hpb=a3c05f5d3f4be5f28a3eae7739f138a07fa263ad diff --git a/Main.hs b/Main.hs index 8df5e74..471fee4 100644 --- a/Main.hs +++ b/Main.hs @@ -1,12 +1,14 @@ module Main where -import CGI hiding (div, head, map, span) +import CGI hiding (div, head, map, span, Text) import RawCGIInternal import CGIOutput import CGITypes import System import Wiki +import Text.ParserCombinators.Parsec + testDB = createPGB "wave" "wiki" "wiki" "12wiki34db" --main = start [] cgi @@ -51,11 +53,39 @@ showPage db key s = do case s of Nothing -> text "No text added for this keyword" Just (full, date) -> do - text full + case parse wikiParser "" full of + Right n -> ex n + Left e -> do + text "PARSE ERROR: " + text (show e) + p $ text full p $ text $ "Last edited: "++date footer db key footer db key = do hr empty submit0 (editPage db key) (attr "value" "Edit") - --address (hlink (URL {unURL = ("wiki?"++key++"+edit")}) (text "Edit this page") ) + --address (hlink (URL {unURL = ("wiki?"++key++"+edit")}) (text "Edit this page") + +ex [] = return () +ex ((Paragraph):xs) = do + p empty + ex xs +ex ((Text s):xs) = do + text s + ex xs +ex ((Link l d):xs) = do + hlink (URL {unURL = ("wiki?"++l)}) (text d) + ex xs + +ex2 [] = [] +ex2 ((Paragraph):xs) = "

"++ex2 xs +ex2 ((Text s):xs) = s++ex2 xs +ex2 ((Link l d):xs) = ""++ex2 xs + + +test s = case parse wikiParser "" s of + Right n -> do + print (ex2 n) + Left e -> do + print e