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"
21 ps a = standardQuery "Hello" a
24 s <- io $ getCurrent db key
27 Just (x,_) -> return x
28 standardQuery key $ do
29 t <- p $ makeTextarea s' (attr_SS "rows" "10" ## attr_SS "cols" "75" ## attr_SS "colspan" "2")
32 a <- textInputField (fieldSIZE 20)
35 c <- textInputField (fieldSIZE 20)
36 --p $ submit (F2 t a) testing (attr "value" "Send")
37 p $ defaultSubmit (F3 t a c) (savePage db key) (attr "value" "Send")
38 --submit0 (sp db key []) (attr "value" "Send1")
41 savePage db key (F3 t a c) = do
42 io $ update db key fulltext author comment
50 s <- io $ getCurrent db key
51 standardQuery key $ do
53 Nothing -> text "No text added for this keyword"
54 Just (full, date) -> do
56 p $ tt $ text $ "Last edited: "++date
59 parseText full = case parse wikiParser "" full of
69 td $ submitLink0 (showPage db "MainPage") (text "Back to main page")
70 when (e key) $ td $ submitLink0 (editPage db key) (text "Edit this keyword")
71 when (e key) $ td $ submitLink0 (listRevs db key) (text "List old versions")
72 td $ submitLink0 (listKeywords db) (text "List all keywords")
74 td $ activate (showPage db) textInputField empty
80 list <- io $ getList db key
81 standardQuery key $ do
83 tr $ mapM (\header -> th (text header))
84 ["Id", "Date", "Author", "Comment"]
85 mapM (revRow db key) list
89 list <- io $ listKeys db
90 standardQuery "List of keywords" $ do
92 tr $ th (text "Keyword")
93 mapM (\key -> tr $ td $ linkKey db key) list)
96 linkKey db key = submitLink0 (showPage db key) (text key)
98 revRow db key (id, date, author, comment) = tr $ do
99 td $ submitLink0 (showRev db key id) (text id)
101 td $ linkKey db author
104 showRev db key id = do
105 s <- io $ get db key id
106 standardQuery key $ do
108 Nothing -> text "No such revision"
109 Just s -> parseText s
111 submitLink0 (changeCurrent db key id) (text "Set this version as the current one")
113 changeCurrent db key id = do
114 b <- io $ setCurrent db key id
115 if b then showPage db key
116 else standardQuery key $ do
117 text "Could not set this revision as the current active one."
121 toWash [] = return ()
122 toWash ((Paragraph):xs) = do
125 toWash ((Text s):xs) = do
128 toWash ((Link l d):xs) = do
129 hlink (URL {unURL = ("wiki?"++l)}) (text d)
131 toWash ((Bold d):xs) = do
134 toWash ((Emph d):xs) = do
137 toWash ((Underline d):xs) = do
140 toWash ((Strike d):xs) = do
143 toWash ((Heading n d):xs) = do
146 toWash ((Url l):xs) = do
147 hlink (URL {unURL = (l)}) (text l)
149 toWash ((Pre s):xs) = do