Tweak hoogle style and behavior #47

This commit is contained in:
Michael Sloan 2014-12-27 19:57:24 -08:00
parent c791c81ede
commit f635977b02
7 changed files with 38 additions and 13 deletions

View File

@ -37,12 +37,13 @@ getHoogleR slug = do
, hqiLimitTo = count'
, hqiOffsetBy = offset
}
Nothing -> return $ HoogleQueryBad "No query provided"
let q = fromMaybe "" mquery
Nothing -> return $ HoogleQueryOutput "" [] Nothing
let queryText = fromMaybe "" mquery
pageLink p = (HoogleR slug
, (if exact then (("exact", "true"):) else id)
$ (maybe id (\q' -> (("q", q'):)) mquery)
[("page", tshow p)])
snapshotLink = SnapshotR slug StackageHomeR
hoogleForm = $(widgetFile "hoogle-form")
defaultLayout $ do
setTitle "Hoogle Search"

View File

@ -21,6 +21,10 @@ getStackageHomeR slug = do
then Just False
else Nothing
base = maybe 0 (const 1) minclusive :: Int
hoogleForm =
let queryText = "" :: Text
exact = False
in $(widgetFile "hoogle-form")
Entity sid _stackage <- runDB $ getBy404 $ UniqueSnapshot slug
defaultLayout $ do
setTitle $ toHtml $ stackageTitle stackage

View File

@ -1,5 +1,5 @@
<form action=@{HoogleR slug}>
<input type=search autofocus name=q value=#{q} placeholder="Hoogle Search Phrase" .search>
<form .hoogle action=@{HoogleR slug}>
<input type=search autofocus name=q value=#{queryText} placeholder="Hoogle Search Phrase" .search>
<input .btn type="submit" value="Search">
<label .checkbox .exact-lookup for=exact title="Only find identifiers matching your search term precisely">
<input type=checkbox name=exact :exact:checked #exact>

View File

@ -1,8 +1,14 @@
input[type=submit] {
margin-bottom: 10px;
form.hoogle {
margin-bottom: 20px;
.search {
width: 25em;
}
input {
margin-bottom: 0;
}
}
.exact-lookup {
display: inline-block;
margin-left: 0.5em;
margin-left: 1em;
}

View File

@ -1,11 +1,13 @@
<div .container>
<div .content>
<h1>Hoogle Search
<p>Within <a href=@{snapshotLink}>#{stackageTitle stackage}</a>
^{hoogleForm}
$case mresults
$of HoogleQueryBad _err
$of HoogleQueryOutput query results mtotalCount
<p>Searched for: #{preEscapedToHtml query}
$of HoogleQueryBad err
<p>#{err}
<p>For information on what queries should look like, see the <a href="http://www.haskell.org/haskellwiki/Hoogle">hoogle user manual</a>.
$of HoogleQueryOutput _query results mtotalCount
$if null results
<p>Your search produced no results.
$else

View File

@ -6,6 +6,16 @@ ol.search-results {
.self {
margin-bottom: 0;
/* Use bold instead of italics to indicate matching part of search */
a {
b {
font-weight: normal;
}
i {
font-weight: bold;
font-style: normal;
}
}
}
table.sources {
@ -24,7 +34,7 @@ table.sources {
.docs {
white-space: pre-wrap;
background: #f8f8f8;
background: #e8e8e8;
}
.docs, .nodocs {

View File

@ -38,8 +38,10 @@ $newline never
<a href=@{SnapshotR slug StackageCabalConfigR}?global=true>
the global configuration instructions
<h3>
Packages
<h3>Hoogle
^{hoogleForm}
<h3>Packages
<div .container .content>
<div .packages>