3 import CGI hiding (div, head, map, span, Text)
11 import Text.ParserCombinators.Parsec
13 testDB = createPGB "localhost" "wiki" "wiki" "12wiki34db"
17 s <- getCurrent db key
24 runWithHook [] (\(key:act) -> showPage db (filter (/= '\\') key)) $ showPage db "itproj3"
27 s <- io $ getCurrent db key
30 Just (x,_) -> return x
31 standardQuery key $ do
32 t <- p $ makeTextarea s' (attr_SS "rows" "25" ## attr_SS "cols" "120" ## attr_SS "colspan" "2")
35 a <- textInputField (fieldSIZE 20)
38 c <- textInputField (fieldSIZE 20)
39 p $ defaultSubmit (F3 t a c) (savePage db key) (attr "value" "Send")
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
60 s <- io $ getCurrent db key
61 standardQuery key $ do
63 Nothing -> text "No text added for this keyword"
64 Just (full, date) -> do
66 p $ tt $ text $ "Last edited: "++date
69 parseText full = case parse wikiParser "" full of
76 parseLatex full = case parse wikiParser "" full of
77 Right n -> pre $ text $ toLatex n
87 searchKey <- td $ textInputField empty
88 td $ defaultSubmit (F1 searchKey) (\(F1 sk) -> showPage db (value sk)) (attr "value" "Go")
90 td $ submitLink0 (showPage db "itproj3") (text "Back to main page")
91 when (e key) $ td $ submitLink0 (editPage db key) (text "Edit this keyword")
92 when (e key) $ td $ submitLink0 (listRevs db key) (text "List old versions")
93 when (e key) $ td $ submitLink0 (showLatex db key) (text "Output latex")
94 td $ submitLink0 (listKeywords db) (text "List all keywords")
95 --td $ activate (showPage db) textInputField empty
101 list <- io $ getList db key
102 standardQuery key $ do
104 tr $ mapM (\header -> th (text header))
105 ["Id", "Date", "Author", "Comment"]
106 mapM (revRow db key) list
110 list <- io $ listKeys db
111 standardQuery "List of keywords" $ do
113 tr $ th (text "Keyword")
114 mapM (\key -> tr $ td $ linkKey db key) list)
117 linkKey db key = submitLink0 (showPage db key) (text key)
119 revRow db key (id, date, author, comment) = tr $ do
120 td $ submitLink0 (showRev db key id) (text id)
122 td $ linkKey db author
125 showRev db key id = do
126 s <- io $ get db key id
127 standardQuery key $ do
129 Nothing -> text "No such revision"
130 Just s -> parseText s
132 submitLink0 (changeCurrent db key id) (text "Set this version as the current one")
134 changeCurrent db key id = do
135 b <- io $ setCurrent db key id
136 if b then showPage db key
137 else standardQuery key $ do
138 text "Could not set this revision as the current active one."
142 toWash [] = return ()
143 toWash ((Paragraph):xs) = do
146 toWash ((Text s):xs) = do
149 toWash ((Link l d):xs) = do
150 hlink (URL {unURL = ("wiki?"++l)}) (text d)
152 toWash ((Font o d):xs) = do
155 toWash ((Heading n d):xs) = do
158 toWash ((Url l):xs) = do
159 hlink (URL {unURL = (l)}) (text $ stripMailto l)
161 toWash ((Pre s):xs) = do
164 toWash ((List o l):xs) = do
165 listType o $ mapM (\s -> li $ toWash s) l
171 stripMailto ('m':'a':'i':'l':'t':'o':':':xs) = xs
178 fontOp Strike = strike