3 import CGI hiding (div, head, map, span, Text)
12 import Text.ParserCombinators.Parsec
14 --backend = createPGB "hostname" "database" "user" "password"
15 --If you want to implement this function here, then remove the import of Backend
19 runWithHook [] (\(key:act) -> showPage db (filter (/= '\\') key)) $ showPage db "itproj3"
22 s <- io $ getCurrent db key
25 Just (x,_) -> return x
26 standardQuery key $ do
27 t <- p $ makeTextarea s' (attr_SS "rows" "25" ## attr_SS "cols" "120" ## 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
55 s <- io $ getCurrent db key
56 standardQuery key $ do
58 Nothing -> text "No text added for this keyword"
59 Just (full, date) -> do
61 p $ tt $ text $ "Last edited: "++date
64 parseText full = case parse wikiParser "" full of
71 parseLatex full = case parse wikiParser "" full of
72 Right n -> pre $ text $ toLatex n
82 searchKey <- td $ textInputField empty
83 td $ defaultSubmit (F1 searchKey) (\(F1 sk) -> showPage db (value sk)) (attr "value" "Go")
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")
90 --td $ activate (showPage db) textInputField empty
96 list <- io $ getList db key
97 standardQuery key $ do
99 tr $ mapM (\header -> th (text header))
100 ["Id", "Date", "Author", "Comment"]
101 mapM (revRow db key) list
105 list <- io $ listKeys db
106 standardQuery "List of keywords" $ do
108 tr $ th (text "Keyword")
109 mapM (\key -> tr $ td $ linkKey db key) list)
112 linkKey db key = submitLink0 (showPage db key) (text key)
114 revRow db key (id, date, author, comment) = tr $ do
115 td $ submitLink0 (showRev db key id) (text id)
117 td $ linkKey db author
120 showRev db key id = do
121 s <- io $ get db key id
122 standardQuery key $ do
124 Nothing -> text "No such revision"
125 Just s -> parseText s
127 submitLink0 (changeCurrent db key id) (text "Set this version as the current one")
129 changeCurrent db key id = do
130 b <- io $ setCurrent db key id
131 if b then showPage db key
132 else standardQuery key $ do
133 text "Could not set this revision as the current active one."
137 toWash [] = return ()
138 toWash ((Paragraph):xs) = do
141 toWash ((Text s):xs) = do
144 toWash ((Link l d):xs) = do
145 hlink (URL {unURL = ("wiki?"++l)}) (text d)
147 toWash ((Font o d):xs) = do
150 toWash ((Heading n d):xs) = do
153 toWash ((Url l):xs) = do
154 hlink (URL {unURL = (l)}) (text $ stripMailto l)
156 toWash ((Pre s):xs) = do
159 toWash ((List o l):xs) = do
160 listType o $ mapM (\s -> li $ toWash s) l
166 stripMailto ('m':'a':'i':'l':'t':'o':':':xs) = xs
173 fontOp Strike = strike