]> ruin.nu Git - yawbih.git/commitdiff
getCurrent and getList done
authorMichael Andreen <harv@ruin.nu>
Sun, 5 Dec 2004 15:49:26 +0000 (15:49 +0000)
committerMichael Andreen <harv@ruin.nu>
Sun, 5 Dec 2004 15:49:26 +0000 (15:49 +0000)
Wiki.hs

diff --git a/Wiki.hs b/Wiki.hs
index c41effa9d481e63e5c7b41aa1aa5569504475287..4ff75751ea71d396fa2ae0c0ac9c5ba9124bbd37 100644 (file)
--- a/Wiki.hs
+++ b/Wiki.hs
@@ -11,7 +11,7 @@ class WB a where
        getCurrent :: a -> String -> IO (String,String)
 
        --Keyword -> [(id,date)]
        getCurrent :: a -> String -> IO (String,String)
 
        --Keyword -> [(id,date)]
-       getList :: a -> String -> IO [(String, String)]
+       getList :: a -> String -> IO [(String, String, String, String)]
 
        --Keyword -> id -> Full text
        get :: a -> String -> String -> IO String
 
        --Keyword -> id -> Full text
        get :: a -> String -> String -> IO String
@@ -24,17 +24,25 @@ class WB a where
 
 data PGB = PGB DBService
 
 
 data PGB = PGB DBService
 
-createPGP host database user password = let db = createDBService host database "" user password Nothing in return (PGB db)
+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
 
 instance WB PGB where
 
-       getCurrent (PGB db) key = return ("","")
+       getCurrent (PGB db) key = do 
+               [[text,date]] <- selectReturnTuples db $ "SELECT fulltext,timestamp FROM curtexts where keyword='"++key++"'"
+               return (text,date)
 
 
-       getList (PGB db) key = return [("","")]
+       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 ""
 
        get (PGB db) key id = return ""
 
        setCurrent (PGB db) key id = return ()
 
        addNew (PGB db) key text = return ""
+