From f2c2a5b386134e829606247edfe24ce1e4e712fd Mon Sep 17 00:00:00 2001 From: jrandom Date: Fri, 25 Nov 2005 11:06:00 +0000 Subject: [PATCH] 2005-11-25 jrandom * Don't publish stats for periods we haven't reached yet (thanks zzz!) * Cleaned up the syndie threaded display to show the last updated date for a subthread, and to highlight threads updated in the last two days. --- .../java/src/net/i2p/syndie/BlogManager.java | 3 +- .../src/net/i2p/syndie/web/BaseServlet.java | 7 ++++ .../i2p/syndie/web/ViewThreadedServlet.java | 28 +++++++++++++--- history.txt | 7 +++- .../src/net/i2p/router/RouterVersion.java | 4 +-- .../src/net/i2p/router/StatisticsManager.java | 33 ++++++++++++------- 6 files changed, 61 insertions(+), 21 deletions(-) diff --git a/apps/syndie/java/src/net/i2p/syndie/BlogManager.java b/apps/syndie/java/src/net/i2p/syndie/BlogManager.java index e87f54993..929c37462 100644 --- a/apps/syndie/java/src/net/i2p/syndie/BlogManager.java +++ b/apps/syndie/java/src/net/i2p/syndie/BlogManager.java @@ -949,7 +949,8 @@ public class BlogManager { } private final SimpleDateFormat _dateFormat = new SimpleDateFormat("yyyy/MM/dd", Locale.UK); - private final long getDayBegin(long now) { + public final long getDayBegin() { return getDayBegin(_context.clock().now()); } + public final long getDayBegin(long now) { synchronized (_dateFormat) { try { String str = _dateFormat.format(new Date(now)); diff --git a/apps/syndie/java/src/net/i2p/syndie/web/BaseServlet.java b/apps/syndie/java/src/net/i2p/syndie/web/BaseServlet.java index 91a942285..853d0a742 100644 --- a/apps/syndie/java/src/net/i2p/syndie/web/BaseServlet.java +++ b/apps/syndie/java/src/net/i2p/syndie/web/BaseServlet.java @@ -934,7 +934,14 @@ public abstract class BaseServlet extends HttpServlet { "}\n" + ".threadNavRight {\n" + " text-align: right;\n" + +" float: right;\n" + +" background-color: #BBBBBB;\n" + "}\n" + +".rightOffset {\n" + +" float: right;\n" + +" margin: 0 5px 0 0;\n" + +" display: inline;\n" + +"}\n" + ".postMeta {\n" + " background-color: #BBBBFF;\n" + "}\n" + diff --git a/apps/syndie/java/src/net/i2p/syndie/web/ViewThreadedServlet.java b/apps/syndie/java/src/net/i2p/syndie/web/ViewThreadedServlet.java index 1cd4cf7c0..d0dd7666e 100644 --- a/apps/syndie/java/src/net/i2p/syndie/web/ViewThreadedServlet.java +++ b/apps/syndie/java/src/net/i2p/syndie/web/ViewThreadedServlet.java @@ -99,6 +99,7 @@ public class ViewThreadedServlet extends BaseServlet { } out.write("\n"); + out.write(""); int max = index.getRootCount(); if (threadOffset + 10 > max) { out.write("Next Page> Last Page>>\n"); @@ -109,7 +110,8 @@ public class ViewThreadedServlet extends BaseServlet { out.write(getNavLink(req, -1)); out.write("\">Last Page>>\n"); } - out.write("\n"); + out.write(""); + //out.write("\n"); out.write("\n"); } @@ -247,7 +249,17 @@ public class ViewThreadedServlet extends BaseServlet { out.write(""); - out.write(rend.getEntryDate(node.getEntry().getEntryId())); + long dayBegin = BlogManager.instance().getDayBegin(); + long postId = node.getMostRecentPostDate(); + if (postId >= dayBegin) { + out.write("today"); + } else if (postId >= dayBegin - 24*60*60*1000) { + out.write("yesterday"); + } else { + int daysAgo = (int)((dayBegin - postId + 24*60*60*1000-1)/(24*60*60*1000)); + out.write(daysAgo + " days ago"); + } + out.write(": "); EntryContainer entry = archive.getEntry(node.getEntry()); if (entry == null) throw new RuntimeException("Unable to fetch the entry " + node.getEntry()); @@ -259,9 +271,15 @@ public class ViewThreadedServlet extends BaseServlet { subject = ""; out.write(trim(subject, 40)); out.write("\n\n"); - out.write("view thread\n"); + if (childCount > 0) { + out.write(" view thread\n"); + } else { + out.write("view post\n"); + } out.write("\n"); boolean rendered = true; diff --git a/history.txt b/history.txt index ceb3fc637..6b3a68b25 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,9 @@ -$Id: history.txt,v 1.327 2005/11/23 11:04:56 jrandom Exp $ +$Id: history.txt,v 1.328 2005/11/24 03:45:57 jrandom Exp $ + +2005-11-25 jrandom + * Don't publish stats for periods we haven't reached yet (thanks zzz!) + * Cleaned up the syndie threaded display to show the last updated date for + a subthread, and to highlight threads updated in the last two days. 2005-11-24 jrandom * Fix to save syndication settings in Syndie (thanks spaetz!) diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 167f433b6..21bc31c29 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -15,9 +15,9 @@ import net.i2p.CoreVersion; * */ public class RouterVersion { - public final static String ID = "$Revision: 1.295 $ $Date: 2005/11/23 11:04:56 $"; + public final static String ID = "$Revision: 1.296 $ $Date: 2005/11/24 03:45:56 $"; public final static String VERSION = "0.6.1.5"; - public final static long BUILD = 6; + public final static long BUILD = 7; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("Router ID: " + RouterVersion.ID); diff --git a/router/java/src/net/i2p/router/StatisticsManager.java b/router/java/src/net/i2p/router/StatisticsManager.java index df7fbcc2b..de1d4cc7f 100644 --- a/router/java/src/net/i2p/router/StatisticsManager.java +++ b/router/java/src/net/i2p/router/StatisticsManager.java @@ -182,6 +182,7 @@ public class StatisticsManager implements Service { if (rate == null) return; long periods[] = rate.getPeriods(); for (int i = 0; i < periods.length; i++) { + if (periods[i] > _context.router().getUptime()) continue; if (selectedPeriods != null) { boolean found = false; for (int j = 0; j < selectedPeriods.length; j++) { @@ -233,22 +234,30 @@ public class StatisticsManager implements Service { private void includeThroughput(Properties stats) { RateStat sendRate = _context.statManager().getRate("bw.sendRate"); if (sendRate != null) { - Rate r = sendRate.getRate(5*60*1000); - if (r != null) - stats.setProperty("stat_bandwidthSendBps.5m", num(r.getAverageValue()) + ';' + num(r.getExtremeAverageValue()) + ";0;0;"); - r = sendRate.getRate(60*60*1000); - if (r != null) - stats.setProperty("stat_bandwidthSendBps.60m", num(r.getAverageValue()) + ';' + num(r.getExtremeAverageValue()) + ";0;0;"); + if (_context.router().getUptime() > 5*60*1000) { + Rate r = sendRate.getRate(5*60*1000); + if (r != null) + stats.setProperty("stat_bandwidthSendBps.5m", num(r.getAverageValue()) + ';' + num(r.getExtremeAverageValue()) + ";0;0;"); + } + if (_context.router().getUptime() > 60*60*1000) { + Rate r = sendRate.getRate(60*60*1000); + if (r != null) + stats.setProperty("stat_bandwidthSendBps.60m", num(r.getAverageValue()) + ';' + num(r.getExtremeAverageValue()) + ";0;0;"); + } } RateStat recvRate = _context.statManager().getRate("bw.recvRate"); if (recvRate != null) { - Rate r = recvRate.getRate(5*60*1000); - if (r != null) - stats.setProperty("stat_bandwidthReceiveBps.5m", num(r.getAverageValue()) + ';' + num(r.getExtremeAverageValue()) + ";0;0;"); - r = recvRate.getRate(60*60*1000); - if (r != null) - stats.setProperty("stat_bandwidthReceiveBps.60m", num(r.getAverageValue()) + ';' + num(r.getExtremeAverageValue()) + ";0;0;"); + if (_context.router().getUptime() > 5*60*1000) { + Rate r = recvRate.getRate(5*60*1000); + if (r != null) + stats.setProperty("stat_bandwidthReceiveBps.5m", num(r.getAverageValue()) + ';' + num(r.getExtremeAverageValue()) + ";0;0;"); + } + if (_context.router().getUptime() > 60*60*1000) { + Rate r = recvRate.getRate(60*60*1000); + if (r != null) + stats.setProperty("stat_bandwidthReceiveBps.60m", num(r.getAverageValue()) + ';' + num(r.getExtremeAverageValue()) + ";0;0;"); + } } }