buf.append("<div class='article-description'>\n");
if (a.description != null) {
buf.append("<p>");
- buf.append(a.description);
+ if (a.description.length() < 512) {
+ buf.append(a.description);
+ } else {
+ buf.append(a.description.substring(0, 512));
+ buf.append("[..]");
+ }
buf.append("</p>");
}
buf.append("</div>\n");
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)