From d6b9db7926af4dc6d7df5af55d261731bd623c23 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Fri, 10 Oct 2014 21:21:14 +0200 Subject: Introduce a WeblogLink class to refactor a lot of code on how links are written. --- org/madore/damlengine/TodoCategories.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'org/madore/damlengine/TodoCategories.java') diff --git a/org/madore/damlengine/TodoCategories.java b/org/madore/damlengine/TodoCategories.java index cc104e8..5d1a175 100644 --- a/org/madore/damlengine/TodoCategories.java +++ b/org/madore/damlengine/TodoCategories.java @@ -40,20 +40,21 @@ public final class TodoCategories extends TodoElement { if ( ctx.ent == null ) throw new IllegalStateException("entry context not defined in categories element"); for ( String cat : ctx.ent.catList ) { + WeblogLink lk = new WeblogLink(ctx.ent.year, ctx.ent.month, + ctx.ent.day, ctx.ent.number, "", + ctx.ent.doSinglePage); + lk.setTypeCat(cat); + String baseDir = ((ctx.gc.uriToTop==null)?"":(ctx.gc.uriToTop+"weblog/")); p.appendChild(ctx.doc.createTextNode(" ")); Element a1 = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "a"); - String target1URL = ((ctx.gc.uriToTop==null)?"":(ctx.gc.uriToTop+"weblog/")) - + cat + ".html"; - a1.setAttributeNS(null, "href", target1URL); + a1.setAttributeNS(null, "href", lk.getFile(baseDir)); a1.setAttributeNS(null, "title", TodoWeblogSelectionElement.categoryName(cat, lang)); p.appendChild(a1); a1.appendChild(ctx.doc.createTextNode(cat)); p.appendChild(ctx.doc.createTextNode("(")); Element a2 = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "a"); - String target2URL = target1URL - + "#d." + ctx.ent.date + "." + ctx.ent.number; - a2.setAttributeNS(null, "href", target2URL); + a2.setAttributeNS(null, "href", lk.getTarget(baseDir)); p.appendChild(a2); a2.appendChild(ctx.doc.createTextNode("\u2022")); p.appendChild(ctx.doc.createTextNode(")")); -- cgit v1.2.3