I have just released Hoogle 4.2, which adds the feature Hoogle Embed, letting you embed a small Hoogle powered search box on any web page. For an example, visit the Hoogle page on my website, and try typing "database" in the search box on the right. You should see:
As you type, the search box will perform Hoogle searches on the Hoogle API, and display the results. Selecting a result will visit the associated documentation. Pressing the Search button will perform the search at the Hoogle website.
- Hoogle Embed has been tested in Chrome, Firefox and IE.
Using IEUsing IE 7 or below you may not see results unless the page being displayed is on the same server as the Hoogle instance (i.e. haskell.org), due to restrictions on cross domain AJAX requests. This limitation can probably be overcome with additional work, if people are interested. - Hoogle Embed degrades gracefully if the browser does not support Javascript, leaving just the search box.
- Configuration options allow you to automatically add a prefix or suffix to the users search, for example adding +hoogle to search only the Hoogle API.
- This feature works with either a custom Hoogle instance, or the standard version on haskell.org.
Using Hoogle Embed in your web page
To include Hoogle Embed on a web page, simply add the following piece of HTML:
<script type="text/javascript" src="http://haskell.org/hoogle/datadir/resources/jquery-1.4.2.js"></script>
<script type="text/javascript" src="http://haskell.org/hoogle/datadir/resources/hoogle.js"></script>
<form action="http://haskell.org/hoogle/" method="get">
<input type="text" name="hoogle" id="hoogle" accesskey="1" />
<input type="hidden" name="prefix" value="+base" />
<input type="submit" value="Search" />
</form>
To use a different Hoogle server change the action field of the form. To specify a prefix/suffix for all searches add an input field with the name prefix/suffix. For example, the above snippet only searches the base pacakge. By eliminating the prefix line it will search using the default Hoogle settings (the Haskell platform).
The Hoogle Embed feature is usable on any web page, but I think would be particularly effective on pages such as the Hackage page for a package, or for any Haddock documentation (perhaps when using a flag such as --hoogle-embed). I encourage anyone who is interested to submit patches to the relevant projects.
Hoogle Manual
I am currently considering the issue of documentation, and would welcome other peoples thoughts. Currently the Hoogle manual is hosted on the Haskell Wiki, but is somewhat out of date. For all other packages, I tend to write an HTML manual stored in the darcs repo, such as for hlint. There are advantages to both formats - the wiki can be easily edited by many people, but the darcs manual can be updated simultaneously with the code and is available offline (most Hoogle work is done on a train without internet access, so this issue is very relevant). My current thought is to remove the wiki page and move it's contents into darcs.
Edit: Fixed the Javascript links.
Edit 2: Hoogle Embed now works cross domain in IE 8 and above.
Great! Testing at http://hledger.org/DEVELOPMENT.html. I don't think instant search is working there - should it be ?
ReplyDeleteSorry, I gave the wrong URL's for the Javascript - they should have been under hoogle/datadir/resources/*.js, not just hoogle/*.js. I've copied the files to both though, so your hledger search now works - but I recommend changing the URL's since the other ones are the ones I regularly update.
ReplyDeleteThanks for pointing out the problem.
Awesome, fixed.
ReplyDeleteHow is IE's security policy different from the other browsers that constrains your script?
ReplyDeleteWei: By default, no browser lets XmlHttpRequest retrieve pages from a different domain. In Firefox/Chrome there is an exception if the server you send a request to explicitly allows it (using Access-Control-Allow-Origin *, which Hoogle sends). In IE 6/7 there is no way to retrieve the information without horrible IFRAME trickery, which isn't very flexible, and is very hacky. In IE 8 you can use the XDomainRequest object, but it's annoying to use a different method just for IE (but I probably will eventually...).
ReplyDeletePart of the problem is that IE6 is still in use, and IE8 is fairly old, whereas no one runs old versions of Chrome or Firefox. New specifications (like cross site AJAX) therefore aren't in IE.
Wei: I now updated the code so it works on IE8 and above, but not in IE7/6.
ReplyDeleteMaybe a wiki backed by the Hoogle darcs repo via gitit? You can obliterate the default gitit patches.
ReplyDeleteEric: I did consider that. Then I realised I don't have the time/effort/energy to set it up - I could review/apply the patches but that's about it. If anyone wanted to do the rest that would be great...
ReplyDeletewhy do you ignore problem in you haskell libraries. I wrote you emails about CmdArgs issues more then two times. You ignore its why ?
ReplyDeleteAHTOH (very sorry for the name, my browser is failing to get the right characters): I'm sorry for not responding, but I haven't received your emails. Could you forward them again, put their contents as a message on this blog, or paste your email address here? I definitely want to hear any problems you are having with cmdargs!
ReplyDeletei wrote you from acheshkov@gmail.com to ndmitchell@gmail.com.
ReplyDeleteI will resend my letter today.
Thanks
I got an email from you this morning (expect a reply shortly!), searched my inbox and found 5 additional emails - but all sent to the web-devel list about other things. I checked spam and found nothing there. It seems something lost your messages.
ReplyDelete