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
85 td $ submitLink0 (showPage db "itproj3") (text "Back to main page")
86 when (e key) $ td $ submitLink0 (editPage db key) (text "Edit this keyword")
87 when (e key) $ td $ submitLink0 (listRevs db key) (text "List old versions")
88 when (e key) $ td $ submitLink0 (showLatex db key) (text "Output latex")
89 td $ submitLink0 (listKeywords db) (text "List all keywords")
91 td $ activate (showPage db) textInputField empty
97 list <- io $ getList db key
98 standardQuery key $ do
100 tr $ mapM (\header -> th (text header))
101 ["Id", "Date", "Author", "Comment"]
102 mapM (revRow db key) list
106 list <- io $ listKeys db
107 standardQuery "List of keywords" $ do
109 tr $ th (text "Keyword")
110 mapM (\key -> tr $ td $ linkKey db key) list)
113 linkKey db key = submitLink0 (showPage db key) (text key)
115 revRow db key (id, date, author, comment) = tr $ do
116 td $ submitLink0 (showRev db key id) (text id)
118 td $ linkKey db author
121 showRev db key id = do
122 s <- io $ get db key id
123 standardQuery key $ do
125 Nothing -> text "No such revision"
126 Just s -> parseText s
128 submitLink0 (changeCurrent db key id) (text "Set this version as the current one")
130 changeCurrent db key id = do
131 b <- io $ setCurrent db key id
132 if b then showPage db key
133 else standardQuery key $ do
134 text "Could not set this revision as the current active one."
138 toWash [] = return ()
139 toWash ((Paragraph):xs) = do
142 toWash ((Text s):xs) = do
145 toWash ((Link l d):xs) = do
146 hlink (URL {unURL = ("wiki?"++l)}) (text d)
148 toWash ((Font o d):xs) = do
151 toWash ((Heading n d):xs) = do
154 toWash ((Url l):xs) = do
155 hlink (URL {unURL = (l)}) (text $ stripMailto l)
157 toWash ((Pre s):xs) = do
160 toWash ((List o l):xs) = do
161 listType o $ mapM (\s -> li $ toWash s) l
167 stripMailto ('m':'a':'i':'l':'t':'o':':':xs) = xs
174 fontOp Strike = strike