X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Wiki.hs;h=4ff75751ea71d396fa2ae0c0ac9c5ba9124bbd37;hb=d34c7b573c637a384786d8fb0e6279311528725c;hp=916829e11a872db3fd7b99d37fb5e68954bf844e;hpb=0bf2b690d5e8399175531005f9ca03df947cf878;p=yawbih.git diff --git a/Wiki.hs b/Wiki.hs index 916829e..4ff7575 100644 --- a/Wiki.hs +++ b/Wiki.hs @@ -1,21 +1,48 @@ module Wiki ( + WB + ,PGB ) where -import Graphics.UI.WXCore.Db +import Dbconnect -{-Keyword -> Full text -getCurrent :: String -> IO String +class WB a where + --Keyword -> (Full text,date) + getCurrent :: a -> String -> IO (String,String) ---Keyword -> (id,date) -getList :: String -> IO (Int, String) + --Keyword -> [(id,date)] + getList :: a -> String -> IO [(String, String, String, String)] ---Keyword -> id -> Full Text -get :: String -> Int -> IO String + --Keyword -> id -> Full text + get :: a -> String -> String -> IO String ---Keyword -> id -> () -setCurrent :: String -> Int -> IO () + --Keyword -> id -> () + setCurrent :: a -> String -> String -> IO () + + --Keyword -> Full text -> id + addNew :: a -> String -> String -> IO String + +data 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 WB PGB where + + getCurrent (PGB db) key = do + [[text,date]] <- selectReturnTuples db $ "SELECT fulltext,timestamp FROM curtexts where keyword='"++key++"'" + return (text,date) + + getList (PGB db) key = do + list <- selectReturnTuples db $ "SELECT id, timestamp, author, comment from fulltexts where keyword = '"++key++"'" + return $ map (\[id,date,author,comment] -> (id,date,author,comment)) list + + get (PGB db) key id = return "" + + setCurrent (PGB db) key id = return () + + addNew (PGB db) key text = return "" ---Keyword -> Full text -> id -addNew :: String -> String -> IO Int --}