2005-12-07 jrandom

* Expand the thread we're viewing to its leaf
    * Bugfix on intraday ordering (children are always newer than parents)
This commit is contained in:
jrandom
2005-12-07 20:19:42 +00:00
committed by zzz
parent 19bba048f2
commit 952bcc696a
6 changed files with 45 additions and 19 deletions

View File

@ -53,8 +53,10 @@ class ThreadNodeImpl implements ThreadNode {
void summarizeThread() { void summarizeThread() {
_recursiveAuthors.add(_entry.getKeyHash()); _recursiveAuthors.add(_entry.getKeyHash());
_recursiveEntries.add(_entry); _recursiveEntries.add(_entry);
_mostRecentPostDate = _entry.getEntryId(); // children are always 'newer' than parents, even if their dates are older
_mostRecentPostAuthor = _entry.getKeyHash(); // (e.g. post #1 for a child on tuesday is 'newer' than post #5 for the parent on tuesday)
_mostRecentPostDate = -1;
_mostRecentPostAuthor = null;
// we need to go through all children (recursively), in case the // we need to go through all children (recursively), in case the
// tree is out of order (which it shouldn't be, if its built carefully...) // tree is out of order (which it shouldn't be, if its built carefully...)
@ -71,6 +73,22 @@ class ThreadNodeImpl implements ThreadNode {
_recursiveAuthors.addAll(node.getRecursiveAuthors()); _recursiveAuthors.addAll(node.getRecursiveAuthors());
_recursiveEntries.addAll(node.getRecursiveEntries()); _recursiveEntries.addAll(node.getRecursiveEntries());
} }
if (_mostRecentPostDate < 0) {
_mostRecentPostDate = _entry.getEntryId();
_mostRecentPostAuthor = _entry.getKeyHash();
}
// now reorder the children
TreeSet ordered = new TreeSet(new WritableThreadIndex.NewestNodeFirstComparator());
for (int i = 0; i < _children.size(); i++) {
ThreadNodeImpl kid = (ThreadNodeImpl)_children.get(i);
ordered.add(kid);
}
List kids = new ArrayList(ordered.size());
for (Iterator iter = ordered.iterator(); iter.hasNext(); )
kids.add(iter.next());
_children = kids;
} }
public String toString() { public String toString() {

View File

@ -152,7 +152,7 @@ class WritableThreadIndex extends ThreadIndex {
} }
} }
/** sort ThreadNodeImpl instances with the highest entryId first */ /** sort ThreadNodeImpl instances with the highest entryId first */
private class NewestNodeFirstComparator implements Comparator { public static class NewestNodeFirstComparator implements Comparator {
public int compare(Object lhs, Object rhs) { public int compare(Object lhs, Object rhs) {
ThreadNodeImpl left = (ThreadNodeImpl)lhs; ThreadNodeImpl left = (ThreadNodeImpl)lhs;
ThreadNodeImpl right = (ThreadNodeImpl)rhs; ThreadNodeImpl right = (ThreadNodeImpl)rhs;

View File

@ -650,7 +650,7 @@ public class HTMLRenderer extends EventReceiverImpl {
_postBodyBuffer.append("schema=").append(sanitizeURL(l.schema)).append('&'); _postBodyBuffer.append("schema=").append(sanitizeURL(l.schema)).append('&');
if (l.location != null) if (l.location != null)
_postBodyBuffer.append("location=").append(sanitizeURL(l.location)).append('&'); _postBodyBuffer.append("location=").append(sanitizeURL(l.location)).append('&');
_postBodyBuffer.append("\">").append(sanitizeString(l.location)); _postBodyBuffer.append("\">").append(sanitizeString(l.location, 30));
_postBodyBuffer.append(getSpan("summDetailExternalNet")).append(" (").append(sanitizeString(l.schema)).append(")</span></a> "); _postBodyBuffer.append(getSpan("summDetailExternalNet")).append(" (").append(sanitizeString(l.schema)).append(")</span></a> ");
} }
_postBodyBuffer.append("<br />\n"); _postBodyBuffer.append("<br />\n");

View File

@ -376,10 +376,10 @@ public class ThreadedHTMLRenderer extends HTMLRenderer {
for (int i = 0; i < _entry.getAttachments().length; i++) { for (int i = 0; i < _entry.getAttachments().length; i++) {
_postBodyBuffer.append("<option value=\"").append(i).append("\">"); _postBodyBuffer.append("<option value=\"").append(i).append("\">");
Attachment a = _entry.getAttachments()[i]; Attachment a = _entry.getAttachments()[i];
_postBodyBuffer.append(sanitizeString(a.getName())); _postBodyBuffer.append(sanitizeString(a.getName(), 30));
if ( (a.getDescription() != null) && (a.getDescription().trim().length() > 0) ) { if ( (a.getDescription() != null) && (a.getDescription().trim().length() > 0) ) {
_postBodyBuffer.append(": "); _postBodyBuffer.append(": ");
_postBodyBuffer.append(sanitizeString(a.getDescription())); _postBodyBuffer.append(sanitizeString(a.getDescription(), 30));
} }
_postBodyBuffer.append(" (").append(a.getDataLength()/1024).append("KB"); _postBodyBuffer.append(" (").append(a.getDataLength()/1024).append("KB");
_postBodyBuffer.append(", type ").append(sanitizeString(a.getMimeType())).append(")</option>\n"); _postBodyBuffer.append(", type ").append(sanitizeString(a.getMimeType())).append(")</option>\n");
@ -396,7 +396,7 @@ public class ThreadedHTMLRenderer extends HTMLRenderer {
boolean expanded = (_user != null ? _user.getShowExpanded() : false); boolean expanded = (_user != null ? _user.getShowExpanded() : false);
boolean images = (_user != null ? _user.getShowImages() : false); boolean images = (_user != null ? _user.getShowImages() : false);
_postBodyBuffer.append(getPageURL(new Hash(Base64.decode(b.hash)), b.tag, b.entryId, -1, -1, expanded, images)); _postBodyBuffer.append(getPageURL(new Hash(Base64.decode(b.hash)), b.tag, b.entryId, -1, -1, expanded, images));
_postBodyBuffer.append("\">").append(sanitizeString(b.name)).append("</a> "); _postBodyBuffer.append("\">").append(sanitizeString(b.name, 30)).append("</a> ");
} }
_postBodyBuffer.append("<br />\n"); _postBodyBuffer.append("<br />\n");
} }
@ -412,7 +412,7 @@ public class ThreadedHTMLRenderer extends HTMLRenderer {
_postBodyBuffer.append("schema=").append(sanitizeURL(l.schema)).append('&'); _postBodyBuffer.append("schema=").append(sanitizeURL(l.schema)).append('&');
if (l.location != null) if (l.location != null)
_postBodyBuffer.append("location=").append(sanitizeURL(l.location)).append('&'); _postBodyBuffer.append("location=").append(sanitizeURL(l.location)).append('&');
_postBodyBuffer.append("\">").append(sanitizeString(l.location)); _postBodyBuffer.append("\">").append(sanitizeString(l.location, 30));
_postBodyBuffer.append(getSpan("summDetailExternalNet")).append(" (").append(sanitizeString(l.schema)).append(")</span></a> "); _postBodyBuffer.append(getSpan("summDetailExternalNet")).append(" (").append(sanitizeString(l.schema)).append(")</span></a> ");
} }
_postBodyBuffer.append("<br />\n"); _postBodyBuffer.append("<br />\n");
@ -439,7 +439,7 @@ public class ThreadedHTMLRenderer extends HTMLRenderer {
_postBodyBuffer.append(AddressesServlet.PARAM_NAME).append("=").append(sanitizeTagParam(a.name)).append('&'); _postBodyBuffer.append(AddressesServlet.PARAM_NAME).append("=").append(sanitizeTagParam(a.name)).append('&');
if (a.protocol != null) if (a.protocol != null)
_postBodyBuffer.append(AddressesServlet.PARAM_PROTO).append("=").append(sanitizeTagParam(a.protocol)).append('&'); _postBodyBuffer.append(AddressesServlet.PARAM_PROTO).append("=").append(sanitizeTagParam(a.protocol)).append('&');
_postBodyBuffer.append("\">").append(sanitizeString(a.name)).append("</a>"); _postBodyBuffer.append("\">").append(sanitizeString(a.name, 30)).append("</a>");
} }
} }
_postBodyBuffer.append("<br />\n"); _postBodyBuffer.append("<br />\n");

