bamboo-2009.6.6: src/Bamboo/Controller/Search.hs
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NamedFieldPuns #-}
module Bamboo.Controller.Search where
import Bamboo.Controller.Env hiding (query)
import qualified Bamboo.Model.Post as Post
import qualified Bamboo.Type.State as S
import qualified Bamboo.View.Control.Search as SearchV
search_controller :: Controller
search_controller = 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
}
search_view :: View
search_view = SearchV.view > output_html
search :: Application
search = run search_controller search_view