X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Wiki.hs;h=4ff75751ea71d396fa2ae0c0ac9c5ba9124bbd37;hb=d34c7b573c637a384786d8fb0e6279311528725c;hp=c4b7166f377a508ac021b55fcedfb1e024733269;hpb=e36bf63ff310b307b1f62f86fc87307e18c4677a;p=yawbih.git diff --git a/Wiki.hs b/Wiki.hs index c4b7166..4ff7575 100644 --- a/Wiki.hs +++ b/Wiki.hs @@ -1,20 +1,48 @@ module Wiki ( + WB + ,PGB ) where -class WikiBackend a where - --Keyword -> Full text - getCurrent :: a -> String -> IO String +import Dbconnect + +class WB a where + --Keyword -> (Full text,date) + getCurrent :: a -> String -> IO (String,String) --Keyword -> [(id,date)] - getList :: a -> String -> IO [(Int, String)] + getList :: a -> String -> IO [(String, String, String, String)] --Keyword -> id -> Full text - get :: a -> String -> Int -> IO String + get :: a -> String -> String -> IO String --Keyword -> id -> () - setCurrent :: a -> String -> Int -> IO () + setCurrent :: a -> String -> String -> IO () --Keyword -> Full text -> id - addNew :: String -> String -> IO Int + 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 ""