View File

@ -951,16 +951,20 @@ public abstract class BaseServlet extends HttpServlet {
String tags, String author) { String tags, String author) {
StringBuffer buf = new StringBuffer(64); StringBuffer buf = new StringBuffer(64);
buf.append(uri); buf.append(uri);
BlogURI expandTo = node.getEntry();
if (node.getChildCount() > 0) { if (node.getChildCount() > 0) {
buf.append('?').append(ThreadedHTMLRenderer.PARAM_VISIBLE).append('='); if (true) {
ThreadNode child = node.getChild(0); // lets expand to the leaf
buf.append(child.getEntry().getKeyHash().toBase64()).append('/'); expandTo = new BlogURI(node.getMostRecentPostAuthor(), node.getMostRecentPostDate());
buf.append(child.getEntry().getEntryId()).append('&'); } else {
} else { // only expand one level
buf.append('?').append(ThreadedHTMLRenderer.PARAM_VISIBLE).append('='); expandTo = node.getChild(0).getEntry();
buf.append(node.getEntry().getKeyHash().toBase64()).append('/'); }
buf.append(node.getEntry().getEntryId()).append('&'); }
} buf.append('?').append(ThreadedHTMLRenderer.PARAM_VISIBLE).append('=');
buf.append(expandTo.getKeyHash().toBase64()).append('/');
buf.append(expandTo.getEntryId()).append('&');
buf.append(ThreadedHTMLRenderer.PARAM_VIEW_THREAD).append('='); buf.append(ThreadedHTMLRenderer.PARAM_VIEW_THREAD).append('=');
buf.append(node.getEntry().getKeyHash().toBase64()).append('/'); buf.append(node.getEntry().getKeyHash().toBase64()).append('/');
buf.append(node.getEntry().getEntryId()).append('&'); buf.append(node.getEntry().getEntryId()).append('&');

View File

@ -1,4 +1,8 @@
$Id: history.txt,v 1.347 2005/12/04 15:12:19 jrandom Exp $ $Id: history.txt,v 1.348 2005/12/05 01:14:16 jrandom Exp $
2005-12-07 jrandom
* Expand the thread we're viewing to its leaf
* Bugfix on intraday ordering (children are always newer than parents)
2005-12-05 jrandom 2005-12-05 jrandom
* Added an RDF and XML thread export to Syndie, reachable at * Added an RDF and XML thread export to Syndie, reachable at