buf.append("</nav>\n");
}
- public static String toHTML(List<Article> articles, Category catActive, Config cfg, ArticleProvider provider) {
+ private static String toURL(Category catActive, String entity) {
+ try {
+ return catActive.getURL() + "?entity=" + URLEncoder.encode(entity, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ LOG.log(Level.SEVERE, "Failed to generate link to entity " + entity, e);
+ return catActive.getURL();
+ }
+ }
+
+ public static String toHTML(List<Article> articles, Category catActive, String entityActive, Config cfg, ArticleProvider provider) {
StringBuffer buf;
int i;
- Category[] cats;
List<EntityStat> entities;
+ String cl;
buf = new StringBuffer();
buf.append("<!DOCTYPE html>\n");
buf.append("</head>\n");
buf.append("<body>\n");
- cats = cfg.getCategories();
-
appendMenu(buf, catActive, cfg);
try {
i = 0;
for (EntityStat s: entities) {
buf.append("<li>");
- buf.append(s.getEntity());
+ if (entityActive != null && s.getEntity().equals(entityActive))
+ cl = "active";
+ else
+ cl = null;
+ appendA(buf, s.getEntity(), toURL(catActive, s.getEntity()), cl);
buf.append("</li>\n");
i++;
if (i > 10)