refined search site inner workings

This commit is contained in:
nek0 2015-10-17 21:52:01 +02:00
parent 77d6089588
commit 18dc01b2c3

View file

@ -12,7 +12,6 @@ import System.FilePath.Posix
getSearchR :: Handler Html getSearchR :: Handler Html
getSearchR = do getSearchR = do
((res, widget), _) <- runFormGet searchForm ((res, widget), _) <- runFormGet searchForm
results <-
case res of case res of
FormSuccess query -> do FormSuccess query -> do
(ru, ra, rm, rc) <- getResults query (ru, ra, rm, rc) <- getResults query
@ -20,10 +19,6 @@ getSearchR = do
b <- return $ (decode (responseBody ra) :: Maybe (SearchResult SearchAlbum)) b <- return $ (decode (responseBody ra) :: Maybe (SearchResult SearchAlbum))
c <- return $ (decode (responseBody rm) :: Maybe (SearchResult SearchMedium)) c <- return $ (decode (responseBody rm) :: Maybe (SearchResult SearchMedium))
d <- return $ (decode (responseBody rc) :: Maybe (SearchResult SearchComment)) d <- return $ (decode (responseBody rc) :: Maybe (SearchResult SearchComment))
return $ Just (a, b, c, d)
_ -> return $ Nothing
case results of
Just (a, b, c, d) -> do
hitListA <- case a of hitListA <- case a of
Just as -> return $ hits $ searchHits as Just as -> return $ hits $ searchHits as
Nothing -> return [] Nothing -> return []
@ -77,10 +72,12 @@ getSearchR = do
mediumList <- return . catMaybes =<< mapM (\i -> runDB $ selectFirst [MediumId ==. i] []) mediumIdList mediumList <- return . catMaybes =<< mapM (\i -> runDB $ selectFirst [MediumId ==. i] []) mediumIdList
commentList <- return . catMaybes =<< mapM (\i -> runDB $ selectFirst [CommentId ==. i] []) commentIdList commentList <- return . catMaybes =<< mapM (\i -> runDB $ selectFirst [CommentId ==. i] []) commentIdList
let allEmpty = (null userList) && (null albumList) && (null mediumList) && (null commentList) let allEmpty = (null userList) && (null albumList) && (null mediumList) && (null commentList)
defaultLayout $ defaultLayout $ do
setTitle $ toHtml $ "Eidolon :: Search results for " ++ (T.unpack query)
$(widgetFile "result") $(widgetFile "result")
Nothing -> _ ->
defaultLayout $ defaultLayout $ do
setTitle "Eidolon :: Search"
$(widgetFile "search") $(widgetFile "search")
searchForm :: Form T.Text searchForm :: Form T.Text