--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Activator.java Tue Aug 03 14:42:22 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Activator.java Wed Aug 04 09:27:14 2010 -0500
@@ -123,7 +123,6 @@
}
public static void setBusyCursor(final Control control, final boolean isBusy) {
- System.out.println("control="+control);
if (control == null)
return;
final Display display = control.getDisplay();
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/SimpleRSSReader.java Tue Aug 03 14:42:22 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/editor/SimpleRSSReader.java Wed Aug 04 09:27:14 2010 -0500
@@ -21,8 +21,8 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
-import java.text.DateFormat;
import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
@@ -102,18 +102,20 @@
else if (RSSHandler.DESCRIPTION.equals(element) || RSSHandler.SUMMARY.equals(element))
description = value;
else if (RSSHandler.PUBDATE.equals(element)) {
- try {
- // FIXME parser needs writing!!
- DateFormat dateFormat = DateFormat.getInstance();
- dateFormat.setLenient(true);
- pubDate = dateFormat.parse(value);
- } catch (ParseException e) {
- // don't store malformed dates
- }
+ pubDate = parseRFC822Date(value);
}
else if (RSSHandler.CATEGORY.equals(element))
categories.add(value);
}
+
+ private Date parseRFC822Date(String value) {
+ SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z"); //$NON-NLS-1$
+ try {
+ return format.parse(value);
+ } catch (ParseException e) {
+ }
+ return null;
+ }
}
public static class Channel extends Container {
@@ -216,7 +218,6 @@
}
}
-
public static Rss readRSS(URL url) throws SAXException, IOException, ParserConfigurationException {
Rss rss = new Rss();
@@ -227,4 +228,6 @@
parser.parse(inputStream, new RSSHandler(rss));
return rss;
}
+
+
}
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractRSSPortalPageLayer.java Tue Aug 03 14:42:22 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractRSSPortalPageLayer.java Wed Aug 04 09:27:14 2010 -0500
@@ -19,8 +19,10 @@
import java.net.URL;
import java.text.DateFormat;
import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
@@ -36,6 +38,8 @@
public abstract class AbstractRSSPortalPageLayer extends AbstractBrowserPortalPageLayer {
+ private static final List<Pattern> EXCLUDE_TAG_PATTERNS = new ArrayList<Pattern>();
+
private static final String[] EXCLUDE_TAGS = {
"object", //$NON-NLS-1$
"param", //$NON-NLS-1$
@@ -44,10 +48,18 @@
"img" //$NON-NLS-1$
};
- private static final Pattern[] EXCLUDE_TAG_PATTERNS = new Pattern[EXCLUDE_TAGS.length * 2];
+ private static final String[] EXCLUDE_FORMAT_TAGS = {
+ "b", //$NON-NLS-1$
+ "i", //$NON-NLS-1$
+ "em", //$NON-NLS-1$
+ "strong", //$NON-NLS-1$
+ "tt", //$NON-NLS-1$
+ "s", //$NON-NLS-1$
+ "strike", //$NON-NLS-1$
+ "p" //$NON-NLS-1$
+ };
static {
- int i = 0;
for (String tagString : EXCLUDE_TAGS) {
StringBuilder sb = new StringBuilder();
sb.append('<');
@@ -55,18 +67,25 @@
sb.append(" .*</"); //$NON-NLS-1$
sb.append(tagString);
sb.append('>');
- EXCLUDE_TAG_PATTERNS[i++] =
- Pattern.compile(sb.toString(),
- Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
+ EXCLUDE_TAG_PATTERNS.add(Pattern.compile(sb.toString(),
+ Pattern.CASE_INSENSITIVE | Pattern.MULTILINE));
}
for (String tagString : EXCLUDE_TAGS) {
StringBuilder sb = new StringBuilder();
sb.append('<');
sb.append(tagString);
sb.append(" .*/>"); //$NON-NLS-1$
- EXCLUDE_TAG_PATTERNS[i++] =
- Pattern.compile(sb.toString(),
- Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
+ EXCLUDE_TAG_PATTERNS.add(Pattern.compile(sb.toString(),
+ Pattern.CASE_INSENSITIVE | Pattern.MULTILINE));
+ }
+ for (String formatTag : EXCLUDE_FORMAT_TAGS) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("</?"); //$NON-NLS-1$
+ sb.append(formatTag);
+ sb.append('>');
+ EXCLUDE_TAG_PATTERNS.add(Pattern.compile(sb.toString(),
+ Pattern.CASE_INSENSITIVE | Pattern.MULTILINE));
+
}
}
@@ -117,8 +136,11 @@
buf.append("</a>"); //$NON-NLS-1$
buf.append("<div class=\"itemBody\">"); //$NON-NLS-1$
Date date = item.getPubDate();
- if (date != null)
- buf.append(DateFormat.getInstance().format(date));
+ if (date != null) {
+ String dateString = DateFormat.getDateTimeInstance().format(date);
+ buf.append(dateString);
+ buf.append("<br>");
+ }
buf.append(clean(item.getDescription()));
buf.append("</div></li>"); //$NON-NLS-1$
}
@@ -129,10 +151,12 @@
}
private String clean(String s) {
+ String output = s;
for (Pattern pattern : EXCLUDE_TAG_PATTERNS) {
- s = pattern.matcher(s).replaceAll(""); //$NON-NLS-1$
+ output = pattern.matcher(output).replaceAll(""); //$NON-NLS-1$
}
- return s.length() > MAX_ELEM_LEN ? s.substring(0, MAX_ELEM_LEN) : s;
+ output = output.length() > MAX_ELEM_LEN ? output.substring(0, MAX_ELEM_LEN) : output;
+ return output;
}
@Override