{- Copyright (C) 2013 John Lenz This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . -} module Handler.Tags( tagHeader , tagWidget , postRetagThreadR , postRetagMessageR , postCustomRetagThreadR , postCustomRetagMessageR ) where import Import --import Data.Hashable (hash) import qualified Data.Text as T displayTag :: T.Text -> WidgetT App IO () displayTag "unread" = [whamlet|unread|] displayTag t = [whamlet|#{t}|] {- displayTag t = case hash t `mod` 5 of 0 -> [whamlet|#{t}|] 1 -> [whamlet|#{t}|] 2 -> [whamlet|#{t}|] 3 -> [whamlet|#{t}|] _ -> [whamlet|#{t}|] -} -- | A widget consisting of the retag buttons followed by the current tag list. tagWidget :: Either SearchResult Message -> WidgetT App IO () tagWidget x = do let url = case x of Left s -> RetagThreadR (searchThread s) Right m -> RetagMessageR (messageId m) let customUrl = case x of Left s -> CustomRetagThreadR (searchThread s) Right m -> CustomRetagMessageR (messageId m) let tags = either searchTags messageTags x retags <- extraRetag <$> getExtra [whamlet| $forall r <- retags