summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2014-10-10 14:35:25 (GMT)
committerDavid A. Madore <david+git@madore.org>2014-10-10 14:35:25 (GMT)
commitcf2ae71372bb49ab83d3db0a093408608faa19d7 (patch)
tree1524417c07d667bab85664fa4336e3802c169e7d
parent8ed1ac19770dca2b5c37c529fe4420068e107f77 (diff)
downloaddamlengine-cf2ae71372bb49ab83d3db0a093408608faa19d7.zip
damlengine-cf2ae71372bb49ab83d3db0a093408608faa19d7.tar.gz
damlengine-cf2ae71372bb49ab83d3db0a093408608faa19d7.tar.bz2
Add support for d:wrefcat="@month" to link specifically to an entry in its month.
-rw-r--r--org/madore/damlengine/TodoWXrefAttr.java2
-rw-r--r--org/madore/damlengine/TodoWrefAttr.java13
2 files changed, 10 insertions, 5 deletions
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";
}
}