{-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE NamedFieldPuns #-} module Bamboo.Controller.Search where import Bamboo.Controller.Env import qualified Bamboo.Model.Post as Post import qualified Bamboo.Type.State as S search :: Controller search = do init_state s <- get let key = s.env.param_with_default "s" "" query = s.env.uri (posts, pager) <- Post.search key .io >>= (mapM init_post_meta_data) >>= paged put s { uid = query , pager , posts , S.resource_title = query , search_key = key }