Skip to content

Commit

Permalink
Search ignores accents
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Nov 10, 2010
1 parent b1ef726 commit ed48dd3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Handler/Root.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ import Haskellers hiding (Filter)
import Yesod.Form.Core
import qualified Data.ByteString.Lazy.UTF8 as L
import Data.Digest.Pure.MD5 (md5)
import Data.Char (toLower, isSpace)
import Data.Char (toLower, isSpace, isMark)
import Data.Maybe (fromMaybe)
import System.Random (newStdGen)
import System.Random.Shuffle (shuffle')
import Data.IORef (readIORef)
import Control.Applicative
import Data.List (isInfixOf)
import Yesod.Form.Jquery
import Data.Time
import qualified Data.Text as T
import Data.Text.ICU.Normalize

-- This is a handler function for the GET request method on the RootR
-- resource pattern. All of your resource patterns are defined in
Expand Down Expand Up @@ -91,7 +92,10 @@ applyFilter f p = and
case y f of
Nothing -> True
Just z -> x z
name x = map toLower x `isInfixOf` map toLower (profileName p)
norm = T.filter validChar . T.map toLower . normalize NFKD . T.pack
validChar = not . isMark
isInfixOf x y = norm x `T.isInfixOf` norm y
name x = x `isInfixOf` profileName p
minsince x =
case userHaskellSince $ profileUser p of
Nothing -> False
Expand Down
2 changes: 2 additions & 0 deletions haskellers.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ executable simple-server
data-default,
mime-mail,
web-routes,
text,
text-icu,
utf8-string
ghc-options: -Wall -Werror
extensions: TemplateHaskell, QuasiQuotes, TypeFamilies
Expand Down

0 comments on commit ed48dd3

Please sign in to comment.