X-Git-Url: https://wpitchoune.net/gitweb/?a=blobdiff_plain;f=war%2Fsrc%2Fmain%2Fjava%2Fpnews%2Fservlet%2FHTML.java;h=89ce7c5970122ab643f240ad601f890437929931;hb=56c07f5de3319eb61182b7100855801644538e6f;hp=681c84bd1e2365116a0b3a70eb8d8b12294fedbd;hpb=180bf164e8751ae680b27be5302c681b955eba76;p=pnews.git diff --git a/war/src/main/java/pnews/servlet/HTML.java b/war/src/main/java/pnews/servlet/HTML.java index 681c84b..89ce7c5 100644 --- a/war/src/main/java/pnews/servlet/HTML.java +++ b/war/src/main/java/pnews/servlet/HTML.java @@ -1,13 +1,18 @@ package pnews.servlet; +import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; +import com.rometools.rome.io.FeedException; + import pnews.Article; import pnews.Category; +import pnews.EntityStat; +import pnews.Language; public class HTML { private static final String CLASS_NAME= HTML.class.getName(); @@ -71,13 +76,16 @@ public class HTML { buf.append("\n"); } - private static void appendMenu(StringBuffer buf, Category catActive, Category[] cats) { + private static void appendMenu(StringBuffer buf, Category catActive, Config cfg) { String cl; buf.append("\n"); } - public static String toHTML(List
articles, Category catActive, Category[] cats) { + public static String toHTML(List
articles, Category catActive, Config cfg, ArticleProvider provider) { StringBuffer buf; int i; + Category[] cats; + List entities; buf = new StringBuffer(); buf.append("\n"); @@ -109,14 +123,37 @@ public class HTML { buf.append("\n"); buf.append("\n"); - appendMenu(buf, catActive, cats); + cats = cfg.getCategories(); + + appendMenu(buf, catActive, cfg); + + try { + entities = provider.getEntityStats(catActive); + + if (entities.size() > 0) { + buf.append("Hot topics: "); + buf.append("
    "); + i = 0; + for (EntityStat s: entities) { + buf.append("
  • "); + buf.append(s.getEntity()); + buf.append("
  • "); + i++; + if (i > 10) + break; + } + buf.append("
"); + } + } catch (IllegalArgumentException | FeedException | IOException e2) { + LOG.log(Level.SEVERE, "Failed to get entities", e2); + } i = 0; for (Article e: articles) { try { append(buf, e); } catch (UnsupportedEncodingException e1) { - LOG.log(Level.SEVERE, "fail to convert article to HTML", e1); + LOG.log(Level.SEVERE, "Failed to convert article to HTML", e1); } if (i == 100) break;