forked from I2P_Developers/i2p.i2p
Console: Add initial news to bottom of news page so it doesn't disappear (ticket #1153)
This commit is contained in:
@ -172,6 +172,23 @@ public class NewsManager implements ClientApp {
|
|||||||
return parseNews(newsContent, false);
|
return parseNews(newsContent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The initial (welcome to i2p) news
|
||||||
|
*
|
||||||
|
* @return entry with first-installed date stamp, or null
|
||||||
|
* @since 0.9.28
|
||||||
|
*/
|
||||||
|
public NewsEntry getInitialNews() {
|
||||||
|
List<NewsEntry> list = parseInitialNews();
|
||||||
|
if (list.isEmpty())
|
||||||
|
return null;
|
||||||
|
NewsEntry rv = list.get(0);
|
||||||
|
long installed = _context.getProperty("router.firstInstalled", 0L);
|
||||||
|
if (installed > 0)
|
||||||
|
rv.updated = installed;
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
private List<NewsEntry> parseInitialNews() {
|
private List<NewsEntry> parseInitialNews() {
|
||||||
NewsEntry entry = new NewsEntry();
|
NewsEntry entry = new NewsEntry();
|
||||||
File file = new File(_context.getBaseDir(), "docs/initialNews/initialNews.xml");
|
File file = new File(_context.getBaseDir(), "docs/initialNews/initialNews.xml");
|
||||||
|
@ -50,8 +50,15 @@ public class NewsFeedHelper extends HelperBase {
|
|||||||
ClientAppManager cmgr = ctx.clientAppManager();
|
ClientAppManager cmgr = ctx.clientAppManager();
|
||||||
if (cmgr != null) {
|
if (cmgr != null) {
|
||||||
NewsManager nmgr = (NewsManager) cmgr.getRegisteredApp(NewsManager.APP_NAME);
|
NewsManager nmgr = (NewsManager) cmgr.getRegisteredApp(NewsManager.APP_NAME);
|
||||||
if (nmgr != null)
|
if (nmgr != null) {
|
||||||
entries = nmgr.getEntries();
|
entries = nmgr.getEntries();
|
||||||
|
NewsEntry init = nmgr.getInitialNews();
|
||||||
|
if (init != null) {
|
||||||
|
// crude check to see if it's already in there
|
||||||
|
if (entries.size() != 1 || !DataHelper.eq(entries.get(0).title, init.title))
|
||||||
|
entries.add(init);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!entries.isEmpty()) {
|
if (!entries.isEmpty()) {
|
||||||
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
|
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
|
||||||
|
Reference in New Issue
Block a user