News: connect it all together (ticket #1425):

- Enable new NewsManager to load/store feed items on disk by UUID
 - News items are stored forever, not lost when they are removed from feed
 - News read in once at startup, not at every summary bar refresh
 - Convert old initialNews.xml and news.xml to NewsEntry format
 - Limit display to 2 news items in summary bar, /home and /console
 - New /news page to show all news
This commit is contained in:
zzz
2015-09-15 13:33:29 +00:00
parent a2e38503fe
commit addc9c5ca3
11 changed files with 130 additions and 81 deletions

View File

@@ -97,10 +97,11 @@ public class NewsXMLParser {
*
* @param file XML content only. Any su3 or gunzip handling must have
* already happened.
* @return the root node
* @throws IOException on any parse error
*/
public void parse(File file) throws IOException {
parse(new BufferedInputStream(new FileInputStream(file)));
public Node parse(File file) throws IOException {
return parse(new BufferedInputStream(new FileInputStream(file)));
}
/**
@@ -108,15 +109,17 @@ public class NewsXMLParser {
*
* @param in XML content only. Any su3 or gunzip handling must have
* already happened.
* @return the root node
* @throws IOException on any parse error
*/
public void parse(InputStream in) throws IOException {
public Node parse(InputStream in) throws IOException {
_entries = null;
_metadata = null;
XMLParser parser = new XMLParser(_context);
try {
Node root = parser.parse(in);
extract(root);
return root;
} catch (ParserException pe) {
throw new I2PParserException(pe);
}
@@ -352,7 +355,7 @@ public class NewsXMLParser {
*
* @return non-null
*/
static List<Node> getNodes(Node node, String name) {
public static List<Node> getNodes(Node node, String name) {
List<Node> rv = new ArrayList<Node>();
int count = node.getNNodes();
for (int i = 0; i < count; i++) {