- Fix retrieval of entry links from feed
 - Linkify entry headers
This commit is contained in:
zzz
2015-09-16 16:42:24 +00:00
parent 37597b8c7d
commit 3d533a406d
4 changed files with 19 additions and 9 deletions

View File

@ -269,6 +269,7 @@ public class NewsManager implements RouterApp {
return rv;
}
/****
public static void main(String[] args) {
if (args.length != 0) {
System.err.println("Usage: NewsManager");
@ -281,7 +282,9 @@ public class NewsManager implements RouterApp {
System.out.println("Loaded " + entries.size() + " news entries");
for (int i = 0; i < entries.size(); i++) {
NewsEntry e = entries.get(i);
System.out.println("\n****** News #" + (i+1) + ": " + e.title + ' ' + new Date(e.updated) + '\n' + e.content);
System.out.println("\n****** News #" + (i+1) + ": " + e.title + ' ' + new Date(e.updated) +
"\nLink: " + e.link + '\n' + e.content);
}
}
****/
}

View File

@ -267,9 +267,9 @@ public class NewsXMLParser {
}
n = entry.getNode("link");
if (n != null) {
e.link = n.getValue();
if (e.link != null)
e.link = e.link.trim();
String a = n.getAttributeValue("href");
if (a.length() > 0)
e.link = a.trim();
}
n = entry.getNode("id");
if (n != null) {

View File

@ -155,9 +155,9 @@ class PersistNews {
}
n = entry.getNode("link");
if (n != null) {
e.link = n.getValue();
if (e.link != null)
e.link = e.link.trim();
String a = n.getAttributeValue("href");
if (a.length() > 0)
e.link = a.trim();
}
n = entry.getNode("id");
if (n != null) {
@ -231,6 +231,7 @@ class PersistNews {
return PFX + Base64.encode(hash) + SFX;
}
/****
public static void main(String[] args) {
if (args.length != 1) {
System.err.println("Usage: PersistNews file.xml");
@ -262,4 +263,5 @@ class PersistNews {
System.out.println("\n****** News #" + (i+1) + ": " + e.title + '\n' + e.content);
}
}
****/
}

View File

@ -8,6 +8,7 @@ import java.util.TimeZone;
import net.i2p.I2PAppContext;
import net.i2p.app.ClientAppManager;
import net.i2p.data.DataHelper;
import net.i2p.router.news.NewsEntry;
import net.i2p.router.news.NewsManager;
@ -68,8 +69,12 @@ public class NewsFeedHelper extends HelperBase {
buf.append(fmt.format(date))
.append(": ");
}
buf.append(entry.title)
.append("</h3>\n<div class=\"newscontent\">\n")
if (entry.link != null)
buf.append("<a href=\"").append(DataHelper.escapeHTML(entry.link)).append("\">");
buf.append(entry.title);
if (entry.link != null)
buf.append("</a>");
buf.append("</h3>\n<div class=\"newscontent\">\n")
.append(entry.content)
.append("\n</div></div>\n");
if (i >= start + max)