X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Wiki.hs;h=83b14b6223ceb7d7e7e59d7c6db4f6592d1bdbf2;hb=da6b71a772c66eb03c9ced7a6ca0cbbd49013536;hp=231dda46217123dc1cee063d5dbc150a1c8f4f1f;hpb=464842463236cab162bb4cffa8bebe8b42f3b3eb;p=yawbih.git diff --git a/Wiki.hs b/Wiki.hs index 231dda4..83b14b6 100644 --- a/Wiki.hs +++ b/Wiki.hs @@ -56,7 +56,6 @@ pPara = do pEol return (Paragraph) - pSpace = do space return (Text " ") @@ -92,17 +91,9 @@ pS s f = do s <- pStopAt s return (f s) -pStopAt xs = do - try (string xs >> return []) <|> (do - s <- pMain - ss <- pStopAt xs - return (s:ss)) - -pString xs = do - try (string xs >> return []) <|> (do - s <- anyChar - ss <- pString xs - return (s:ss)) +pStopAt xs = pUntil pMain xs +pString xs = pUntil anyChar xs +pUntil p xs = manyTill p (try $ string xs) pHeading = do many1 pEol @@ -140,18 +131,14 @@ pOtherChar = do return (Text (c:[])) pText = do - t <- many1 alphaNum--(noneOf ['\n','\r','[',']']) + t <- many1 alphaNum return (Text t) - newtype PGB = PGB DBService createPGB :: String -> String -> String -> String -> IO PGB createPGB host database user password = let db = createDBService host database "" user password Nothing in return (PGB db) - -testDB = createPGB "wave" "wiki" "wiki" "12wiki34db" - instance Backend PGB where getCurrent (PGB db) key = do @@ -196,7 +183,7 @@ instance Backend PGB where return id listKeys (PGB db) = do - list <- selectReturnTuples db $ "SELECT keyword FROM fulltexts ORDER BY lower(keyword)" + list <- selectReturnTuples db $ "SELECT keyword FROM fulltexts GROUP BY keyword ORDER BY lower(keyword)" case list of [[]] -> return [] _ -> mapM (\[key] -> return key) list