A jQuery plugin
that sets a div or span to show a Google Search Blogbar.
If you find this plugin useful please
vote for it
on the jQuery site.
The current version is 1.0.2 and is available under the GPL and MIT licences. For more detail see the documentation reference page.
The Google Search Blogbar functionality can easily be added to a division. It displays a set of blog links based on provided search terms. The default search term is 'jquery'.
Google places some restrictions on your use of this service, including obtaining a key specific to a target URL providing the service, making the Web site freely accessible, and showing included Google branding. See the link above for more details.
You can also remove the GSBlogbar widget if it is no longer required.
Default blogbar:
$('#defaultBlogbar').gsblogbar();
$('#removeBlogbar').toggle(
function() {
$(this).text('Re-attach');
$('#defaultBlogbar').gsblogbar('destroy');
},
function() {
$(this).text('Remove');
$('#defaultBlogbar').gsblogbar();
}
);
You can override the defaults globally as shown below:
$.gsblogbar.setDefaults({horizontal: true});
Processed fields are marked with a class of hasGSBlogbar
and are not re-processed if targetted a second time.
You have some control over the appearance of the blogbar. The settings marked with an asterisk (*) only apply to the vertical layout.
Formatting:
$('#formatBlogbar').gsblogbar();
var targets = [$.gsblogbar.targetSelf, $.gsblogbar.targetBlank,
$.gsblogbar.targetTop, $.gsblogbar.targetParent];
var orders = [$.gsblogbar.orderRelevance, $.gsblogbar.orderDate];
$('#format input,#format select').change(function() {
$('#formatBlogbar').gsblogbar('change',
{title: $('#title').val(),
horizontal: $('#orientation').val() == 'true',
verticalCompressed: $('#compressed').val() == 'true',
manyResults: $('#results').val() == 'true',
linkTarget: targets[$('#target').val()],
order: orders[$('#order').val()]});
});
You can restrict the search to a single blog Web site.
Restricted search: Web site
$('#restrictBlogbar').gsblogbar(
{siteRestriction: 'http://googleajaxsearchapi.blogspot.com/'});
$('#restrict').click(function() {
$('#restrictBlogbar').gsblogbar('change',
{siteRestriction: $('#site').val()});
});
You can show more detail about a blog entry when in horizontal mode by providing the jQuery selector for a container.
Extra info:
$('#extraBlogbar').gsblogbar({currentResult: '#extraInfo'});
You can set the blogbar up to cycle automatically through a set of search terms, with control over the interval between cycles and the order. Just pass an array of search terms when attaching the blogbar.
For horizontal blogbars, the cycle time is the interval between showing individual blog entries, whereas for vertical ones it is the interval between showing blog entries for one of the search terms.
For both orientations, the mode dictates the order of the search terms, not the individual blog entries.
Cycling:
$('#cycleBlogbar').gsblogbar(
{search: ['jquery', 'australia', 'cats', 'tennis']});
var times = [$.gsblogbar.cycleVShort,
$.gsblogbar.cycleShort, $.gsblogbar.cycleMedium,
$.gsblogbar.cycleLong, $.gsblogbar.cycleManual];
var modes = [$.gsblogbar.cycleRandom, $.gsblogbar.cycleLinear];
$('#cycle select').change(function() {
$('#cycleBlogbar').gsblogbar('change',
{cycleTime: times[$('#cycleTime').val()],
cycleMode: modes[$('#cycleMode').val()],
horizontal: $('#orientation2').val() == 'true'});
});
You can provide preset links or free text entry to generate new blog searches by using the 'search' command. If there are no matching search results, the bar defaults to results for 'Google'.
Searchable blogbar:
$('#searchBlogbar').gsblogbar();
$('#presetTerm').change(function() {
$('#searchBlogbar').gsblogbar('search', $(this).val());
});
$('#doSearch').click(function() {
$('#searchBlogbar').gsblogbar('search', $('#searchTerm').val());
});
This tab highlights examples of this plugin in use "in the wild".
None as yet.
To add another example, please contact me (kbwood{at}iinet.com.au) and provide the plugin name, the URL of your site, its title, and a short description of its purpose and where/how the plugin is used.
A full list of all possible settings is shown below. Note that not all would apply in all cases. For more detail see the documentation reference page.
$(selector).gsblogbar({
horizontal: true, // True for horizontal display, false for vertical
verticalCompressed: false, // True for compressed layout when vertical,
// false for expanded
title: '', // Title for the bar
search: 'jquery', // Single or list of search terms
siteRestriction: '', // Specify a site to restrict searches to
order: this.orderRelevance, // Control the order of the results
manyResults: false, // True for many results, false for only a few
cycleTime: this.cycleManual, // Time between cycles of the search terms
cycleMode: this.cycleLinear, // Mode of cycling through the search terms
linkTarget: this.targetSelf, // Control where the blog links open
currentResult: '' // jQuery selector, jQuery object, or element for
// additional info for current entry when horizontal
});
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script><script type="text/javascript">
$.googleSearchKey = 'ABQIAAAA...2Z_iWfuw';
</script><style type="text/css">@import "jquery.gsblogbar.css";</style>
<script type="text/javascript" src="jquery.gsblogbar.js"></script>
Alternately, you can use the packed version jquery.gsblogbar.pack.js (3.2K vs 7.2K)
or minified version jquery.gsblogbar.min.js (3.4K, 1.4K when zipped).divs or spans.
$(selector).gsblogbar({search: ...});
For more detail see the documentation reference page.
None as yet.
Contact Keith Wood at kbwood{at}iinet.com.au with comments or suggestions.
| Version | Date | Changes |
|---|---|---|
| 1.0.2 | 28 May 2011 |
|
| 1.0.1 | 26 Dec 2009 |
|
| 1.0.0 | 29 Nov 2008 |
|