Author: jonathan
Date: Mon Mar 10 12:09:39 2008
New Revision: 14662
Log:
MASHUP-662; Simplified search box, with direct access to a mashup if there's
only one match.
Modified:
trunk/mashup/java/modules/www/css/styles.css
trunk/mashup/java/modules/www/search.jsp
trunk/mashup/java/modules/www/searchbox.jsp
Modified: trunk/mashup/java/modules/www/css/styles.css
==============================================================================
--- trunk/mashup/java/modules/www/css/styles.css (original)
+++ trunk/mashup/java/modules/www/css/styles.css Mon Mar 10 12:09:39 2008
@@ -61,24 +61,24 @@
color: #1E6DCC;
}
-div.advanced-search-link {
+.advanced-search-link {
padding:.3em 1em;
}
-div.advanced-search-link a {
+.advanced-search-link a {
text-decoration: underline;
font-style:italic;
}
-div.advanced-search-link a:link {
+.advanced-search-link a:link {
color: white;
}
-div.advanced-search-link a:visited {
+.advanced-search-link a:visited {
color: white;
}
-div.advanced-search-link a:hover {
+.advanced-search-link a:hover {
color: white;
}
-div.advanced-search-link a:active {
+.advanced-search-link a:active {
color: white;
}
Modified: trunk/mashup/java/modules/www/search.jsp
==============================================================================
--- trunk/mashup/java/modules/www/search.jsp (original)
+++ trunk/mashup/java/modules/www/search.jsp Mon Mar 10 12:09:39 2008
@@ -72,7 +72,7 @@
}
String searchFor = request.getParameter("for");
- if (searchFor == null || searchFor.equals("(anything)")) {
+ if (searchFor == null || searchFor.equals("(mashups)") ||
searchFor.equals("(all mashups)") || searchFor.equals("(all comments)")) {
searchFor = "";
} else {
// strip "%", since they are a special character in our world
@@ -113,6 +113,9 @@
String controls = request.getParameter("controls");
boolean showAdvanced = controls == null ||
controls.equalsIgnoreCase("true");
+ String origin = request.getParameter("origin");
+ boolean feelingLucky = origin != null &&
origin.equalsIgnoreCase("searchBox");
+
// Format for results - an HTML page, or an RSS feed.
String format = request.getParameter("format");
boolean isFeed = (format != null) &&
@@ -274,6 +277,14 @@
results = RegistryUtils.doQuery(registry, queryTitle, queryPath,
queryParams,
MashupConstants.MAX_RESULTS_COUNT);
+
+ if (feelingLucky && results.getResultCount() == 1) {
+ Iterator iter = results.getResults().iterator();
+ if (results.getResultsType().equals("resource") && iter.hasNext())
{
+ QueryResult result = (QueryResult) iter.next();
+ response.sendRedirect("/mashup.jsp?path=" + result.getPath());
+ }
+ }
}
if (format != null) {
@@ -555,9 +566,9 @@
</td>
<td>
<input id="searchMashups_for" type="text" name="for" size="50"
- value="<%= searchFor == null ? "(anything)" : searchFor %>"
- onfocus="prepareInput(event)"
onblur="restoreInput(event,'(anything)')" class="emptyfield" />
- <script type="text/javascript">initInput('searchMashups_for',
'(anything)');</script>
+ value="<%= searchFor == null ? "(all mashups)" : searchFor
%>"
+ onfocus="prepareInput(event)"
onblur="restoreInput(event,'(all mashups)')" class="emptyfield" />
+ <script type="text/javascript">initInput('searchMashups_for',
'(all mashups)');</script>
<div class="search-include">
Include:
@@ -617,9 +628,9 @@
</td>
<td>
<input id="searchComments_for" type="text" name="for" size="50"
- value="<%= searchFor == null ? "(anything)" : searchFor %>"
- onfocus="prepareInput(event)"
onblur="restoreInput(event,'(anything)')" class="emptyfield" />
- <script type="text/javascript">initInput('searchComments_for',
'(anything)');</script>
+ value="<%= searchFor == null ? "(all comments)" : searchFor
%>"
+ onfocus="prepareInput(event)"
onblur="restoreInput(event,'(all comments)')" class="emptyfield" />
+ <script type="text/javascript">initInput('searchComments_for',
'(all comments)');</script>
</td>
<td>
<input id="submit-comments" type="submit" value="Search"/>
Modified: trunk/mashup/java/modules/www/searchbox.jsp
==============================================================================
--- trunk/mashup/java/modules/www/searchbox.jsp (original)
+++ trunk/mashup/java/modules/www/searchbox.jsp Mon Mar 10 12:09:39 2008
@@ -17,22 +17,17 @@
<div id="search">
<form id="formSearch" name="formSearch" action="search.jsp" method="get">
<input type="hidden" name="query" value="mashups">
- <span>Search </span>
- <select name="scope">
- <option value="" <% if (!RegistryUtils.isLoggedIn(registry)) { %>
selected="selected"<% } %>>Everyone's mashups</option>
-<% if (RegistryUtils.isLoggedIn(registry)) { %>
- <option value="<%=RegistryUtils.getCurrentUser(registry)%>"
selected="selected">My mashups</option>
-<% } %>
- </select>
- <span> for </span>
- <input id="searchBox_for" type="text" name="for" value="(anything)"
onfocus="prepareInput(event)" onblur="restoreInput(event,'(anything)')"
class="emptyfield"/>
- <script type="text/javascript">initInput('searchBox_for',
'(anything)');</script>
+ <input type="hidden" name="scope" value="">
+ <input type="hidden" name="origin" value="searchBox">
+ <span>Find </span>
+ <input id="searchBox_for" type="text" name="for" value="(mashups)"
onfocus="prepareInput(event)" onblur="restoreInput(event,'(mashups)')"
class="emptyfield"/>
+ <script type="text/javascript">initInput('searchBox_for',
'(mashups)');</script>
<span style="display:none">
<input type="checkbox" name="tags" value="true" checked="checked"/>
<input type="checkbox" name="titles" value="true"
checked="checked"/>
<input type="checkbox" name="descriptions" value="true"
checked="checked"/>
</span>
<input type="image" src="images/icon-search.gif" alt="search now"
value="submit" class="edit-link" />
- <div class="advanced-search-link"><a href="search.jsp">advanced
search...</a></div>
+ <span> | </span><span class="advanced-search-link"><a
href="search.jsp">Search...</a></span>
</form>
</div>
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev