Skip to content

Commit

Permalink
added query to site
Browse files Browse the repository at this point in the history
  • Loading branch information
Mast3rwaf1z committed Sep 3, 2024
1 parent 10c0759 commit 9cb10eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/Pages/Pages.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pages :: [Page]
pages = [
("/search", "Search for pages", \req -> do
let [_, query] = getArgs req
return $ layout $ search pages $ mkRegex query
return $ layout $ search pages query
),
("/contact", "My Contact Information", \_ -> return $ layout contact),
("/sources", "Sources for this website and my source code", \_ -> return $ layout sources),
Expand Down
8 changes: 4 additions & 4 deletions app/Pages/Search/Search.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Pages.Search.Search where
import Text.Blaze.Html (Html)
import IHP.HSX.QQ (hsx)
import Text.Regex (Regex, matchRegex)
import Text.Regex (Regex, matchRegex, mkRegex)
import Network.Wai (Request, Response)
import Helpers.Section (section)

Expand All @@ -13,10 +13,10 @@ findPage ((target, description, _):xs) regex = case matchRegex regex target of
_ -> (target, description) : findPage xs regex
findPage [] _ = []

search :: [Page] -> Regex -> Html
search :: [Page] -> String -> Html
search pages query = [hsx|
<h1>Search Results:</h1>
{section $ makeResults 1 $ findPage pages query}
<h1>Search Results: [query={query}]</h1>
{section $ makeResults 1 $ findPage pages $ mkRegex query}
|]
where
makeResults :: Int -> [(String, String)] -> Html
Expand Down

0 comments on commit 9cb10eb

Please sign in to comment.