Permalink
Browse files

bookbrainz-server: Search and display editions in search results

  • Loading branch information...
1 parent 95ab71f commit 0066b6522d1a7e6d8a8870e018a1ea95cf06d86f Oliver Charles committed Jun 23, 2012
@@ -23,8 +23,9 @@ search = do
case r of
Just submission -> do
books <- S.searchBooks (Forms.query submission)
+ editions <- S.searchEditions (Forms.query submission)
persons <- S.searchPersons (Forms.query submission)
publishers <- S.searchPublishers (Forms.query submission)
- output $ V.searchResults books persons publishers
+ output $ V.searchResults books editions persons publishers
Nothing -> output $ V.searchPortal v
@@ -11,26 +11,34 @@ import qualified Text.Digestive.View as Forms
import qualified BookBrainz.Search as S
import BookBrainz.Web.Sitemap as Sitemap (Sitemap(..), showURL)
-import BookBrainz.Web.View (pageLayout, detailTable, linkBook, linkPerson, linkPublisher, View)
+import BookBrainz.Web.View (pageLayout, detailTable, linkBook, linkEdition, linkPerson, linkPublisher, View)
import BookBrainz.Web.View.Role
--------------------------------------------------------------------------------
-- | Given a list of search results, display them in a human readable
-- table.
searchResults :: SearchResults S.SearchableBook
-- ^ The 'Book' search results.
+ -> SearchResults S.SearchableEdition
+ -- ^ The 'Edition' search results.
-> SearchResults S.SearchablePerson
-- ^ The 'Person' search results.
-> SearchResults S.SearchablePublisher
-- ^ The 'Publisher' search results.
-> View
-searchResults books persons publishers = pageLayout Nothing $ do
+searchResults books editions persons publishers = pageLayout Nothing $ do
H.h2 "Books"
detailTable [("Score", ["score"])
,("Book", [])
,("People", [])
]
$ formatBook `map` getResults books
+ H.h2 "Editions"
+ detailTable [("Score", ["score"])
+ ,("Edition", [])
+ ,("People", [])
+ ]
+ $ formatEdition `map` getResults editions
H.h2 "People"
detailTable [("Score", ["score"])
,("Name", [])
@@ -45,6 +53,9 @@ searchResults books persons publishers = pageLayout Nothing $ do
formatBook r = formatResult r [ linkBook $ S.bookResult $ result r
, roleList $ S.bookRoles $ result r
]
+ formatEdition r = formatResult r [ linkEdition $ S.editionResult $ result r
+ , roleList $ S.editionRoles $ result r
+ ]
formatPerson r = formatResult r [ linkPerson $ S.personResult $ result r
]
formatPublisher r = formatResult r [ linkPublisher $ S.publisherResult $ result r

0 comments on commit 0066b65

Please sign in to comment.