module Wiki (
- Backend
+ Backend (getCurrent,getList,get,setCurrent,update)
,PGB
+ ,createPGB
) where
--Keyword -> (Full text,date)
getCurrent :: a -> String -> IO (Maybe (String,String))
- --Keyword -> [(id,date)]
+ --Keyword -> [(id,date,author,comment)]
getList :: a -> String -> IO [(String, String, String, String)]
--Keyword -> id -> Full text
--Keyword -> Full text -> id
update :: a -> String -> String -> String -> String -> IO String
+data Markup = Text String
+ | Bold String
+ | Paragraph [Markup]
+
+type Document = [Markup]
+
newtype PGB = PGB DBService
createPGB :: String -> String -> String -> String -> IO PGB
setCurrent (PGB db) key id = do
full <- selectReturnTuples db $ "SELECT keyword FROM fulltexts WHERE keyword="++tov key++" AND id='"++id++"'"
- cur <- selectReturnTuples db $ "SELECT keyword FROM curtexts WHERE keyword='"++tov key++"'"
+ cur <- selectReturnTuples db $ "SELECT keyword FROM curtexts WHERE keyword="++tov key
case full of
[[]] -> do
- print "No text found with this id and key"
return False
_ -> do
rows <- case cur of
- [] -> do
- print "No link found in current, inserting"
- execute db $ "INSERT INTO current (keyword, id) VALUES ("++tov id++","++tov key++")"
+ [[]] -> do
+ execute db $ "INSERT INTO current (keyword, id) VALUES ("++tov key++","++tov id++")"
_ -> do
- print "Link found in current, updating"
execute db $ "UPDATE current SET id = "++tov id++" WHERE keyword = "++tov key
- print rows
if rows == 1 then return True
else return False