]> ruin.nu Git - yawbih.git/commitdiff
possible to list all keywords
authorMichael Andreen <harv@ruin.nu>
Mon, 13 Dec 2004 11:29:27 +0000 (11:29 +0000)
committerMichael Andreen <harv@ruin.nu>
Sat, 26 Jan 2008 11:33:18 +0000 (12:33 +0100)
Main.hs
Wiki.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
diff --git a/Wiki.hs b/Wiki.hs
index 231dda46217123dc1cee063d5dbc150a1c8f4f1f..a2b6548509f8282f73af4d2059216c4b91c23673 100644 (file)
--- a/Wiki.hs
+++ b/Wiki.hs
@@ -196,7 +196,7 @@ instance Backend PGB where
                                return id
 
        listKeys (PGB db) = do
-               list <- selectReturnTuples db $ "SELECT keyword FROM fulltexts ORDER BY lower(keyword)"
+               list <- selectReturnTuples db $ "SELECT keyword FROM fulltexts GROUP BY keyword ORDER BY lower(keyword)"
                case list of
                        [[]] -> return []
                        _ -> mapM (\[key] -> return key) list