aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad
diff options
context:
space:
mode:
authorgwern0 <gwern0@gmail.com>2008-05-19 21:09:12 +0200
committergwern0 <gwern0@gmail.com>2008-05-19 21:09:12 +0200
commit64bcd5c45fb82b118365e7c9fbd183346208bc3d (patch)
treed1e83a234244bd2361ba3ca428dde8ab89de4405 /XMonad
parentd6fec655025e61f3e12dc9173c4393d3c140b204 (diff)
downloadXMonadContrib-64bcd5c45fb82b118365e7c9fbd183346208bc3d.tar.gz
XMonadContrib-64bcd5c45fb82b118365e7c9fbd183346208bc3d.tar.xz
XMonadContrib-64bcd5c45fb82b118365e7c9fbd183346208bc3d.zip
revamp Search.hs to export a replacement for simpleEngine
It's called searchEngine now, and is a wrapper around the SearchEngine type. Different type as well darcs-hash:20080519190912-f7719-3c66bdaa2b029ea48020f0fa26026408ff97eca5.gz
Diffstat (limited to 'XMonad')
-rw-r--r--XMonad/Actions/Search.hs70
1 files changed, 35 insertions, 35 deletions
diff --git a/XMonad/Actions/Search.hs b/XMonad/Actions/Search.hs
index 9074f91..74426bc 100644
--- a/XMonad/Actions/Search.hs
+++ b/XMonad/Actions/Search.hs
@@ -1,21 +1,20 @@
-{- |
- Module : XMonad.Actions.Search
- Copyright : (C) 2007 Gwern Branwen
- License : None; public domain
+{- | Module : XMonad.Actions.Search
+ Copyright : (C) 2007 Gwern Branwen
+ License : None; public domain
- Maintainer : <gwern0@gmail.com>
- Stability : unstable
- Portability : unportable
+ Maintainer : <gwern0@gmail.com>
+ Stability : unstable
+ Portability : unportable; depends on XSelection, XPrompt
- A module for easily running Internet searches on web sites through xmonad.
- Modeled after the handy Surfraw CLI search tools at <https://secure.wikimedia.org/wikipedia/en/wiki/Surfraw>.
+ A module for easily running Internet searches on web sites through xmonad.
+ Modeled after the handy Surfraw CLI search tools at <https://secure.wikimedia.org/wikipedia/en/wiki/Surfraw>.
- Additional sites welcomed.
--}
+ Additional sites welcomed. -}
module XMonad.Actions.Search ( -- * Usage
-- $usage
search,
SearchEngine,
+ searchEngine,
promptSearch,
promptSearchBrowser,
selectSearch,
@@ -66,7 +65,7 @@ import XMonad.Util.XSelection (getSelection)
want, the browser you want, and anything special they might need;
this whole line is then bound to a key of you choosing in your
xmonad.hs. For specific examples, see each function. This module
- is easily extended to new sites by using 'simpleEngine'.
+ is easily extended to new sites by using 'searchEngine'.
The currently available search engines are:
@@ -175,37 +174,38 @@ data SearchEngine = SearchEngine Name Site
search :: Browser -> Site -> Query -> X ()
search browser site query = safeSpawn browser (site ++ (escape query))
-{- | Given a base URL, create the SearchEngine that escapes the query and
- appends it to the base. You can easily define a new engine locally using SearchEngine
- without needing to modify Search.hs:
+{- | Given a base URL, create the 'SearchEngine' that escapes the query and
+ appends it to the base. You can easily define a new engine locally using
+ exported functions without needing to modify "XMonad.Actions.Search":
- > newEngine = SearchEngine "site" "http://site.com/search="
+> myNewEngine = searchEngine "site" "http://site.com/search="
- The important thing is that the site has a interface which accepts the query
- string as part of the URL. Alas, the exact URL to feed simpleEngine varies
- from site to site, often considerably. Generally, examining the resultant URL
- of a search will allow you to reverse-engineer it if you can't find the
- necessary URL already described in other projects such as Surfraw. -}
---simpleEngine :: Name -> Query -> SearchEngine
---simpleEngine site query = site ++ escape query
+ The important thing is that the site has a interface which accepts the escaped query
+ string as part of the URL. Alas, the exact URL to feed searchEngine varies
+ from site to site, often considerably, so there's no general way to cover this.
+
+ Generally, examining the resultant URL of a search will allow you to reverse-engineer
+ it if you can't find the necessary URL already described in other projects such as Surfraw. -}
+searchEngine :: Name -> Site -> SearchEngine
+searchEngine name site = SearchEngine name site
-- The engines.
amazon, dictionary, google, hoogle, imdb, maps, mathworld,
scholar, wayback, wikipedia, youtube :: SearchEngine
-amazon = SearchEngine "amazon" "http://www.amazon.com/exec/obidos/external-search?index=all&keyword="
-dictionary = SearchEngine "dictionary" "http://dictionary.reference.com/browse/"
-google = SearchEngine "google" "http://www.google.com/search?num=100&q="
-hoogle = SearchEngine "hoogle" "http://www.haskell.org/hoogle/?q="
-imdb = SearchEngine "imdb" "http://www.imdb.com/Find?select=all&for="
-maps = SearchEngine "maps" "http://maps.google.com/maps?q="
-mathworld = SearchEngine "mathworld" "http://mathworld.wolfram.com/search/?query="
-scholar = SearchEngine "scholar" "http://scholar.google.com/scholar?q="
-wikipedia = SearchEngine "wikipedia" "https://secure.wikimedia.org/wikipedia/en/wiki/Special:Search?go=Go&search="
-youtube = SearchEngine "youtube" "http://www.youtube.com/results?search_type=search_videos&search_query="
+amazon = searchEngine "amazon" "http://www.amazon.com/exec/obidos/external-search?index=all&keyword="
+dictionary = searchEngine "dictionary" "http://dictionary.reference.com/browse/"
+google = searchEngine "google" "http://www.google.com/search?num=100&q="
+hoogle = searchEngine "hoogle" "http://www.haskell.org/hoogle/?q="
+imdb = searchEngine "imdb" "http://www.imdb.com/Find?select=all&for="
+maps = searchEngine "maps" "http://maps.google.com/maps?q="
+mathworld = searchEngine "mathworld" "http://mathworld.wolfram.com/search/?query="
+scholar = searchEngine "scholar" "http://scholar.google.com/scholar?q="
+wikipedia = searchEngine "wikipedia" "https://secure.wikimedia.org/wikipedia/en/wiki/Special:Search?go=Go&search="
+youtube = searchEngine "youtube" "http://www.youtube.com/results?search_type=search_videos&search_query="
{- This doesn't seem to work, but nevertheless, it seems to be the official
method at <http://web.archive.org/collections/web/advanced.html> to get the
latest backup. -}
-wayback = SearchEngine "wayback" "http://web.archive.org/"
+wayback = searchEngine "wayback" "http://web.archive.org/"
{- | Like 'search', but for use with the output from a Prompt; it grabs the
Prompt's result, passes it to a given searchEngine and opens it in a given
@@ -236,4 +236,4 @@ selectSearchBrowser browser (SearchEngine _ site) = search browser site =<< getS
This specializes "selectSearchBrowser" by supplying the browser argument as
supplied by 'getBrowser' from "XMonad.Prompt.Shell". -}
selectSearch :: SearchEngine -> X ()
-selectSearch engine = liftIO getBrowser >>= \browser -> selectSearchBrowser browser engine \ No newline at end of file
+selectSearch engine = liftIO getBrowser >>= \browser -> selectSearchBrowser browser engine