diff options
author | David A. Madore <david+git@madore.org> | 2014-10-11 00:44:10 +0200 |
---|---|---|
committer | David A. Madore <david+git@madore.org> | 2014-10-11 00:44:10 +0200 |
commit | a285090037efb50f19fb3800bf2a015fd53d94c9 (patch) | |
tree | cff7131d12dd10f938d76fef1995f8f5b2b169fb | |
parent | d00919beaf69c925f6287dbde65ce9fc806f735b (diff) | |
download | damlengine-servlet.tar.gz damlengine-servlet.tar.bz2 damlengine-servlet.zip |
Make it possible to link to previous and next entries from the single page template.servlet
-rw-r--r-- | org/madore/damlengine/TodoWXrefAttr.java | 16 | ||||
-rw-r--r-- | org/madore/damlengine/WeblogServlet.java | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/org/madore/damlengine/TodoWXrefAttr.java b/org/madore/damlengine/TodoWXrefAttr.java index bb1c861..e35d06f 100644 --- a/org/madore/damlengine/TodoWXrefAttr.java +++ b/org/madore/damlengine/TodoWXrefAttr.java @@ -22,15 +22,17 @@ public class TodoWXrefAttr extends TodoAttr { @Override public void handle() { String wxrefStr = attr.getValue(); - if ( wxrefStr.equals("##weblog-selection-older") ) { + if ( wxrefStr.equals("##weblog-selection-older") + || wxrefStr.equals("##weblog-selection-newer") ) { if ( ctx.wsc == null ) throw new IllegalStateException("wxref attribute encountered with no weblog selection state"); - int prev = ctx.wsc.sel.first() - 1; + final int trgt = ctx.wsc.sel.first() + + (wxrefStr.equals("##weblog-selection-older") ? -1 : 1); WeblogSummary sum = WeblogSummary.getSummary(ctx.dc); if ( sum != null && sum.entries != null - && sum.entries.containsKey(new Integer(prev)) ) { + && sum.entries.containsKey(new Integer(trgt)) ) { WeblogSummary.EntrySummary ent - = sum.entries.get(new Integer(prev)); + = sum.entries.get(new Integer(trgt)); String target = "#d." + ent.date + "." + String.format("%04d", ent.id); this.owner.removeAttributeNode(this.attr); @@ -38,8 +40,10 @@ public class TodoWXrefAttr extends TodoAttr { = ctx.doc.createAttributeNS(DamlEngine.DAML_NS, "d:wref"); newAttr.setValue(target); this.owner.setAttributeNodeNS(newAttr); - // Force linking to the month page. - this.owner.setAttributeNS(DamlEngine.DAML_NS, "d:wrefcat", "@month"); + if ( ! this.owner.hasAttributeNS(DamlEngine.DAML_NS, "d:wrefcat") ) { + if ( ctx.wsc instanceof Context.WeblogMonthSelectionContext ) + this.owner.setAttributeNS(DamlEngine.DAML_NS, "d:wrefcat", "@month"); + } this.ownerDeque.registerAtStart(new TodoWrefAttr(newAttr, this.owner, this.ctx, this)); } else { diff --git a/org/madore/damlengine/WeblogServlet.java b/org/madore/damlengine/WeblogServlet.java index 444d1ed..39660e5 100644 --- a/org/madore/damlengine/WeblogServlet.java +++ b/org/madore/damlengine/WeblogServlet.java @@ -34,7 +34,7 @@ import javax.servlet.http.HttpServletResponse; public class WeblogServlet extends HttpServlet { - private static final long serialVersionUID = 2014101004L; + private static final long serialVersionUID = 2014101005L; @Override public void init(ServletConfig cfg) |