]> ruin.nu Git - yawbih.git/blobdiff - Wiki.hs
Possible to list and get old revisions
[yawbih.git] / Wiki.hs
diff --git a/Wiki.hs b/Wiki.hs
index 337d715eb9160b83cd94e2fa2549de67e09fd6da..7d337c9f679b3b14ce01e1bf6716864a3390fb6d 100644 (file)
--- a/Wiki.hs
+++ b/Wiki.hs
@@ -20,7 +20,7 @@ class Backend a where
        getList :: a -> String -> IO [(String, String, String, String)]
 
        --Keyword -> id -> Full text
-       get :: a -> String -> String -> IO String
+       get :: a -> String -> String -> IO (Maybe String)
 
        --Keyword -> id -> ()
        setCurrent :: a -> String -> String -> IO Bool
@@ -100,7 +100,11 @@ instance Backend PGB where
                list <- selectReturnTuples db $ "SELECT id, timestamp, author, comment from fulltexts WHERE keyword = "++tov key
                return $ map (\[id,date,author,comment] -> (id,date,author,comment)) list
 
-       get (PGB db) key id = return ""
+       get (PGB db) key id = do
+               list <- selectReturnTuples db $ "SELECT fulltext from fulltexts WHERE id = "++tov id    
+               case list of
+                       [s]:_ -> return (Just s)
+                       _ -> return Nothing
 
        setCurrent (PGB db) key id = do
                full <- selectReturnTuples db $ "SELECT keyword FROM fulltexts WHERE keyword="++tov key++" AND id='"++id++"'"