Author: jonathan
Date: Thu Jan 24 16:03:28 2008
New Revision: 12850
Log:
MASHUP-582: Improved contents of query-based feeds.
Modified:
trunk/mashup/java/modules/www/search.jsp
Modified: trunk/mashup/java/modules/www/search.jsp
==============================================================================
--- trunk/mashup/java/modules/www/search.jsp (original)
+++ trunk/mashup/java/modules/www/search.jsp Thu Jan 24 16:03:28 2008
@@ -115,7 +115,10 @@
// Format for results - an HTML page, or an RSS feed.
String format = request.getParameter("format");
-
+ boolean isFeed = (format != null) &&
+ (format.toString().equalsIgnoreCase("rss") ||
+ format.toString().equalsIgnoreCase("atom"));
+
String queryTitle = "";
String queryPath = "";
String[] queryParams = new String[] { };
@@ -132,7 +135,7 @@
} else if (query.equalsIgnoreCase("mashups") && searchFor.equals("")) {
// Set up the predefined query for "[My] Mashups"
- queryTitle = (currentUser.equals(searchScope) ? "My" :
+ queryTitle = ((currentUser.equals(searchScope) && !isFeed) ? "My" :
RegistryUtils.getFullName(request, searchScope) + "'s") +
" mashups";
queryPath = MashupConstants.MY_MASHUPS_QUERY_PATH;
queryParams = new String[] { searchScope };
@@ -173,7 +176,7 @@
} else if (query.equalsIgnoreCase("mashups")) {
// Set up the customized query within the mashups of a certain
user as defined by the search phrase and locations
- queryTitle = (currentUser.equals(searchScope) ? "My" :
+ queryTitle = ((currentUser.equals(searchScope) && !isFeed) ? "My" :
RegistryUtils.getFullName(request, searchScope) + "'s") +
" mashups ";
queryPath = MashupConstants.MY_CUSTOM_QUERY_PATH;
@@ -214,7 +217,7 @@
// Set up the predefined query for "[My] Highest Rated Mashups"
queryPath = MashupConstants.MY_TOP_MASHUPS_QUERY_PATH;
- queryTitle = (currentUser.equals(searchScope) ? "My" :
+ queryTitle = ((currentUser.equals(searchScope) && !isFeed) ? "My" :
RegistryUtils.getFullName(request, searchScope) + "'s") +
" highest rated mashups";
@@ -224,7 +227,7 @@
// Set up the predefined query for All comments
queryPath = MashupConstants.COMMENTS_QUERY_PATH;
- queryTitle = "Comments";
+ queryTitle = "Comments on all mashups";
String resourcePath = null;
queryParams = new String[] { "%" + searchFor + "%" };
@@ -233,7 +236,7 @@
// Set up the predefined query for [My] comments
queryPath = MashupConstants.MY_COMMENTS_QUERY_PATH;
- queryTitle = (currentUser.equals(searchScope) ? "My" :
+ queryTitle = ((currentUser.equals(searchScope) && !isFeed) ? "My" :
RegistryUtils.getFullName(request, searchScope) + "'s") +
" comments";
String resourcePath = null;
@@ -246,7 +249,7 @@
if (searchScope == null || searchScope.equals("")) {
queryTitle = "Recent ";
} else {
- queryTitle = (currentUser.equals(searchScope) ? "My" :
+ queryTitle = ((currentUser.equals(searchScope) && !isFeed) ?
"My" :
RegistryUtils.getFullName(request, searchScope) +
"'s") + " recent ";
}
@@ -318,18 +321,57 @@
if (results != null) {
Iterator iter = results.getResults().iterator();
+ String entryTitle, entryAuthor, entryDescription, entryLink;
+ Date entryDate;
while (iter.hasNext()) {
QueryResult result = (QueryResult) iter.next();
+ String mashupAuthor = RegistryUtils.getFullName(request,
result.getPath().split("\\/")[2]);
+ if (results.getResultsType().equals("activity")) {
+ String action = result.getAction();
+ entryTitle = "Activity on " + mashupAuthor + "'s " +
result.getName() + " service";
+ entryDescription =
+ RegistryUtils.getFullName(request,
result.getAuthor()) +
+ " (" + result.getAuthor() + ") " +
+ action +
+ (action.equals("commented") ? " on " : " ") +
+ mashupAuthor + "'s <strong>" + result.getName() +
"</strong> service";
+ if (action.equals("rated")) {
+ entryDescription += " <strong>" +
result.getContentString() + "</strong> stars.";
+ } else if (action.equals("tagged")) {
+ entryDescription += " with <strong>" +
result.getContentString() + "</strong>";
+ } else if (action.equals("commented")) {
+ entryDescription += ": <strong>" +
result.getContentString() + "</strong>";
+ }
+ entryLink = null;
+ } else if (results.getResultsType().equals("comment")) {
+ String serviceName = result.getName().substring(0,
result.getName().indexOf(";"));
+ entryTitle = RegistryUtils.getFullName(request,
result.getAuthor()) + " commented on " +
+ mashupAuthor + "'s " + serviceName + " service.";
+ entryDescription = result.getContentString();
+ } else {
+ entryTitle = result.getName() + " by " +
RegistryUtils.getFullName(request, result.getAuthor()) + " (" +
result.getAuthor() + ")";
+ entryDescription = result.getDescription();
+ String baseURI =
request.getRequestURI().substring(0,request.getRequestURI().lastIndexOf("/"));
+ }
+ URL mashupLink = new URL(request.getScheme(),
+ request.getServerName(),
+ request.getServerPort(),
+ "/mashup.jsp?path=" +
result.getPath());
+ entryLink = mashupLink.toString();
+ entryDate = today;
+ entryAuthor = bundle.getString("main.title");
+
SyndEntry entry = new SyndEntryImpl();
- entry.setTitle(result.getName());
- entry.setPublishedDate(today);
- entry.setAuthor(bundle.getString("main.title"));
+ entry.setTitle(entryTitle);
+ entry.setPublishedDate(entryDate);
+ entry.setAuthor(entryAuthor);
SyndContent description = new SyndContentImpl();
description.setType("text/html");
- description.setValue(result.getDescription());
+ description.setValue(entryDescription);
entry.setDescription(description);
+ if (entryLink != null) entry.setLink(entryLink);
entries.add(entry);
}
@@ -784,8 +826,7 @@
<tr class="results">
<td width="12%" valign="top">
- <nobr><%=QueryParamUtils.friendlyDate(result.getDate())%>
- </nobr>
+ <nobr><%=QueryParamUtils.friendlyDate(result.getDate())%></nobr>
</td>
<td valign="top">
<% if (action.equals("deleted")) { %>
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev