Author: chris.laprun(a)jboss.com
Date: 2011-11-03 10:03:18 -0400 (Thu, 03 Nov 2011)
New Revision: 7957
Modified:
components/pc/trunk/samples/src/main/artifacts/google-portlet-war/WEB-INF/portlet.xml
components/pc/trunk/samples/src/main/java/org/gatein/pc/samples/google/GoogleClippingPortlet.java
components/pc/trunk/samples/src/main/java/org/gatein/pc/samples/google/GoogleWeatherClippingPortlet.java
Log:
- Fixed Google portlets: tweaked excerpt that we look for, changed user agent so that we
don't get JS-generated HTML, tweaked post-processing for weather icons.
Modified:
components/pc/trunk/samples/src/main/artifacts/google-portlet-war/WEB-INF/portlet.xml
===================================================================
---
components/pc/trunk/samples/src/main/artifacts/google-portlet-war/WEB-INF/portlet.xml 2011-11-03
10:23:56 UTC (rev 7956)
+++
components/pc/trunk/samples/src/main/artifacts/google-portlet-war/WEB-INF/portlet.xml 2011-11-03
14:03:18 UTC (rev 7957)
@@ -50,7 +50,7 @@
<preference>
<!-- Query used to retrieve data -->
<name>query</name>
-
<
value>http://www.google.com/search?gl=US&hl=en&q=</...
+
<
value>http://www.google.com/search?gl=US&hl=en&q=map+&...
<read-only>false</read-only>
</preference>
<preference>
@@ -59,7 +59,7 @@
finds after this String.
-->
<name>beginningString</name>
- <value><![CDATA[<div id=res]]></value>
+ <value><![CDATA[<li class="g"]]></value>
<read-only>false</read-only>
</preference>
</portlet-preferences>
@@ -103,7 +103,7 @@
finds after this String.
-->
<name>beginningString</name>
- <value><![CDATA[<div id=res]]></value>
+ <value><![CDATA[<li class="g"]]></value>
<read-only>false</read-only>
</preference>
</portlet-preferences>
Modified:
components/pc/trunk/samples/src/main/java/org/gatein/pc/samples/google/GoogleClippingPortlet.java
===================================================================
---
components/pc/trunk/samples/src/main/java/org/gatein/pc/samples/google/GoogleClippingPortlet.java 2011-11-03
10:23:56 UTC (rev 7956)
+++
components/pc/trunk/samples/src/main/java/org/gatein/pc/samples/google/GoogleClippingPortlet.java 2011-11-03
14:03:18 UTC (rev 7957)
@@ -63,7 +63,7 @@
* should result in the expected result.
*/
private static final String DEFAULT_QUERY =
"http://www.google.com/search?gl=US&hl=en&q=";
- private static final String DEFAULT_BEG = "<div id=res>";
+ private static final String DEFAULT_BEG = "<li class=\"g\"";
private static final String DEFAULT_ZIP = "94102";
private static final String END_TABLE = "</table>";
private static final String BEG_TABLE = "<table";
@@ -78,7 +78,7 @@
URL url = new URL(query);
URLConnection connection = url.openConnection();
- connection.setRequestProperty("User-Agent", "Mozilla/5.0");
+ connection.setRequestProperty("User-Agent", "Mozilla/4.0
(compatible; MSIE 7.0; Windows NT 6.0)");
BufferedInputStream in = new BufferedInputStream(connection.getInputStream());
String html = new String(getBytes(in, 16384), "UTF-8");
Modified:
components/pc/trunk/samples/src/main/java/org/gatein/pc/samples/google/GoogleWeatherClippingPortlet.java
===================================================================
---
components/pc/trunk/samples/src/main/java/org/gatein/pc/samples/google/GoogleWeatherClippingPortlet.java 2011-11-03
10:23:56 UTC (rev 7956)
+++
components/pc/trunk/samples/src/main/java/org/gatein/pc/samples/google/GoogleWeatherClippingPortlet.java 2011-11-03
14:03:18 UTC (rev 7957)
@@ -43,6 +43,7 @@
endIndex = html.indexOf(A_END, begIndex);
html = html.substring(0, begIndex) + html.substring(endIndex + A_END.length());
}
+ html = html.replaceAll("src=\"\\/\\/",
"src=\"http:\\/\\/");
return super.postProcessHTML(html);
}