diff options
Diffstat (limited to 'org/madore/damlengine')
-rw-r--r-- | org/madore/damlengine/Context.java | 5 | ||||
-rw-r--r-- | org/madore/damlengine/TodoCategories.java | 60 | ||||
-rw-r--r-- | org/madore/damlengine/TodoComments.java | 4 | ||||
-rw-r--r-- | org/madore/damlengine/TodoEntryElement.java | 28 | ||||
-rw-r--r-- | org/madore/damlengine/included.css | 9 |
5 files changed, 98 insertions, 8 deletions
diff --git a/org/madore/damlengine/Context.java b/org/madore/damlengine/Context.java index d7c950a..ca521fa 100644 --- a/org/madore/damlengine/Context.java +++ b/org/madore/damlengine/Context.java @@ -68,14 +68,17 @@ public class Context implements Cloneable { public String date; public String number; public String dow; + public ArrayList<String> catList; public Element headerNode; public Element headlinkNode; public EntryContext(String year, String month, String day, - String number, String dow) { + String number, String dow, + ArrayList<String> catList) { this.year = year; this.month = month; this.day = day; this.yandm = year+"-"+month; this.date = yandm+"-"+day; this.number = number; this.dow = dow; + this.catList = catList; } } diff --git a/org/madore/damlengine/TodoCategories.java b/org/madore/damlengine/TodoCategories.java new file mode 100644 index 0000000..3219e82 --- /dev/null +++ b/org/madore/damlengine/TodoCategories.java @@ -0,0 +1,60 @@ +package org.madore.damlengine; + +import java.util.Map; +import java.util.HashMap; +import org.w3c.dom.*; + +public final class TodoCategories extends TodoElement { + + public TodoCategories(Element node, + Context ctx, + TodoItem caller) { + super(node, ctx, caller); + } + + protected final static Map<String,String> listNameTable; + + static { + listNameTable = new HashMap<String,String>(); + listNameTable.put("en", "Categories:"); + listNameTable.put("fr", "Cat\u00e9gories\u00a0:"); + listNameTable.put("de", "Kategorien:"); + listNameTable.put("ia", "Categorias\u00a0:"); + } + + @Override + public void handle() { + Element p = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "p"); + String lang = LangHelper.getLangRec(node); + String explicitLang = LangHelper.getLangNorec(node); + if ( lang == null || listNameTable.get(lang) == null ) { + System.err.println("warning: will use English categories list"); + lang = "en"; + explicitLang = "en"; + } + if ( explicitLang != null ) + LangHelper.setLangNorec(p, explicitLang); + p.setAttributeNS(null, "class", "categories-list"); + node.getParentNode().replaceChild(p, node); + p.appendChild(ctx.doc.createTextNode(listNameTable.get(lang))); + if ( ctx.ent == null ) + throw new IllegalStateException("entry context not defined in categories element"); + for ( String cat : ctx.ent.catList ) { + 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); + 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); + p.appendChild(a2); + a2.appendChild(ctx.doc.createTextNode("\u2022")); + p.appendChild(ctx.doc.createTextNode(")")); + } + } +} diff --git a/org/madore/damlengine/TodoComments.java b/org/madore/damlengine/TodoComments.java index b37129f..e5cb04e 100644 --- a/org/madore/damlengine/TodoComments.java +++ b/org/madore/damlengine/TodoComments.java @@ -24,7 +24,6 @@ public final class TodoComments extends TodoElement { @Override public void handle() { - Element footer = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "footer"); Element p = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "p"); String lang = LangHelper.getLangRec(node); String explicitLang = LangHelper.getLangNorec(node); @@ -36,8 +35,7 @@ public final class TodoComments extends TodoElement { if ( explicitLang != null ) LangHelper.setLangNorec(p, explicitLang); p.setAttributeNS(null, "class", "talkback-link"); - node.getParentNode().replaceChild(footer, node); - footer.appendChild(p); + node.getParentNode().replaceChild(p, node); Element a = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "a"); if ( ctx.ent == null ) throw new IllegalStateException("entry context not defined in comments element"); diff --git a/org/madore/damlengine/TodoEntryElement.java b/org/madore/damlengine/TodoEntryElement.java index 7365b88..db78c06 100644 --- a/org/madore/damlengine/TodoEntryElement.java +++ b/org/madore/damlengine/TodoEntryElement.java @@ -45,6 +45,18 @@ public final class TodoEntryElement extends TodoDefaultElement { String entryMonthStr = entryDateMatcher.group(2); String entryDayStr = entryDateMatcher.group(3); String entryDowStr = node.getAttributeNS(null, "day_of_week"); + String entryCatStr = node.getAttributeNS(null, "cat"); + ArrayList<String> entryCatList; + if ( entryCatStr.equals("") ) { + entryCatList = new ArrayList<String>(0); + } else { + String[] temp = entryCatStr.split("\\s+"); + entryCatList = new ArrayList<String>(temp.length); + for ( String cat : temp ) { + if ( ! cat.equals("") ) + entryCatList.add(cat); + } + } String entryIdStr = "d."+entryDateStr+"."+entryNumberStr; div.setAttributeNS(null, "id", entryIdStr); @@ -76,7 +88,7 @@ public final class TodoEntryElement extends TodoDefaultElement { Context ctx2 = ctx.clone(); ctx2.ent = new Context.EntryContext(entryYearStr, entryMonthStr, entryDayStr, - entryNumberStr, entryDowStr); + entryNumberStr, entryDowStr, entryCatList); ctx2.ent.headerNode = header; ctx2.ent.headlinkNode = headlink; @@ -95,11 +107,21 @@ public final class TodoEntryElement extends TodoDefaultElement { toProcess.add(it); } } + Element footer = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "footer"); + div.appendChild(footer); + div.appendChild(ctx.doc.createTextNode("\n")); + if ( entryCatList.size() > 0 ) { + Element token = ctx.doc.createElementNS(DamlEngine.DAML_NS, + "d:implicit-do-categories"); + footer.appendChild(token); + footer.appendChild(ctx.doc.createTextNode("\n")); + toProcess.add(new TodoCategories(token, ctx2, this)); + } if ( node.getAttributeNS(null, "nocomments").equals("") ) { Element token = ctx.doc.createElementNS(DamlEngine.DAML_NS, "d:implicit-do-comments"); - div.appendChild(token); - div.appendChild(ctx.doc.createTextNode("\n")); + footer.appendChild(token); + footer.appendChild(ctx.doc.createTextNode("\n")); toProcess.add(new TodoComments(token, ctx2, this)); } this.ownerDeque.registerAtStart(toProcess); diff --git a/org/madore/damlengine/included.css b/org/madore/damlengine/included.css index f00f385..3b7b01e 100644 --- a/org/madore/damlengine/included.css +++ b/org/madore/damlengine/included.css @@ -40,10 +40,17 @@ article { display: block; } font-family: Futura, "Avant Garde", Helvetica, Arial, sans-serif; } .talkback-link { - color: rgb(128,64,0); font-size: 0.83em; text-align: right; font-family: Futura, "Avant Garde", Helvetica, Arial, sans-serif; + color: rgb(128,64,0); font-size: 0.83em; text-align: right; + font-family: Futura, "Avant Garde", Helvetica, Arial, sans-serif; margin-bottom: 0pt; } .talkback-link > a { color: inherit; } +.categories-list { + color: rgb(128,64,0); font-size: 0.83em; text-align: right; + font-family: Futura, "Avant Garde", Helvetica, Arial, sans-serif; + margin-bottom: 0pt; +} +.categories-list > a { color: inherit; } .sitemap-note { font-style: italic; color: rgb(96,0,0); |