summaryrefslogtreecommitdiffstats
path: root/org/madore/damlengine/TodoCutHere.java
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2014-10-10 21:21:14 +0200
committerDavid A. Madore <david+git@madore.org>2014-10-10 21:21:14 +0200
commitd6b9db7926af4dc6d7df5af55d261731bd623c23 (patch)
treed8f289bdfb30202a92404d4be7608a0230c19242 /org/madore/damlengine/TodoCutHere.java
parent5b15f489d9793afdfe5dde2a2934c975b61567bd (diff)
downloaddamlengine-d6b9db7926af4dc6d7df5af55d261731bd623c23.tar.gz
damlengine-d6b9db7926af4dc6d7df5af55d261731bd623c23.tar.bz2
damlengine-d6b9db7926af4dc6d7df5af55d261731bd623c23.zip
Introduce a WeblogLink class to refactor a lot of code on how links are written.
Diffstat (limited to 'org/madore/damlengine/TodoCutHere.java')
-rw-r--r--org/madore/damlengine/TodoCutHere.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/org/madore/damlengine/TodoCutHere.java b/org/madore/damlengine/TodoCutHere.java
index e935c4e..898c784 100644
--- a/org/madore/damlengine/TodoCutHere.java
+++ b/org/madore/damlengine/TodoCutHere.java
@@ -27,12 +27,15 @@ public final class TodoCutHere extends TodoDefaultElement {
throw new IllegalStateException("cut-here element found in non single-page entry");
String lang = LangHelper.getLangRec(node);
String explicitLang = LangHelper.getLangNorec(node);
+ final WeblogLink lk
+ = new WeblogLink(ctx.ent.year, ctx.ent.month,
+ ctx.ent.day, ctx.ent.number,
+ ".CUT", ctx.ent.doSinglePage);
+ lk.setTypeSingle();
if ( ctx.wsc == null
|| ctx.wsc instanceof Context.WeblogSingleSelectionContext ) {
Element div = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "div");
- div.setAttributeNS(null, "id",
- "d." + ctx.ent.date + "." + ctx.ent.number
- + ".CUT");
+ div.setAttributeNS(null, "id", lk.getFragment());
div.setAttributeNS(null, "class", "cut-anchor");
div.appendChild(ctx.doc.createComment(" EMPTY "));
node.getParentNode().replaceChild(div, node);
@@ -40,11 +43,8 @@ public final class TodoCutHere extends TodoDefaultElement {
Element p = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "p");
Element a = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "a");
p.appendChild(a);
- a.setAttributeNS(null, "href",
- ((ctx.gc.uriToTop==null)?"":(ctx.gc.uriToTop+"weblog/"))
- + ctx.ent.date + "-" + ctx.ent.doSinglePage + ".html"
- + "#d." + ctx.ent.date + "." + ctx.ent.number
- + ".CUT");
+ final String baseDir = ((ctx.gc.uriToTop==null)?"":(ctx.gc.uriToTop+"weblog/"));
+ a.setAttributeNS(null, "href", lk.getTarget(baseDir));
if ( explicitLang != null )
LangHelper.setLangNorec(p, explicitLang);
p.setAttributeNS(null, "class", "cut-link");