From cf2ae71372bb49ab83d3db0a093408608faa19d7 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Fri, 10 Oct 2014 16:35:25 +0200 Subject: Add support for d:wrefcat="@month" to link specifically to an entry in its month. --- org/madore/damlengine/TodoWXrefAttr.java | 2 ++ org/madore/damlengine/TodoWrefAttr.java | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'org/madore') diff --git a/org/madore/damlengine/TodoWXrefAttr.java b/org/madore/damlengine/TodoWXrefAttr.java index dbc5511..130ba53 100644 --- a/org/madore/damlengine/TodoWXrefAttr.java +++ b/org/madore/damlengine/TodoWXrefAttr.java @@ -38,6 +38,8 @@ 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"); this.ownerDeque.registerAtStart(new TodoWrefAttr(newAttr, this.owner, this.ctx, this)); } else { diff --git a/org/madore/damlengine/TodoWrefAttr.java b/org/madore/damlengine/TodoWrefAttr.java index 7f69a96..f58f7a3 100644 --- a/org/madore/damlengine/TodoWrefAttr.java +++ b/org/madore/damlengine/TodoWrefAttr.java @@ -54,13 +54,14 @@ public class TodoWrefAttr extends TodoAttr { if ( ! ((wrefYearStr+"-"+wrefMonthStr+"-"+wrefDayStr) .equals(esum.date)) ) throw new IllegalArgumentException("date mismatch for reference to entry "+wrefNumberStr); - if ( wrefCat != null ) { + if ( wrefCat != null && ! wrefCat.equals("@month") ) { if ( esum.catSet == null || ! esum.catSet.contains(wrefCat) ) throw new IllegalArgumentException("reference to entry "+wrefNumberStr+" in wrong category "+wrefCat); } } // Choose file portion of link target if ( esum != null && esum.doSinglePage != null && ! wrefSupplementStr.equals("") ) { + // Linking to a _fragment_ of an entry that has a single page. if ( ctx.wsc != null && ctx.wsc.sel != null && ctx.wsc instanceof Context.WeblogSingleSelectionContext && ((Context.WeblogSingleSelectionContext)ctx.wsc).number == wrefNumber ) @@ -69,16 +70,18 @@ public class TodoWrefAttr extends TodoAttr { targetFile = targetStdDir + esum.date + "-" + esum.doSinglePage + ".html"; } else if ( ctx.wsc != null && ctx.wsc.sel != null && ctx.wsc.sel.contains(wrefNumber) ) { + // Linking to an entry already present on this page. targetFile = ""; - } else if ( wrefCat != null ) { + } else if ( wrefCat != null && ! wrefCat.equals("@month") ) { + // Linking to an entry in a designated category. targetFile = targetStdDir + wrefCat + ".html"; } else { + // Linking to an entry in its month, or single page. targetFile = targetStdDir + wrefYearStr + "-" + wrefMonthStr + ".html"; if ( esum != null && esum.doSinglePage != null // Note to self: remember we could be called from d:wxref - // because of link on "older entries": we don't want - // to link to single entry page in this case. :-\ - && ! ( caller instanceof TodoWXrefAttr ) ) { + // because of link on "older entries". + && ( wrefCat == null || ! wrefCat.equals("@month") ) ) { targetFile = targetStdDir + esum.date + "-" + esum.doSinglePage + ".html"; } } -- cgit v1.2.3