X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=war%2Fsrc%2Fmain%2Fjava%2Fpnews%2Fservlet%2FHTML.java;h=42564e896d9e857e1da5e685521f2e7bb982e56e;hb=6a601c7b03d36f95fbb69ba487c8a4953828c71d;hp=b78d29bbb2d04c31bd359f849b9ede4e70ea8bda;hpb=7b8a970adb62ec5d1c5ca07b5bbbb5750f0cdd62;p=pnews.git diff --git a/war/src/main/java/pnews/servlet/HTML.java b/war/src/main/java/pnews/servlet/HTML.java index b78d29b..42564e8 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(); @@ -53,7 +58,7 @@ public class HTML { buf.append("
\n"); buf.append("
\n"); - appendA(buf, a.title, "redirect?url=" + URLEncoder.encode(a.link, "UTF-8"), null); + appendA(buf, a.title, "/redirect?url=" + URLEncoder.encode(a.link, "UTF-8"), null); buf.append("
\n"); buf.append("
" + a.website + " - " + a.publicationDate + "
"); @@ -71,13 +76,16 @@ public class HTML { buf.append("
\n"); } - private static void appendMenu(StringBuffer buf, Category catActive) { + private static void appendMenu(StringBuffer buf, Category catActive, Config cfg) { String cl; buf.append("\n"); } - public static String toHTML(List
articles, Category catActive) { + 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"); buf.append("\n"); buf.append("\n"); buf.append("\n"); - buf.append("\n"); - buf.append("PNews\n"); + buf.append("\n"); + buf.append(""); + buf.append(catActive.getTitle()); + buf.append(" - PNews\n"); buf.append("\n"); buf.append("\n"); - appendMenu(buf, catActive); + cats = cfg.getCategories(); + + appendMenu(buf, catActive, cfg); + + try { + entities = provider.getEntityStats(catActive); + + if (entities.size() > 0) { + buf.append("\n"); + } + } 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;