diff --git a/google-taglib/htdocs/docs.html b/google-taglib/htdocs/docs.html index 7290805..8780f4a 100644 --- a/google-taglib/htdocs/docs.html +++ b/google-taglib/htdocs/docs.html @@ -427,7 +427,7 @@ code {font-size:10pt}
- site + site
Restricts the search to documents within the specfied @@ -437,7 +437,7 @@ code {font-size:10pt}
- type + type
Specifies the file type to be searched. (e.g.: pdf) @@ -675,12 +675,9 @@ code {font-size:10pt}

The <google:next/> tag is used to - - used to display a link to more search results.
The <google:previous/> tag is used to used to display a link to previous search results.
-

Tag Syntax

@@ -739,11 +736,8 @@ code {font-size:10pt}

- The <google:searchComments/> - tag is used to - - - display the comments (if any) included with the current result set. + The <google:searchComments/> + tag is used to display the comments (if any) included with the current result set.

@@ -755,14 +749,15 @@ code {font-size:10pt}

- The <google:searchQuery/> - tag is used to - - - display the text of the current query. - + The <google:searchQuery/> tag is used to display + the text of the current query.

+ The specified search keywords (or phrase) are returned by default. + To display the full query (including preset site and + file type options), set the type attribute + to full. +

@@ -773,12 +768,9 @@ code {font-size:10pt}

- The <google:searchTime/> - tag is used to - - - display the total server time used to return the search results, measured in - seconds. + The <google:searchTime/> + tag is used to display the total server time used to return the search results, + measured in seconds.

@@ -790,11 +782,9 @@ code {font-size:10pt}

- The <google:searchTips/> - tag is used to - - - display the tips (if any) included with the current result set. + The <google:searchTips/> + tag is used to display the tips (if any) included with the current result + set.

diff --git a/google-taglib/src/net/thauvin/google/GoogleSearchBean.java b/google-taglib/src/net/thauvin/google/GoogleSearchBean.java index e120882..32eb406 100644 --- a/google-taglib/src/net/thauvin/google/GoogleSearchBean.java +++ b/google-taglib/src/net/thauvin/google/GoogleSearchBean.java @@ -115,6 +115,7 @@ public class GoogleSearchBean "The authorization key has not been specified."; private GoogleSearch service = null; private GoogleSearchResult result = null; + private String keywords = null; private GoogleSearchResultElement elements[] = null; private boolean keySet = false; private int maxResults = 10; @@ -168,6 +169,26 @@ public class GoogleSearchBean return keySet; } + /** + * Sets the search keywords. + * + * @param keywords The keywords + */ + public final void setKeywords(String keywords) + { + this.keywords = keywords; + } + + /** + * Returns the keywords. + * + * @return The keywords value. + */ + public final String getKeywords() + { + return this.keywords; + } + /** * Sets the HTTP proxy host, port, user name and password. * @@ -578,6 +599,10 @@ public class GoogleSearchBean { return String.valueOf(result.getDocumentFiltering()); } + else if (property.equalsIgnoreCase("searchKeywords")) + { + return getKeywords(); + } else if (property.equalsIgnoreCase("searchQuery")) { return result.getSearchQuery(); diff --git a/google-taglib/src/net/thauvin/google/taglibs/Search.java b/google-taglib/src/net/thauvin/google/taglibs/Search.java index 49f1d1f..c8b1f43 100644 --- a/google-taglib/src/net/thauvin/google/taglibs/Search.java +++ b/google-taglib/src/net/thauvin/google/taglibs/Search.java @@ -362,6 +362,8 @@ public class Search extends QuerySupport pageContext.getServletContext() .getInitParameter(TagUtility.GOOGLE_PROXY_PASSWORD)); + bean.setKeywords(getQuery()); + bean.getGoogleSearch(getKey(), getSite() + getQuery() + getType(), getStart(), getMaxResults(), getFilter(), getRestrict(), getSafeSearch(), getLr()); diff --git a/google-taglib/src/net/thauvin/google/taglibs/SearchQuery.java b/google-taglib/src/net/thauvin/google/taglibs/SearchQuery.java index de530a7..47da919 100644 --- a/google-taglib/src/net/thauvin/google/taglibs/SearchQuery.java +++ b/google-taglib/src/net/thauvin/google/taglibs/SearchQuery.java @@ -4,14 +4,14 @@ * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * - * Redistribution and use in source and binary forms, with or without + * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - * Redistributions in binary form must reproduce the above copyright notice, + * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * @@ -20,7 +20,7 @@ * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, @@ -36,6 +36,8 @@ */ package net.thauvin.google.taglibs; +import net.thauvin.google.TagUtility; + /** * A custom tag used to retrieve the query string of a Google search. @@ -47,6 +49,28 @@ package net.thauvin.google.taglibs; */ public class SearchQuery extends SearchResultSupport { + private String type = null; + + /** + * Sets the type attribute + * + * @param type The new attribute value. + */ + public final void setType(String type) + { + this.type = type; + } + + /** + * Release method. + */ + public void release() + { + super.release(); + + type = null; + } + /** * Returns the property provided by this tag. * @@ -54,7 +78,12 @@ public class SearchQuery extends SearchResultSupport */ protected String getPropertyName() { - return "searchQuery"; + if (TagUtility.isValidString(type) && type.equalsIgnoreCase("full")) + { + return "searchQuery"; + } + + return "searchKeywords"; } /** diff --git a/google-taglib/tlds/google.tld b/google-taglib/tlds/google.tld index 990665d..68b0b49 100644 --- a/google-taglib/tlds/google.tld +++ b/google-taglib/tlds/google.tld @@ -181,7 +181,12 @@ net.thauvin.google.taglibs.SearchQuery empty Displays the current search query. - + + type + false + true + + searchResult