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 $ table $ do
82 tr $ mapM (\header -> th (text header))
83 ["Id", "Date", "Author", "Comment"]
84 mapM (revRow db key) list
87 list <- io $ listKeys db
88 standardQuery "List of keywords" $ do
90 tr $ th (text "Keyword")
91 mapM (\key -> tr $ td $ linkKey db key) list)
94 linkKey db key = submitLink0 (showPage db key) (text key)
96 revRow db key (id, date, author, comment) = tr $ do
97 td $ submitLink0 (showRev db key id) (text id)
99 td $ linkKey db author
102 showRev db key id = do
103 s <- io $ get db key id
104 standardQuery key $ do
106 Nothing -> text "No such revision"
107 Just s -> parseText s
109 submitLink0 (changeCurrent db key id) (text "Set this version as the current one")
111 changeCurrent db key id = do
112 b <- io $ setCurrent db key id
113 if b then showPage db key
114 else standardQuery key $ do
115 text "Could not set this revision as the current active one."
119 toWash [] = return ()
120 toWash ((Paragraph):xs) = do
123 toWash ((Text s):xs) = do
126 toWash ((Link l d):xs) = do
127 hlink (URL {unURL = ("wiki?"++l)}) (text d)
129 toWash ((Bold d):xs) = do
132 toWash ((Emph d):xs) = do
135 toWash ((Underline d):xs) = do
138 toWash ((Strike d):xs) = do
141 toWash ((Heading n d):xs) = do
144 toWash ((Url l):xs) = do
145 hlink (URL {unURL = (l)}) (text l)
147 toWash ((Pre s):xs) = do