refined search site inner workings
This commit is contained in:
parent
77d6089588
commit
18dc01b2c3
1 changed files with 12 additions and 15 deletions
|
@ -12,18 +12,13 @@ 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
|
a <- return $ (decode (responseBody ru) :: Maybe (SearchResult SearchUser))
|
||||||
a <- return $ (decode (responseBody ru) :: Maybe (SearchResult SearchUser))
|
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
|
||||||
|
|
Loading…
Reference in a new issue