3 import CGI hiding (div, head, map, span, Text)
11 import Text.ParserCombinators.Parsec
13 testDB = createPGB "wave" "wiki" "wiki" "12wiki34db"
19 runWithHook [] (\(key:act) -> showPage db (filter (/= '\\') key)) $ showPage db "MainPage"
22 s <- io $ getCurrent db key
25 Just (x,_) -> return x
26 standardQuery key $ do
27 t <- p $ makeTextarea s' (attr_SS "rows" "10" ## attr_SS "cols" "75" ## attr_SS "colspan" "2")
30 a <- textInputField (fieldSIZE 20)
33 c <- textInputField (fieldSIZE 20)
34 p $ defaultSubmit (F3 t a c) (savePage db key) (attr "value" "Send")
36 savePage db key (F3 t a c) = do
37 io $ update db key fulltext author comment
45 s <- io $ getCurrent db key
46 standardQuery key $ do
48 Nothing -> text "No text added for this keyword"
49 Just (full, date) -> do
51 p $ tt $ text $ "Last edited: "++date
54 parseText full = case parse wikiParser "" full of
64 td $ submitLink0 (showPage db "MainPage") (text "Back to main page")
65 when (e key) $ td $ submitLink0 (editPage db key) (text "Edit this keyword")
66 when (e key) $ td $ submitLink0 (listRevs db key) (text "List old versions")
67 td $ submitLink0 (listKeywords db) (text "List all keywords")
69 td $ activate (showPage db) textInputField empty
75 list <- io $ getList db key
76 standardQuery key $ do
78 tr $ mapM (\header -> th (text header))
79 ["Id", "Date", "Author", "Comment"]
80 mapM (revRow db key) list
84 list <- io $ listKeys db
85 standardQuery "List of keywords" $ do
87 tr $ th (text "Keyword")
88 mapM (\key -> tr $ td $ linkKey db key) list)
91 linkKey db key = submitLink0 (showPage db key) (text key)
93 revRow db key (id, date, author, comment) = tr $ do
94 td $ submitLink0 (showRev db key id) (text id)
96 td $ linkKey db author
99 showRev db key id = do
100 s <- io $ get db key id
101 standardQuery key $ do
103 Nothing -> text "No such revision"
104 Just s -> parseText s
106 submitLink0 (changeCurrent db key id) (text "Set this version as the current one")
108 changeCurrent db key id = do
109 b <- io $ setCurrent db key id
110 if b then showPage db key
111 else standardQuery key $ do
112 text "Could not set this revision as the current active one."
116 toWash [] = return ()
117 toWash ((Paragraph):xs) = do
120 toWash ((Text s):xs) = do
123 toWash ((Link l d):xs) = do
124 hlink (URL {unURL = ("wiki?"++l)}) (text d)
126 toWash ((Bold d):xs) = do
129 toWash ((Emph d):xs) = do
132 toWash ((Underline d):xs) = do
135 toWash ((Strike d):xs) = do
138 toWash ((Heading n d):xs) = do
141 toWash ((Url l):xs) = do
142 hlink (URL {unURL = (l)}) (text l)
144 toWash ((Pre s):xs) = do