From 64b58e5b75b4c8e95574fa9080166f5cf1079005 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Mon, 13 Dec 2004 11:29:27 +0000 Subject: [PATCH] possible to list all keywords --- Main.hs | 18 ++++++++++++++++-- Wiki.hs | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Main.hs b/Main.hs index eb1e82d..418c168 100644 --- 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 231dda4..a2b6548 100644 --- 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 -- 2.39.2