]> ruin.nu Git - yawbih.git/blobdiff - Main.hs
possible to list all keywords
[yawbih.git] / Main.hs
diff --git a/Main.hs b/Main.hs
index eb1e82d7cdd1ef04a925e4b392220575199fa698..418c16820b88fafff475bcc544eee02f227bcabd 100644 (file)
--- a/Main.hs
+++ b/Main.hs
@@ -6,6 +6,7 @@ import CGIOutput
 import CGITypes
 import System
 import Wiki
+import Control.Monad
 
 import Text.ParserCombinators.Parsec
 
@@ -65,11 +66,16 @@ parseText full = case parse wikiParser "" full of
 footer db key = do
        hr empty
        table $ tr $ do
-               td $ submitLink0 (editPage db key) (text "Edit this keyword")
-               td $ submitLink0 (listRevs db key) (text "List old versions")
+               td $ submitLink0 (showPage db "MainPage") (text "Back to main page")
+               when (e key) $ td $ submitLink0 (editPage db key) (text "Edit this keyword")
+               when (e key) $ td $ submitLink0 (listRevs db key) (text "List old versions")
+               td $ submitLink0 (listKeywords db) (text "List all keywords")
                td $ text "Keyword: " 
                td $ activate (showPage db) textInputField empty
 
+e "" = False
+e _ = True
+
 listRevs db key = do 
        list <- io $ getList db key 
        standardQuery key $ table $ do
@@ -77,6 +83,14 @@ listRevs db key = do
                        ["Id", "Date", "Author", "Comment"]
                mapM (revRow db key) list
 
+listKeywords db = do 
+       list <- io $ listKeys db
+       standardQuery "List of keywords" $ do
+               table (do
+                       tr $ th (text "Keyword")
+                       mapM (\key -> tr $ td $ linkKey db key) list)
+               footer db ""
+
 linkKey db key = submitLink0 (showPage db key) (text key)
 
 revRow db key (id, date, author, comment) = tr $ do